1. Configure network cards and storage source
1) Configure the network card eth0, local network card without specifying the gateway and domain name server
network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: [192.168.1.30/24]
2) configure the network card eth1, to maintain a strict two-byte indentation, otherwise it will cause the card to get up
root@ubuntu1804:~# vim /etc/netplan/02-netcfg.yaml network: version: 2 renderer: networkd ethernets: eth1: dhcp4: yes addresses: [192.168.10.107/24] gateway4: 192.168.10.1 nameservers: addresses: [223.6.6.6]
3) Configuration Ali cloud warehouse sources
root@ubuntu1804:~# vim /etc/apt/sources.list deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
4) Update warehouse
root@ubuntu1804:~# apt update root@ubuntu1804:~# apt update Get:1 http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB] Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB] ……
2. Install the package gitlab
1) Download gitlab-ce Community Edition Package
root@ubuntu1804:~# ls /data/ gitlab-ce_11.11.5-ce.0_amd64.deb
2) Installation gitlab, adapted to determine the packet gitlab this release system ubuntu
root@ubuntu1804:/data# dpkg -i gitlab-ce_11.11.5-ce.0_amd64.deb root@ubuntu1804:/data# dpkg -i gitlab-ce_11.11.5-ce.0_amd64.deb Selecting previously unselected package gitlab-ce. (Reading database ... 69294 files and directories currently installed.) Preparing to unpack gitlab-ce_11.11.5-ce.0_amd64.deb ... Unpacking gitlab-ce (11.11.5-ce.0) … #等待安装完成
3) At this time, the host can not identify, modify the configuration file git, specify the host
@ ubuntu1804 the root: / Data # Vim /etc/gitlab/gitlab.rb external_url 'http://192.168.1.30' ip host specified modified #
4) for configuring initialization gitlab
root@ubuntu1804:/data# gitlab-ctl reconfigure
3. Command operation
1) into the database command line
root@ubuntu1804:~# gitlab-psql gitlabhq_production-# \db List of tablespaces Name | Owner | Location ------------+-------------+---------- pg_default | gitlab-psql | pg_global | gitlab-psql | (2 rows)
2) Check the operating status gitlab
root@ubuntu1804:~# gitlab-ctl status run: alertmanager: (pid 4704) 1841s; run: log: (pid 4373) 1867s run: gitaly: (pid 4475) 1844s; run: log: (pid 3483) 2026s run: gitlab-monitor: (pid 4553) 1843s; run: log: (pid 4169) 1887s run: gitlab-workhorse: (pid 4512) 1844s; run: log: (pid 4027) 1910s run: logrotate: (pid 4073) 1900s; run: log: (pid 4089) 1899s run: nginx: (pid 4040) 1906s; run: log: (pid 4060) 1905s run: node-exporter: (pid 4537) 1843s; run: log: (pid 4146) 1892s run: postgres-exporter: (pid 4727) 1840s; run: log: (pid 4409) 1863s run: postgresql: (pid 3659) 2012s; run: log: (pid 3689) 2011s run: prometheus: (pid 4578) 1842s; run: log: (pid 4245) 1875s run: redis: (pid 3417) 2034s; run: log: (pid 3442) 2031s run: redis-exporter: (pid 4561) 1842s; run: log: (pid 4202) 1881s run: sidekiq: (pid 3967) 1920s; run: log: (pid 3983) 1916s run: unicorn: (pid 3908) 1926s; run: log: (pid 3957) 1923s
3) Start gitlab service the command line, stop, restart
gitlab-ctl start/stop/restart gitlab
4) Check gitlab service components of nginx logs
root@ubuntu1804:~# gitlab-ctl tail nginx ==> /var/log/gitlab/nginx/current <== ==> /var/log/gitlab/nginx/access.log <== ==> /var/log/gitlab/nginx/error.log <== ==> /var/log/gitlab/nginx/gitlab_error.log <== ==> /var/log/gitlab/nginx/gitlab_access.log <== 192.168.1.1 - - [21/Jul/2019:10:36:00 +0800] "GET / HTTP/1.1" 302 99 "" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3724.8 Safari/537.36" ……
4. browser access gitlab
1) Set a new password, the default user logged in as root
2) The default login interface
3) Click the setting, click on the sign-up you can set whether to allow the creation of a new user
4) remove the check mark, new account creation blocked
5) Then click Save Changes take effect
6) At this time log out, there is no option to registered users only log in with an existing account
7) will be mail notification when you create a new user
8) create different projects, groups, accounts, specific users into specific groups, to achieve a particular user has permission to view certain items
9) to return to the project list and enter a project
10) Click New file
11) Enter an index test page, then click submit
12) view projects clone address
13) The client clone
root@ubuntu1804:/data/src# git clone http://192.168.1.30/root/web-page.git Cloning into 'web-page'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done.
14) project code cloning success
root@ubuntu1804:/data/src# ls web-page root@ubuntu1804:/data/src# cat web-page/index.html <h>hello jie!</h1>
15) Modify index.html client
root@ubuntu1804:/data/src/web-page# cat index.html <h>hello jie!</h1> <h>hello kobe!</h1> <h>hello curry!</h1> <h>hello rose!</h1>
16) prior to the local staging area (gitlab submit code to the server, commands must be down to clone folders execution environment)
root@ubuntu1804:/data/src/web-page# git add index.html
17), referring to the work area
root@ubuntu1804:/data/src/web-page# git commit -m 'v6' [master 1202723] v6 1 file changed, 4 insertions(+), 1 deletion(-)
18) is then submitted directly to the end of the web repository gitlab
root @ ubuntu1804: / data / src / web-page # git push # wherein git pull to acquire code to local Username for 'http://192.168.1.30': root # gitlab require a login name of the web end user Password for ' http: //[email protected] ': # re-enter the user's login web terminal password gitlab a Counting Objects:.. 3, DONE of Delta up to the using compression. 4 Threads. Compressing Objects: 100% (] 2/2), DONE. Writing Objects: 100% (3/3), 268 bytes | 268.00 KiB / S, DONE. the Total. 3 (Delta 0), the Reused 0 (0 Delta) the To http://192.168.1.30/root/web-page.git ecc001d ..1202723 master -> master # submit completed
19) Check the web end gitlab warehouse project index.html content is changed, indicating successfully submitted
20) again to modify the index.html file, and then upload the v7 version of index.html to the server gitlab
Some basic commands 5.gitlab operation (the Operation Command clone must be in a folder down execution environment, or can not execute orders)
1) client to view the current version is v7
root@ubuntu1804:/data/src/web-page# git reset --hard HEAD HEAD is now at 952e66b v7
2) Check v7 version Index
root@ubuntu1804:/data/src/web-page# cat index.html <h>hello jie!</h1> <h>hello kobe!</h1> <h>hello curry!</h1> <h>hello rose!</h1> <h>hello jordan!</h1> <h>hello jordan!</h1> <h>hello howard!</h1>
3) To roll back to the version v6, following the operation command rollback
root@ubuntu1804:/data/src/web-page# git reset --hard HEAD^ HEAD is now at 9cb6bf6 v6
4) View v6 version of the index file
root@ubuntu1804:/data/src/web-page# cat index.html <h>hello jie!</h1> <h>hello kobe!</h1> <h>hello curry!</h1> <h>hello rose!</h1> <h>hello jordan!</h1> <h>hello jordan!</h1>
5) Check the object code id number of each submission,
root@ubuntu1804:/data/src/web-page# git reflog 9cb6bf6 (HEAD -> master) HEAD@{0}: reset: moving to HEAD^ 952e66b (origin/master, origin/HEAD) HEAD@{1}: reset: moving to HEAD 952e66b (origin/master, origin/HEAD) HEAD@{2}: commit: v7 9cb6bf6 (HEAD -> master) HEAD@{3}: commit: v6 03e27be (tag: v1.4) HEAD@{4}: commit: v7 1202723 HEAD@{5}: commit: v6 ecc001d HEAD@{6}: clone: from http://192.168.1.30/root/web-page.git
6) can also be targeting the id code is to achieve rollback
root@ubuntu1804:/data/src/web-page# git reset --hard 9cb6bf6
7) Check branch currently belongs, the default is master of the main branch
root@ubuntu1804:/data/src/web-page# git branch * master
8) Create and switch to a new branch
root@ubuntu1804:/data/src/web-page# git checkout -b operations Switched to a new branch 'operations'
9) lists all branches branch again
root@ubuntu1804:/data/src/web-page# git branch master * operations
10) to switch back to the main branch
root@ubuntu1804:/data/src/web-page# git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) root@ubuntu1804:/data/src/web-page# git branch * master operations
6. Data Backup
1) must first suspend data services gitlab two former backup, to avoid developers continue to submit code when backing up to gitlab, resulting in incomplete data
root@ubuntu1804:~# gitlab-ctl stop sidekiq ok: down: sidekiq: 0s, normally up root@ubuntu1804:~# gitlab-ctl stop nunicorn
2) manually create a backup
root@ubuntu1804:~# gitlab-rake gitlab:backup:create
3) gitlab default backup data path and name for the compressed file
root@ubuntu1804:~# ll /var/opt/gitlab/backups/1563709800_2019_07_21_11.11.5_gitlab_backup.tar -rw------- 1 git git 92160 Jul 21 19:50 /var/opt/gitlab/backups/1563709800_2019_07_21_11.11.5_gitlab_backup.tar
4) web end gitlab of existing projects, users and groups
5) to delete several items, users or groups
7. Client Data Recovery
1) Before restoring data also closed gitlab first two data services
root@ubuntu1804:~# gitlab-ctl stop sidekiq ok: down: sidekiq: 0s, normally up root@ubuntu1804:~# gitlab-ctl stop unicorn ok: down: unicorn: 0s, normally up
2) to perform a backup data recovery command
root@ubuntu1804:~# gitlab-rake gitlab:backup:restore /var/opt/gitlab/backups/1563709800_2019_07_21_11.11.5_gitlab_backup.tar
3) In the two open data services gitlab
oot@ubuntu1804:~# gitlab-ctl start sidekiq ok: run: sidekiq: (pid 80094) 1s root@ubuntu1804:~# gitlab-ctl start unicorn ok: run: unicorn: (pid 80191) 0s
4) gitlab end of web access test, you can see deleted items, users, groups all restore