【linux】【gitlab】gitlab安装、备份、恢复、升级、内存消耗问题
GitLab:GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
功能:Gitlab 是一个提供代码托管、提交审核和问题跟踪的代码管理平台。对于软件工程质量管理非常重要。
版本:GitLab 分为社区版(CE) 和企业版(EE)。
配置:建议CPU2核,内存2G以上。
一、gitlab安装
1、安装gitlab yum库
1.安装最新版gitlab-ee(企业版)
- curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
2.安装最新版gilab-ce(社区版)
- curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
2、安装gitlab
其中ip为gitlab的访问地址。
1.企业最新版:
- EXTERNAL_URL="http://ip" yum install -y gitlab-ee
2.社区最新版:
- EXTERNAL_URL="http://ip" yum install -y gitlab-ce
3.安装指定版本:
- EXTERNAL_URL="http://ip" yum install -y gitlab-ce-12.1.9-ee.0.el7.x86_64
- EXTERNAL_URL="http://ip" yum install -y gitlab-ce-12.1.9-ce.0.el7.x86_64
4.安装完成基本指令:
查看运行状态
- gitlab-ctl status
启动
- gitlab-ctl start
停止
- gitlab-ctl stop
重启
- gitlab-ctl restart
查看版本
- cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
重载配置
- gitlab-ctl reconfigure
3、访问gitlab
http://ip 浏览器打开
设置root管理员初始密码。
设置邮箱及https等请参考原文。
本文参考CSDN“一缕南风”博主,原文链接:https://blog.csdn.net/weixin_43767602/article/details/84568858
二、gitlab备份、恢复
1.gitlab备份
1.设置gitlab备份目录、权限、有限期
1 [root@localhost /]# cat /etc/gitlab/gitlab.rb | grep -v "#" 2 external_url 'http://192.168.8.127' //安装设定的访问域名 3 gitlab_rails['manage_backup_path'] = true 4 gitlab_rails['backup_path'] = "/data/gitlab/backups" //备份路径 5 gitlab_rails['backup_archive_permissions'] = 0644 //备份文件权限 6 gitlab_rails['backup_keep_time'] = 7776000 //备份文件有效期 30天
2.创建备份路径
1 [root@localhost /]# mkdir -vp /data/gitlab/backups 2 mkdir: 已创建目录 "/data" 3 mkdir: 已创建目录 "/data/gitlab" 4 mkdir: 已创建目录 "/data/gitlab/backups"
3.重载配置
1 [root@localhost /]# gitlab-ctl reconfigure 2 Starting Chef Client, version 14.13.11 3 resolving cookbooks for run list: ["gitlab-ee"] 4 Synchronizing Cookbooks: 5 - gitlab-ee (0.0.1) 6 - package (0.1.0) 7 - gitlab (0.0.1) 8 - consul (0.1.0) 9 - runit (4.3.0) 10 - redis (0.1.0) 11 - repmgr (0.1.0) 12 - postgresql (0.1.0) 13 - gitaly (0.1.0) 14 - letsencrypt (0.1.0) 15 - monitoring (0.1.0) 16 - registry (0.1.0) 17 - mattermost (0.1.0) 18 - nginx (0.1.0) 19 - acme (4.0.0) 20 - crond (0.1.0) 21 Installing Cookbook Gems: 22 Compiling Cookbooks... 23 Recipe: gitlab::default 24 …… 25 …… 26 …… 27 (up to date) 28 Recipe: <Dynamically Defined Resource> 29 * service[repmgrd] action nothing (skipped due to action :nothing) 30 Recipe: repmgr::repmgrd_disable 31 * runit_service[repmgrd] action disable 32 * ruby_block[disable repmgrd] action run (skipped due to only_if) 33 (up to date) 34 Recipe: gitlab-ee::geo-secondary_disable 35 * templatesymlink[Removes database_geo.yml symlink] action delete 36 * file[/var/opt/gitlab/gitlab-rails/etc/database_geo.yml] action delete (up to date) 37 * link[/opt/gitlab/embedded/service/gitlab-rails/config/database_geo.yml] action delete (up to date) 38 (up to date) 39 Recipe: <Dynamically Defined Resource> 40 * service[unicorn] action restart 41 - restart service service[unicorn] 42 * service[sidekiq] action restart 43 - restart service service[sidekiq] 44 Recipe: gitlab::gitlab-rails 45 * execute[clear the gitlab-rails cache] action run 46 - execute /opt/gitlab/bin/gitlab-rake cache:clear 47 Running handlers: 48 Running handlers complete 49 Chef Client finished, 10/708 resources updated in 29 seconds
4.开始备份
1 [root@localhost /]# gitlab-rake gitlab:backup:create 2 2019-09-16 11:00:23 +0800 -- Dumping database ... 3 Dumping PostgreSQL database gitlabhq_production ... [DONE] 4 2019-09-16 11:00:24 +0800 -- done 5 2019-09-16 11:00:24 +0800 -- Dumping repositories ... 6 2019-09-16 11:00:24 +0800 -- done 7 2019-09-16 11:00:24 +0800 -- Dumping uploads ... 8 2019-09-16 11:00:24 +0800 -- done 9 2019-09-16 11:00:24 +0800 -- Dumping builds ... 10 2019-09-16 11:00:24 +0800 -- done 11 2019-09-16 11:00:24 +0800 -- Dumping artifacts ... 12 2019-09-16 11:00:24 +0800 -- done 13 2019-09-16 11:00:24 +0800 -- Dumping pages ... 14 2019-09-16 11:00:24 +0800 -- done 15 2019-09-16 11:00:24 +0800 -- Dumping lfs objects ... 16 2019-09-16 11:00:24 +0800 -- done 17 2019-09-16 11:00:24 +0800 -- Dumping container registry images ... 18 2019-09-16 11:00:24 +0800 -- [DISABLED] 19 Creating backup archive: 1568602824_2019_09_16_12.2.5-ee_gitlab_backup.tar ... done 20 Uploading backup archive to remote storage ... skipped 21 Deleting tmp directories ... done 22 done 23 done 24 done 25 done 26 done 27 done 28 done 29 Deleting old backups ... done. (0 removed) 30 Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 31 and are not included in this backup. You will need these files to restore a backup. 32 Please back them up manually. 33 Backup task is done.
红字部分表示 gitlab.rb 和 gitlab-secrets.json 两个文件包含敏感信息。未被备份到备份文件中。需要手动备份。
1 [root@localhost backups]# pwd 2 /data/gitlab/backups 3 [root@localhost backups]# ls -l 4 总用量 132 5 -rw-r--r-- 1 git git 133120 9月 16 11:00 1568602824_2019_09_16_12.2.5-ee_gitlab_backup.tar 6 [root@localhost backups]#
执行完成后在 /data/gitlab/backups 中生成了备份文件。
2.gitlab恢复备份
1.首先停用gitlab的数据连接部分服务
1 [root@localhost backups]# gitlab-ctl stop unicorn 2 ok: down: unicorn: 0s, normally up 3 [root@localhost backups]# gitlab-ctl stop sidekiq 4 ok: down: sidekiq: 0s, normally up 5 [root@localhost backups]# gitlab-ctl stop nginx 6 ok: down: nginx: 0s, normally up 7 [root@localhost backups]# gitlab-ctl status 8 run: alertmanager: (pid 30960) 3683s; run: log: (pid 30623) 3735s 9 run: gitaly: (pid 30846) 3685s; run: log: (pid 30081) 3828s 10 run: gitlab-monitor: (pid 30843) 3685s; run: log: (pid 30498) 3753s 11 run: gitlab-workhorse: (pid 30820) 3686s; run: log: (pid 30349) 3784s 12 run: grafana: (pid 30980) 3682s; run: log: (pid 30750) 3698s 13 run: logrotate: (pid 37253) 178s; run: log: (pid 30384) 3777s 14 down: nginx: 4s, normally up; run: log: (pid 30368) 3781s 15 run: node-exporter: (pid 30830) 3685s; run: log: (pid 30418) 3764s 16 run: postgres-exporter: (pid 30971) 3683s; run: log: (pid 30650) 3730s 17 run: postgresql: (pid 30127) 3825s; run: log: (pid 30139) 3821s 18 run: prometheus: (pid 30943) 3684s; run: log: (pid 30588) 3741s 19 run: redis: (pid 29960) 3838s; run: log: (pid 29972) 3835s 20 run: redis-exporter: (pid 30854) 3684s; run: log: (pid 30522) 3747s 21 down: sidekiq: 13s, normally up; run: log: (pid 30324) 3788s 22 down: unicorn: 17s, normally up; run: log: (pid 30307) 3792s
2.执行恢复
1 [root@localhost backups]# gitlab-rake gitlab:backup:restore BACKUP=1568602824_2019_09_16_12.2.5-ee 2 Unpacking backup ... done 3 Before restoring the database, we will remove all existing 4 tables to avoid future upgrade problems. Be aware that if you have 5 custom tables in the GitLab database these tables and all data will be 6 removed. 7 …………………………………… 8 Do you want to continue (yes/no)? yes 9 This task will now rebuild the authorized_keys file. 10 You will lose any data stored in the authorized_keys file. 11 Do you want to continue (yes/no)? yes 12 13 Deleting tmp directories ... done 14 done 15 done 16 done 17 done 18 done 19 done 20 done 21 Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 22 and are not included in this backup. You will need to restore these files manually. 23 Restore task is done.
备份tar包一定要放到备份路径下。恢复是删除原有数据,恢复备份tar包中的数据。
如果是在其他服务器恢复备份,一定要记得将 gitlab.rb 和 gitlab-secrets.json 手动复制到相应路径下。
gitlab.rb路径:/etc/gitlab/gitlab.rb
gitlab-secrets.json路径:/etc/gitlab/gitlab-secrets.json
3.重启gitlab,check检查
1 [root@localhost backups]# gitlab-ctl start 2 ok: run: alertmanager: (pid 30960) 3785s 3 ok: run: gitaly: (pid 30846) 3787s 4 ok: run: gitlab-monitor: (pid 30843) 3787s 5 ok: run: gitlab-workhorse: (pid 30820) 3788s 6 ok: run: grafana: (pid 30980) 3784s 7 ok: run: logrotate: (pid 37253) 280s 8 ok: run: nginx: (pid 37535) 0s 9 ok: run: node-exporter: (pid 30830) 3787s 10 ok: run: postgres-exporter: (pid 30971) 3785s 11 ok: run: postgresql: (pid 30127) 3927s 12 ok: run: prometheus: (pid 30943) 3786s 13 ok: run: redis: (pid 29960) 3940s 14 ok: run: redis-exporter: (pid 30854) 3786s 15 ok: run: sidekiq: (pid 37547) 1s 16 ok: run: unicorn: (pid 37553) 0s 17 [root@localhost backups]# gitlab-rake gitlab:check SANITIZE=true 18 Checking GitLab subtasks ... 19 20 Checking GitLab Shell ... 21 22 GitLab Shell: ... GitLab Shell version >= 9.3.0 ? ... OK (9.3.0) 23 Running /opt/gitlab/embedded/service/gitlab-shell/bin/check 24 Check GitLab API access: OK 25 Redis available via internal API: OK 26 27 Access to /var/opt/gitlab/.ssh/authorized_keys: OK 28 gitlab-shell self-check successful 29 30 Checking GitLab Shell ... Finished 31 32 Checking Gitaly ... 33 34 Gitaly: ... default ... OK 35 36 Checking Gitaly ... Finished 37 38 Checking Sidekiq ... 39 40 Sidekiq: ... Running? ... yes 41 Number of Sidekiq processes ... 1 42 43 Checking Sidekiq ... Finished 44 45 Checking Incoming Email ... 46 47 Incoming Email: ... Reply by email is disabled in config/gitlab.yml 48 49 Checking Incoming Email ... Finished 50 51 Checking LDAP ... 52 53 LDAP: ... LDAP is disabled in config/gitlab.yml 54 55 Checking LDAP ... Finished 56 57 Checking GitLab App ... 58 59 Git configured correctly? ... yes 60 Database config exists? ... yes 61 All migrations up? ... yes 62 Database contains orphaned GroupMembers? ... no 63 GitLab config exists? ... yes 64 GitLab config up to date? ... yes 65 Log directory writable? ... yes 66 Tmp directory writable? ... yes 67 Uploads directory exists? ... yes 68 Uploads directory has correct permissions? ... yes 69 Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) 70 Init script exists? ... skipped (omnibus-gitlab has no init script) 71 Init script up-to-date? ... skipped (omnibus-gitlab has no init script) 72 Projects have namespace: ... can't check, you have no projects 73 Redis version >= 2.8.0? ... yes 74 Ruby version >= 2.5.3 ? ... yes (2.6.3) 75 Git version >= 2.22.0 ? ... yes (2.22.0) 76 Git user has default SSH configuration? ... yes 77 Active users: ... 1 78 Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled) 79 80 Checking GitLab App ... Finished 81 82 83 Checking GitLab subtasks ... Finished
ok,至此恢复完成
三、gitlab版本升级
1.
四、gitlab解决内存消耗问题
1 [root@storage100 backups]# cat /etc/gitlab/gitlab.rb | grep -v "#" 2 #进程超时时间 3 unicorn['worker_timeout'] = 60 4 #进程数 5 unicorn['worker_processes'] = 10 6 #进程最小内存 7 unicorn['worker_memory_limit_min'] = "200 * 1 << 20" 8 #进程最大内存 9 unicorn['worker_memory_limit_max'] = "300 * 1 << 20" 10 #并发数 11 sidekiq['concurrency'] = 16 12 #数据库缓存 13 postgresql['shared_buffers'] = "256MB" 14 #数据库并发数 15 postgresql['max_worker_processes'] = 8
参考CSDN博主"欧阳鹏",原文链接:https://blog.csdn.net/ouyang_peng/article/details/84066417
原文地址:https://www.cnblogs.com/jxd283465/p/11525629.html
- 生信宝典之傻瓜式 (一) 如何提取指定位置的基因组序列
- 注意map<> 的[]
- 生信宝典之傻瓜式 (二) 如何快速查找指定基因的调控网络
- React Native组件只Image
- 数据结构之线性表
- 生信宝典之傻瓜式 (三) 我的基因在哪里发光 - 如何查找基因在发表研究中的表达
- 谈谈 char *num="123";和char num[4]="123";的区别
- 未越狱的iPhone/iPad也中招:走近强大的间谍软件XAgent与MadCap
- 【年末收藏】17个新手常见Python运行时错误
- C++ STL之priority_queue
- 链表的相关操作
- 《笨办法学Python》 第0课手记
- Python黑客学习笔记:从HelloWorld到编写PoC(上)
- java多线程(内附实例:窗口售票问题、人和叉子的问题)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法