Centos GitLab 配置

如果重启之后,gitlab-ctl restart报“runsv no running”错,先运行下面命令

systemctl start gitlab-runsvdir.service

0、配置外部nginx

打开gitlab配置文件

vim /etc/gitlab/gitlab.rb

修改配置项

#禁用自带nginx
nginx['enable'] = false
#指定nginx的用户名,一般linux中默认的nginx用户名都是nobody
web_server['external_users'] = ['nobody']
# 添加nginx地址到信任列表,我这里是127.0.0.1
gitlab_rails['trusted_proxies'] = ['127.0.0.1']
#监听tcp
gitlab_workhorse['listen_network'] = "tcp"
#配置gitlab的地址和端口
gitlab_workhorse['listen_addr'] = "127.0.0.1:28080"

重新配置并且重启gitlab

gitlab-ctl reconfigure
gitlab-ctl restart

1、配置gitlab发送邮件

打开gitlab配置文件

vim /etc/gitlab/gitlab.rb

修改配置项

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "XXX@163.com"
gitlab_rails['smtp_password'] = "XXX"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

#使用163邮箱时需要修改发信人
gitlab_rails['gitlab_email_from'] = 'fiveflashes@163.com'

 重新配置gitlab

gitlab-ctl reconfigure

测试能否发邮件

gitlab-rails console
Notify.test_email('收件人地址','测试标题','测试内容').deliver_now

2、配置GitLab仓库路径

创建自己想要做仓库的文件夹

mkdir -p /usr/local/data/git-data

打开gitlab配置文件

vim /etc/gitlab/gitlab.rb

找到这一段,去掉注释,并且将地址改为之前新建的目录

git_data_dirs({
   "default" => {
     "path" => "/usr/local/data/git-data"
   }
})

重新配置gitlab并且重启gitlab(这一步适合不需要旧仓库的数据,如果需要旧仓库数据的,使用下一步的代码)

gitlab-ctl reconfigure
gitlab-ctl restart

如果在之前的路径上已经有仓库了,可以使用下面的代码移过来

sudo gitlab-ctl stop
sudo rsync -av /var/opt/gitlab/git-data/repositories /usr/local/data/git-data
sudo gitlab-ctl reconfigure
sudo ls /usr/local/data/git-data
sudo gitlab-ctl start

3、配置自己的redis

打开gitlab配置文件,修改配置项

vim /etc/gitlab/gitlab.rb
# 禁止使用内部redis
redis['enable'] = false

# 配置redis的ip和端口
gitlab_rails['redis_host'] = '127.0.0.1'
gitlab_rails['redis_port'] = 6379

# 配置redis的密码,如果需要的话
gitlab_rails['redis_password'] = '<redis_password>'

重新配置并且重启gitlab

gitlab-ctl reconfigure
gitlab-ctl restart

4、配置外部postgresql

官方文档地址:https://docs.gitlab.com/omnibus/settings/database.html#using-a-non-packaged-postgresql-database-management-server

准备工作,创建gitlab的数据库和安装pg的扩展

#更新yum
sudo yum update
#查找yum list 里的 contrib
yum search contrib #安装自己pg版本对应的contrib
yum install postgresql13-contrib.x86_64 #进入系统的psql环境 sudo -u postgres psql #创建gitlab的pg用户 create user gitlab with password '12345678'; #创建数据库gitlabhq_production create database gitlabhq_production OWNER gitlab; #将gitlabhq_production库的所有权赋值给gitlab GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production TO gitlab; #进入到gitlab的数据数 \c gitlabhq_production #为gitlab的数据库安装扩展btree_gist CREATE EXTENSION IF NOT EXISTS btree_gist;
#为gitlab的数据库安装扩展pg_trgm
CREATE EXTENSION IF NOT EXISTS pg_trgm;

打开配置文件,修改配置信息

vim /etc/gitlab/gitlab.rb
postgresql['enable'] = false
gitlab_rails['db_adapter'] = "postgresql"
gitlab_rails['db_encoding'] = "utf8"
# gitlab_rails['db_collation'] = nil
gitlab_rails['db_database'] = "gitlabhq_production"
gitlab_rails['db_username'] = "gitlab"
gitlab_rails['db_password'] = "12345678"
gitlab_rails['db_host'] = "127.0.0.1"
gitlab_rails['db_port'] = 5432
View Code

重新配置gitlab并且重启

gitlab-ctl reconfigure
gitlab-ctl restart

 如果reconfigure时提示schema重复,则去pg中删除对应的schema。

posted @ 2020-12-01 17:45  守望雲影  阅读(154)  评论(0编辑  收藏  举报