gitlab安装

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。本文为大家带来gitlab的安装详解。

一、环境介绍

系统:CentOS Linux release 7.6.1810 (Core) 

IP:192.168.0.8

配置:2C4G


二、安装环境包

yum -y install policycoreutils openssh-server openssh-clients postfix


三、下载rpm包

本文使用的是清华大学开源镜像站的rpm包。

清华大学开源镜像站网址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

[root@localhost opt]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.7.5-ce.0.el7.x86_64.rpm     #下载rpm包

[root@localhost opt]# rpm -ivh gitlab-ce-11.7.5-ce.0.el7.x86_64.rpm    #安装,安装结束后有如下信息打印

17]@V5DI0QTD78(GWKH`U}L.png


四、修改配置文件

[root@localhost opt]# vim /etc/gitlab/gitlab.rb

external_url 'http://192.168.0.8:81'     #修改你访问的url


五、初始化并启动

[root@localhost opt]# gitlab-ctl reconfigure

[root@localhost opt]# gitlab-ctl restart


六、网页访问

初始账户: root 密码: 5iveL!fe

第一次登陆会让你修改密码,要满足密码复杂度条件

登陆界面如下,我已经创建过项目,所以可能略有不同

WD%1820B}1KYI7}4DN1_4YU.png


七、gitlab默认安装的目录及命令

/opt/gitlab/   ## 主目录 
/etc/gitlab/   ## 放置配置文件 
/var/opt/gitlab/   ## 各个组件 
/var/log/gitlab/   ## 放置日志文件



检查gitlab各组件状态: 

[root@localhost ~]# gitlab-ctl status

run: alertmanager: (pid 68651) 395467s; run: log: (pid 107041) 518256s

run: gitaly: (pid 68667) 395467s; run: log: (pid 106843) 518261s

run: gitlab-monitor: (pid 68693) 395466s; run: log: (pid 106957) 518259s

run: gitlab-workhorse: (pid 68697) 395466s; run: log: (pid 106788) 518263s

run: logrotate: (pid 110976) 238484s; run: log: (pid 106803) 518262s

run: nginx: (pid 68860) 395465s; run: log: (pid 106796) 518263s

run: node-exporter: (pid 69005) 395465s; run: log: (pid 106937) 518260s

run: postgres-exporter: (pid 69157) 395464s; run: log: (pid 107091) 518255s

run: postgresql: (pid 69229) 395464s; run: log: (pid 106752) 518265s

run: prometheus: (pid 69311) 395464s; run: log: (pid 107011) 518257s

run: redis: (pid 69324) 395463s; run: log: (pid 106741) 518265s

run: redis-exporter: (pid 69429) 395463s; run: log: (pid 106976) 518258s

run: sidekiq: (pid 69437) 395460s; run: log: (pid 106767) 518264s

run: unicorn: (pid 69461) 395459s; run: log: (pid 106760) 518264s


重启gitlab: 

[root@localhost ~]# gitlab-ctl restart


只重启某个组件: 

[root@localhost ~]# gitlab-ctl restart nginx


gitlab组件: 

nginx: 

postgresql: 

redis: 

unicorn: 

sidekiq: 

logrotate:


修改gitlab代码数据默认存储位置

[root@localhost opt]# vim /etc/gitlab/gitlab.rb

git_data_dirs({

   "default" => {

     "path" => "/data/git_data"

    }

 })


执行以下命令

gitlab-ctl stop

gitlab-ctl reconfigure

gitlab-ctl start

[root@localhost opt]# ls /data/git_data/   #查看这个目录下,会有一个repositories目录

重新加载配置文件时遇到报错

connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?       [execute] psql: could not connect to server: 没有那个文件或目录

解决方法:

systemctl restart gitlab-runsvdir

gitlab-ctl reconfigure