https://about.gitlab.com/install/
(一)GitLab安装
1.安装并配置必要的依赖项
在CentOS 7(和RedHat / Oracle / Scientific Linux 7)上,以下命令还将在系统防火墙中打开HTTP和SSH访问
[root@docker01 ~]# yum install -y curl policycoreutils-python openssh-server
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: mirrors.163.com
* updates: ftp.sjtu.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): updates/7/x86_64/primary_db | 6.5 MB 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db | 30 kB 00:00:00
软件包 curl-7.29.0-51.el7.x86_64 已安装并且是最新版本
软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 已安装并且是最新版本
软件包 openssh-server-7.4p1-16.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@docker01 ~]# systemctl enable sshd
[root@docker01 ~]# systemctl start sshd
[root@docker01 ~]# firewall-cmd --permanent --add-service=http
success
[root@docker01 ~]# systemctl reload firewalld
关闭selinux防火墙
[root@docker01 ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are prote
cted.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
重启生效
[root@docker01 ~]# reboot
下载安装文件
安装文件也可去国内源网站,速度更快。
清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
此次下载稳定版gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
2.安装GitLab
使用ftp工具将安装文件上传到当前目录
[root@docker01 ~]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
警告:gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:gitlab-ce-10.2.2-ce.0.el7 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
......
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
(1)修改配置文件
[root@docker01 ~]# vi /etc/gitlab/gitlab.rb
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-ex
ternal-url-for-gitlab
external_url 'http://gitlab.example.com'修改为
external_url 'http://192.168.32.128'
更改配置文件后需重新配置(等待时间较长)
[root@docker01 ~]# gitlab-ctl reconfigure
......
Running handlers:
Running handlers complete
Chef Client finished, 382/541 resources updated in 02 minutes 07 seconds
gitlab Reconfigured!
(2)查看状态
[root@docker01 ~]# gitlab-ctl status
run: gitaly: (pid 9136) 59s; run: log: (pid 8923) 88s
run: gitlab-monitor: (pid 9200) 55s; run: log: (pid 9022) 80s
run: gitlab-workhorse: (pid 9124) 60s; run: log: (pid 8879) 101s
run: logrotate: (pid 8905) 94s; run: log: (pid 8904) 94s
run: nginx: (pid 8885) 100s; run: log: (pid 8884) 100s
run: node-exporter: (pid 9009) 82s; run: log: (pid 9008) 82s
run: postgres-exporter: (pid 9220) 54s; run: log: (pid 9068) 71s
run: postgresql: (pid 8657) 140s; run: log: (pid 8656) 140s
run: prometheus: (pid 9209) 54s; run: log: (pid 9049) 73s
run: redis: (pid 8597) 146s; run: log: (pid 8596) 146s
run: redis-exporter: (pid 9036) 74s; run: log: (pid 9035) 74s
run: sidekiq: (pid 8861) 107s; run: log: (pid 8860) 107s
run: unicorn: (pid 8822) 113s; run: log: (pid 8821) 113s
(3)程序相关目录
1程序安装目录
[root@docker01 ~]# ll /opt/gitlab/
总用量
drwxr-xr-x 2 root root 108 7月 21 15:53 bin
-rw-r--r-- 1 root root 157364 11月 24 2017 dependency_licenses.json
drwxr-xr-x 18 root root 218 7月 21 16:20 embedded
drwxr-xr-x 6 root root 166 7月 21 16:21 etc
drwxr-xr-x 2 root root 243 7月 21 16:21 init
-rw-r--r-- 1 root root 1460869 11月 24 2017 LICENSE
drwxr-xr-x 2 root root 4096 7月 21 15:53 LICENSES
drwxr-xr-x 2 root root 243 7月 21 16:21 service
drwxr-xr-x 15 root root 243 7月 21 16:21 sv
drwxr-xr-x 3 root root 21 7月 21 16:21 var
-rw-r--r-- 1 root root 19881 11月 24 2017 version-manifest.json
-rw-r--r-- 1 root root 8696 11月 24 2017 version-manifest.txt
2存放仓库的目录
[root@docker01 ~]# ll /var/opt/gitlab/git-data/
总用量
drwxrws--- 2 git root 6 7月 21 16:20 repositories
3日志目录
[root@docker01 ~]# ll /var/log/gitlab/
总用量
drwx------ 2 git root 47 7月 21 16:21 gitaly
drwx------ 2 git root 47 7月 21 16:21 gitlab-monitor
drwx------ 2 git root 188 7月 21 16:21 gitlab-rails
drwx------ 2 git root 30 7月 21 16:20 gitlab-shell
drwx------ 2 git root 47 7月 21 16:21 gitlab-workhorse
drwx------ 2 root root 47 7月 21 16:21 logrotate
drwxr-x--- 2 root gitlab-www 131 7月 21 16:21 nginx
drwx------ 2 gitlab-prometheus root 47 7月 21 16:21 node-exporter
drwx------ 2 gitlab-psql root 47 7月 21 16:21 postgres-exporter
drwx------ 2 gitlab-psql root 47 7月 21 16:20 postgresql
drwx------ 2 gitlab-prometheus root 47 7月 21 16:21 prometheus
drwxr-xr-x 2 root root 28 7月 21 16:19 reconfigure
drwx------ 2 gitlab-redis root 47 7月 21 16:20 redis
drwx------ 2 gitlab-redis root 47 7月 21 16:21 redis-exporter
drwx------ 2 git root 47 7月 21 16:21 sidekiq
drwx------ 2 git root 99 7月 21 16:21 unicorn
(4)关闭gitlab
[root@docker01 ~]# gitlab-ctl stop
ok: down: gitaly: 0s, normally up
ok: down: gitlab-monitor: 1s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 1s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 1s, normally up
ok: down: unicorn: 0s, normally up
关闭gitlab单个服务
例:gitlab-ctl stopnginx
(5)启动gitlab
[root@docker01 ~]# gitlab-ctl start
ok: run: gitaly: (pid 10155) 0s
ok: run: gitlab-monitor: (pid 10170) 1s
ok: run: gitlab-workhorse: (pid 10175) 0s
ok: run: logrotate: (pid 10182) 0s
ok: run: nginx: (pid 10188) 1s
ok: run: node-exporter: (pid 10193) 0s
ok: run: postgres-exporter: (pid 10232) 1s
ok: run: postgresql: (pid 10236) 0s
ok: run: prometheus: (pid 10244) 1s
ok: run: redis: (pid 10251) 0s
ok: run: redis-exporter: (pid 10255) 0s
ok: run: sidekiq: (pid 10259) 1s
ok: run: unicorn: (pid 10266) 0s