1、 GitLab 官网地址
官网地址:https://about.gitlab.com/ 
安装说明:https://about.gitlab.com/installation/  
2、 服务器准备
准备一个系统为 CentOS7 以上版本的服务器,要求内存 4G,磁盘 50G。 关闭防火墙,并且配置好主机名和 IP,保证服务器可以上网。
3、 安装包准备
清华同方下载镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=D
 Yum 在线安装 gitlab- ce 时,需要下载几百 M 的安装文件,非常耗时,所以最好提前把 所需 RPM 包下载到本地,然后使用离线 rpm 的方式安装。  
 下载地址: 
https://packages.gitlab.com/gitlab/gitlabce/packages/el/7/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm
4、 执行安装脚本
#1、执行rpm安装脚本sudo rpm -Uvh gitlab-jh-14.7.3-jh.0.el7.x86_64.rpm#2、修改gitlab配置文件vim /etc/gitlab/gitlab.rb# root⽤户初始化密码gitlab_rails['initial_root_password'] = ''# 浏览器访问的ip+端⼝,ip就是安装gitlab机器的ip#注意点 如果是ip地址 要加上访问协议http://external_url 'http://gitlab.example.com'# 设置端⼝ gitlab默认端口80nginx['listen_port'] = nil
5、 初始化 GitLab 服务
#执行以下命令初始化 GitLab 服务,过程大概需要几分钟,耐心等待…#修改完gitlab配置文件也需要执行该命令才能使修改的配置文件生效gitlab-ctl reconfigure#初始化成功输出。 。 。 。 。 。Running handlers:Running handlers completeChef Client finished, 425/608 resources updated in 03 minutes 08secondsgitlab Reconfigured!
6、 启动 GitLab 服务
执行以下命令启动 GitLab 服务,如需停止,执行 gitlab-ctl stop
gitlab-ctl startok: run: alertmanager: (pid 6812) 134sok: run: gitaly: (pid 6740) 135sok: run: gitlab-monitor: (pid 6765) 135sok: run: gitlab-workhorse: (pid 6722) 136sok: run: logrotate: (pid 5994) 197sok: run: nginx: (pid 5930) 203sok: run: node-exporter: (pid 6234) 185sok: run: postgres-exporter: (pid 6834) 133sok: run: postgresql: (pid 5456) 257sok: run: prometheus: (pid 6777) 134sok: run: redis: (pid 5327) 263sok: run: redis-exporter: (pid 6391) 173sok: run: sidekiq: (pid 5797) 215sok: run: unicorn: (pid 5728) 221s
7、 使用浏览器访问 GitLab
gitlab默认使用80端口,如需访问直接访问服务器地址+80端口 80端口是特殊端口可以不带
 首次登陆之前,需要修改下 GitLab 提供的 root 账户的密码,要求 8 位以上,包含大小 写子母和特殊符号。因此我们修改密码为 Atguigu.123456 然后使用修改后的密码登录 GitLab。
8、GitLab常用命令
# 启动所有 gitlab 组件:gitlab-ctl start# 停止所有 gitlab 组件:gitlab-ctl stop# 停止 postgresql 组件:gitlab-ctl stop postgresql# 停止相关数据连接服务gitlab-ctl stop unicorngitlab-ctl stop sidekiq# 重启所有 gitlab 组件:gitlab-ctl restart# 重启 gitlab-workhorse 组件:gitlab-ctl restart gitlab-workhorse# 查看服务状态gitlab-ctl status
如果更改了主配置文件 [:/etc/gitlab/gitlab.rb 文件],需要用这个命令,使配置文件生效 但是会初始化除了gitlab.rb 之外的所有文件
sudo gitlab-ctl reconfigure
执行完上面那个命令 重启所有 gitlab 组件
gitlab-ctl restart
针对某个服务重启 例如重启nginx
gitlab-ctl restart nginx
针对某个服务启动 例如启动nginx
gitlab-ctl start nginx
针对某个服务关闭 例如关闭nginx
gitlab-ctl stop nginx
查看日志 (查看gitlab整个所有的日志)
sudo gitlab-ctl tail
具体的日志文件路径:
[root@ci-node1 src]# ll /var/log/gitlab/total 12drwx------ 2 git root 95 Mar 23 23:27 gitalydrwx------ 2 git root 95 Mar 23 23:27 gitlab-monitordrwx------ 2 git root 4096 Mar 28 00:39 gitlab-railsdrwx------ 2 git root 204 Mar 28 00:39 gitlab-shelldrwx------ 2 git root 95 Mar 23 23:27 gitlab-workhorsedrwx------ 2 root root 95 Mar 23 23:27 logrotatedrwxr-x--- 2 root gitlab-www 4096 Mar 28 00:39 nginxdrwx------ 2 gitlab-prometheus root 95 Mar 23 23:27 node-exporterdrwx------ 2 gitlab-psql root 95 Mar 23 23:27 postgres-exporterdrwx------ 2 gitlab-psql root 95 Mar 23 23:27 postgresqldrwx------ 2 gitlab-prometheus root 235 Mar 27 23:27 prometheusdrwxr-xr-x 2 root root 28 Mar 22 23:25 reconfiguredrwx------ 2 gitlab-redis root 235 Mar 27 23:27 redisdrwx------ 2 gitlab-redis root 95 Mar 23 23:27 redis-exporterdrwx------ 2 git root 235 Mar 27 23:27 sidekiqdrwx------ 2 git root 4096 Mar 28 00:39 unicorn
一般有问题 有报错时候 可以看 所有输出 gitlab-ctl tail
# 检查 redis 的日志
sudo gitlab-ctl tail redis
