1. Installing the operating system
Download the latest system: CentOS 7.7 centos-7-x86_-dvd-1908.iso
2. Set up network, adopt NAT, virtual machine fixed IP
โ vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes PV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=c96bc909-188e-ec64-3a96-6a90982b08ad DEVICE=ens33 ONBOOT=yes IPADDR=192.168.217.4 NETMASK=255.255.255.0 GATEWAY=192.168.217.2 DNS1=114.114.114.114 DNS2=8.8.8.8
Note: a lot of time is wasted here to solve network problems (virtual machine and host, virtual machine and virtual machine can communicate). It's because GATEWAY misspelled a word name, which delayed more than 2 hours to find the problem.
3. Install Docker
Due to the use of lancher and k8s in subsequent plans, the installation was developed in version 18.09.9
Version selection basis: https://rancher.com/docs/rancher/v1.6/en/hosts/#supported-docker-versions
#Set yum source (important: use alisource, otherwise timeout) [root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #Update index [root@localhost ~]# yum makecache fast #Execution and installation [root@localhost ~]# yum install -y docker-ce-18.09.9 #Start docker [root@localhost ~]# systemctl restart docker #View docker information [root@localhost ~]# docker info #Configure the accelerator to add a new daemon.json file, as follows [root@localhost docker]# vi /etc/docker/daemon.json { "registry-mirrors":["https://3r3lw4z9.mirror.aliyuncs.com"] } #Restart, check the docker information, and verify whether the image address is changed successfully [root@localhost docker]# systemctl restart docker [root@localhost docker]# docker info
4. Install GitLab
Reference documents: https://docs.gitlab.com/omnibus/docker/
Note: 1. The development environment restart policy is configured as no, and the production environment can be configured as always or on failure: 3
2. The content of the virtual machine is at least 3G. The previous configuration of 1G failed to start GitLab. [there's a pit here, fill in the back]
docker run -d -p 10443:443 -p 10080:80 -p 10022:22 \ -v /srv/gitlab/config:/etc/gitlab \ -v /srv/gitlab/logs:/var/log/gitlab \ -v /srv/gitlab/data:/var/opt/gitlab \ --hostname 192.168.217.4 \ --name gitlab \ --restart no \ gitlab/gitlab-ce:latest
After installation, query the running status. Note that the startup time of status will be relatively long, about 4 or 5 minutes
[root@localhost docker]# docker p
Visit: http://192.168.217.4:10080/ Verification. After setting the password, you can log in. The default user is root
5. Configure Git Lab - solve the problem of incorrect ssh clone address
Because the default ssh port of GitLab is 22, we map it to 10022 of the host through mapping. So we need to configure the following GitLab.
Now, if you have no port and use the default port 22, i.e. port 22 of the host, you can't pull the code.
Set GitLab parameters
-
1. Edit the / srv/gitlab/config/gitlab.rb configuration file on the host. [see the - v parameter at the start of the container for the path] gitlab [rails ['gitlab [shell] ssh [port '] = 10022 เท modify the ssh port. Refer to the host port mapped to port 22 at the start of the container for the value
You can also enter the container (docker exec - it gitlab / bin / bash), directly VI / etc / gitlab / gitlab.rb, and then set the parameters. Same effect as above.
-
2. Restart GitLab container
[root@localhost]# docker restart gitlab
6. Configure Git Lab - resolve incorrect http clone address.
It's very troublesome to reconfigure if you find any problems. This should be taken into account at startup. [fill in the pit in front, and keep the same inside and outside the http access address] fill in the pit.
PS: during the integration of JIRA and GitLab, it was found that JIRA was unable to pull the code, and it was found during troubleshooting. It shows that JIRA pull code is implemented through http (like nonsense, and ssh public key is not configured).
-
Modify the external_url of the configuration with http~
The operation is similar to modifying ssh port. vi /etc/gitlab/gitlab.rb
# For HTTP external_url "http://192.168.217.4:10080" or # For HTTPS (notice the https) external_url "https://192.168.217.4:10080"
Internal gitlab uses nginx to provide services, and the listening port is pulled from the external "URL by default. So you don't need to modify nginx configuration.
-
Rebuild the container [do not rebuild the container, there are some online Posts saying that you can directly modify the configuration file, but it feels like the way is a little wild, and you can study it if you are interested]
#Stopped container [root@localhost]# sudo docker stop gitlab #Delete existing containers [root@localhost]# sudo docker rm gitlab #New container [root@localhost]# docker run -d -p 10080:10080 -p 10022:22 -v /srv/gitlab/config:/etc/gitlab -v /srv/gitlab/logs:/var/log/gitlab -v /srv/gitlab/data:/var/opt/gitlab --hostname 192.168.217.4 --name gitlab --restart no gitlab/gitlab-ce:latest
Verify resolution
WARNING: IPv4 forwarding is disabled. Networking will not work
gitLab can't be accessed. Keep the data to rebuild the container and report WARNING: IPv4 forwarding is disabled. Networking will not work.
Edit / etc/sysctl.conf, add a line: net.ipv4.ip_forward=1, and restart the network service. Problem solving.