gitlab安装
1.关闭防火墙和selinux
2.安装gitlab依赖软件
yum install curl openssh-server openssh-clients postfix policycoreutils-python –y
3.手动下载gitlab-ce安装包
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
4.本地安装软件包
yum localinstall gitlab-ce-12.8.1-ce.0.el7.x86_64.rpm -y
5.安装完成后会出现下方图示内容,需要编辑/etc/gitlab/gitlab.rb文件,修改external_url
[root@localhost ~]# vim /etc/gitlab/gitlab.rb external_url 'http://192.168.2.3'
6.配置邮箱服务
[root@localhost ~]# vim /etc/gitlab/gitlab.rb gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'xxxxxx@qq.com' #发件邮箱 gitlab_rails['gitlab_email_display_name'] = 'gitlab' #发件人显示名称 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "xxxxx@qq.com" gitlab_rails['smtp_password'] = "xxxxsybdfdf" #邮箱内设置 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true
7.每次编辑gitlab.rb都需要重读配置
[root@localhost ~]# gitlab-ctl reconfigure
8.其他
[root@localhost ~]# gitlab-ctl reconfigure #重读配置 [root@localhost ~]# gitlab-ctl start #启动 [root@localhost ~]# gitlab-ctl restart #重启 [root@localhost ~]# gitlab-ctl status #查看服务状态 [root@localhost ~]# gitlab-ctl stop #停止 [root@localhost ~]# gitlab-ctl stop nginx #单独停止nginx [root@localhost ~]# gitlab-ctl tail #查看日志 /opt/gitlab/ #gitlab程序安装目录 /var/opt/gitlab/ #gitlab数据目录 /var/opt/gitlab/git-data/ #仓库目录
gitlab邮件测试
邮件发不出去可能是配置有问题,控制台测试一下能不能发送邮件
[root@localhost ~]# gitlab-rails console irb(main):003:0> Notify.test_email('邮箱地址','邮件标题','邮件内容').deliver_now
gitlab汉化
万恶的移动网络连gitlab的网站都打不开,开始认为需要kx上网才能打开gitlab,后来搭完还是不管用,最后用联通4G开热点才特么的打开gitlab!!!浪费了我两个小时!!!
1.首先去gitlab官网下载汉化包 https://gitlab.com/xhang/gitlab/ 我这里下载是gitlab-12-1-stable-zh.tar.gz
2.解压汉化包
[root@localhost ~]# tar -xf gitlab-12-1-stable-zh.tar.gz
3.停止gitlab
[root@localhost ~]# gitlab-ctl stop
4.覆盖汉化包,会出错不用管
[root@localhost ~]# cp -r gitlab-12-1-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/ cp: 无法以目录"gitlab-12-1-stable-zh/log" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/log" cp: 无法以目录"gitlab-12-1-stable-zh/tmp" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/tmp"
5.重新启动gitlab
[root@localhost ~]# gitlab-ctl start ok: run: alertmanager: (pid 13818) 0s ok: run: gitaly: (pid 13828) 1s timeout: down: gitlab-exporter: 0s, normally up, want up ok: run: gitlab-monitor: (pid 13965) 0s ok: run: gitlab-workhorse: (pid 13971) 0s ok: run: grafana: (pid 13980) 1s ok: run: logrotate: (pid 13990) 0s ok: run: nginx: (pid 13997) 1s ok: run: node-exporter: (pid 14003) 0s ok: run: postgres-exporter: (pid 14009) 1s ok: run: postgresql: (pid 14015) 0s ok: run: prometheus: (pid 14024) 0s ok: run: redis: (pid 14036) 1s ok: run: redis-exporter: (pid 14040) 0s ok: run: sidekiq: (pid 14047) 1s ok: run: unicorn: (pid 14053) 0s
6.进入web界面设置语言
项目-用户组-用户之间的关系
1.先创建群组
2.在创建项目,把项目归并到这个群组里面
3.在创建用户,把用户加入到这个群组里面,这时候创建用户就会给用户发邮件
禁用注册功能
添加SSH公钥认证
gitlab备份
1.可以手动更改备份文件目录
[root@localhost ~]# vim /etc/gitlab/gitlab.rb gitlab_rails['manage_backup_path'] = true #开启备份 gitlab_rails['backup_path'] = "/data/gitlab/backups" #备份文件目录 gitlab_rails['backup_keep_time'] = 604800 #备份文件保留时间(7天) [root@localhost ~]# gitlab-ctl reconfigure
2.手动备份数据文件,会在配置文件指定的地方生成备份文件
[root@localhost ~]# gitlab-rake gitlab:backup:create [root@localhost ~]# ll /data/gitlab/backups/ 总用量 160 -rw------- 1 git git 163840 2月 27 22:16 1582813002_2020_02_27_12.1.14_gitlab_backup.tar
3.手动备份配置文件
[root@localhost ~]# ll /etc/gitlab/gitlab* -rw------- 1 root root 100725 2月 27 22:13 /etc/gitlab/gitlab.rb -rw------- 1 root root 15553 2月 27 22:15 /etc/gitlab/gitlab-secrets.json [root@localhost ~]# ll /var/opt/gitlab/nginx/conf/ 总用量 16 -rw-r--r-- 1 root root 902 2月 26 23:02 gitlab-health.conf -rw-r--r-- 1 root root 4011 2月 27 17:24 gitlab-http.conf -rw-r--r-- 1 root root 2978 2月 26 23:02 nginx.conf -rw-r--r-- 1 root root 603 2月 26 23:02 nginx-status.conf
4.可以结合crontab每天自动备份
00 02 * * * /usr/bin/gitlab-rake gitlab:backup:create > /dev/null
gitlab恢复(如果是迁移,要注意gitlab版本号一致)
1.先停掉gitlab的写服务
[root@localhost ~]# gitlab-ctl stop unicorn [root@localhost ~]# gitlab-ctl stop sidekiq
2.恢复数据文件,不需要指定文件路径,只需要指定文件的数字部分就行
[root@localhost ~]# gitlab-rake gitlab:backup:restore BACKUP=1582813002_2020_02_27_12.1.14
3.恢复配置文件
4.启动gitlab
[root@localhost ~]# gitlab-ctl start