linux git消耗内存,【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'] = true4 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/backups2 mkdir: 已创建目录 "/data"3 mkdir: 已创建目录 "/data/gitlab"4 mkdir: 已创建目录 "/data/gitlab/backups"

3.重载配置

1 [root@localhost /]# gitlab-ctl reconfigure2 Starting Chef Client, version 14.13.113 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::default24 ……25 ……26 ……27 (up to date)28 Recipe:

29 * service[repmgrd] action nothing (skipped due to action :nothing)30 Recipe: repmgr::repmgrd_disable31 * runit_service[repmgrd] action disable32 * ruby_block[disable repmgrd] action run (skipped due to only_if)33 (up to date)34 Recipe: gitlab-ee::geo-secondary_disable35 * templatesymlink[Removes database_geo.yml symlink] action delete36 * 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:

40 * service[unicorn] action restart41 - restart service service[unicorn]42 * service[sidekiq] action restart43 - restart service service[sidekiq]44 Recipe: gitlab::gitlab-rails45 * execute[clear the gitlab-rails cache] action run46 - execute /opt/gitlab/bin/gitlab-rake cache:clear47 Running handlers:48 Running handlers complete49 Chef Client finished, 10/708 resources updated in 29 seconds

4.开始备份

1 [root@localhost /]# gitlab-rake gitlab:backup:create2 2019-09-16 11:00:23 +0800 -- Dumping database ...3 Dumping PostgreSQL database gitlabhq_production ... [DONE]4 2019-09-16 11:00:24 +0800 -- done5 2019-09-16 11:00:24 +0800 -- Dumping repositories ...6 2019-09-16 11:00:24 +0800 -- done7 2019-09-16 11:00:24 +0800 -- Dumping uploads ...8 2019-09-16 11:00:24 +0800 -- done9 2019-09-16 11:00:24 +0800 -- Dumping builds ...10 2019-09-16 11:00:24 +0800 -- done11 2019-09-16 11:00:24 +0800 -- Dumping artifacts ...12 2019-09-16 11:00:24 +0800 -- done13 2019-09-16 11:00:24 +0800 -- Dumping pages ...14 2019-09-16 11:00:24 +0800 -- done15 2019-09-16 11:00:24 +0800 -- Dumping lfs objects ...16 2019-09-16 11:00:24 +0800 -- done17 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 ... done20 Uploading backup archive to remote storage ... skipped21 Deleting tmp directories ... done22 done23 done24 done25 done26 done27 done28 done29 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]# pwd2 /data/gitlab/backups3 [root@localhost backups]# ls -l4 总用量 1325 -rw-r--r-- 1 git git 133120 9月 16 11:00 1568602824_2019_09_16_12.2.5-ee_gitlab_backup.tar6 [root@localhost backups]#

执行完成后在 /data/gitlab/backups 中生成了备份文件。

2.gitlab恢复备份

1.首先停用gitlab的数据连接部分服务

1 [root@localhost backups]# gitlab-ctl stop unicorn2 ok: down: unicorn: 0s, normally up3 [root@localhost backups]# gitlab-ctl stop sidekiq4 ok: down: sidekiq: 0s, normally up5 [root@localhost backups]# gitlab-ctl stop nginx6 ok: down: nginx: 0s, normally up7 [root@localhost backups]# gitlab-ctl status8 run: alertmanager: (pid 30960) 3683s; run: log: (pid 30623) 3735s9 run: gitaly: (pid 30846) 3685s; run: log: (pid 30081) 3828s10 run: gitlab-monitor: (pid 30843) 3685s; run: log: (pid 30498) 3753s11 run: gitlab-workhorse: (pid 30820) 3686s; run: log: (pid 30349) 3784s12 run: grafana: (pid 30980) 3682s; run: log: (pid 30750) 3698s13 run: logrotate: (pid 37253) 178s; run: log: (pid 30384) 3777s14 down: nginx: 4s, normally up; run: log: (pid 30368) 3781s15 run: node-exporter: (pid 30830) 3685s; run: log: (pid 30418) 3764s16 run: postgres-exporter: (pid 30971) 3683s; run: log: (pid 30650) 3730s17 run: postgresql: (pid 30127) 3825s; run: log: (pid 30139) 3821s18 run: prometheus: (pid 30943) 3684s; run: log: (pid 30588) 3741s19 run: redis: (pid 29960) 3838s; run: log: (pid 29972) 3835s20 run: redis-exporter: (pid 30854) 3684s; run: log: (pid 30522) 3747s21 down: sidekiq: 13s, normally up; run: log: (pid 30324) 3788s22 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-ee2 Unpacking backup ... done3 Before restoring the database, we will remove all existing4 tables to avoid future upgrade problems. Be aware that if you have5 custom tables in the GitLab database these tables and all data will be6 removed.7 ……………………………………8 Do you want to continue (yes/no)? yes9 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)? yes12

13 Deleting tmp directories ... done14 done15 done16 done17 done18 done19 done20 done21 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 start2 ok: run: alertmanager: (pid 30960) 3785s3 ok: run: gitaly: (pid 30846) 3787s4 ok: run: gitlab-monitor: (pid 30843) 3787s5 ok: run: gitlab-workhorse: (pid 30820) 3788s6 ok: run: grafana: (pid 30980) 3784s7 ok: run: logrotate: (pid 37253) 280s8 ok: run: nginx: (pid 37535) 0s9 ok: run: node-exporter: (pid 30830) 3787s10 ok: run: postgres-exporter: (pid 30971) 3785s11 ok: run: postgresql: (pid 30127) 3927s12 ok: run: prometheus: (pid 30943) 3786s13 ok: run: redis: (pid 29960) 3940s14 ok: run: redis-exporter: (pid 30854) 3786s15 ok: run: sidekiq: (pid 37547) 1s16 ok: run: unicorn: (pid 37553) 0s17 [root@localhost backups]# gitlab-rake gitlab:check SANITIZE=true18 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/check24 Check GitLab API access: OK25 Redis available via internal API: OK26

27 Access to /var/opt/gitlab/.ssh/authorized_keys: OK28 gitlab-shell self-check successful29

30 Checking GitLab Shell ... Finished31

32 Checking Gitaly ...33

34 Gitaly: ... default ... OK35

36 Checking Gitaly ... Finished37

38 Checking Sidekiq ...39

40 Sidekiq: ... Running? ... yes41 Number of Sidekiq processes ... 142

43 Checking Sidekiq ... Finished44

45 Checking Incoming Email ...46

47 Incoming Email: ... Reply by email is disabled in config/gitlab.yml48

49 Checking Incoming Email ... Finished50

51 Checking LDAP ...52

53 LDAP: ... LDAP is disabled in config/gitlab.yml54

55 Checking LDAP ... Finished56

57 Checking GitLab App ...58

59 Git configured correctly? ... yes60 Database config exists? ... yes61 All migrations up? ... yes62 Database contains orphaned GroupMembers? ... no63 GitLab config exists? ... yes64 GitLab config up to date? ... yes65 Log directory writable? ... yes66 Tmp directory writable? ... yes67 Uploads directory exists? ... yes68 Uploads directory has correct permissions? ... yes69 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 projects73 Redis version >= 2.8.0? ... yes74 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? ... yes77 Active users: ... 178 Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)79

80 Checking GitLab App ... Finished81

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'] = 604 #进程数5 unicorn['worker_processes'] = 106 #进程最小内存7 unicorn['worker_memory_limit_min'] = "200 * 1 << 20"8 #进程最大内存9 unicorn['worker_memory_limit_max']= "300 * 1 << 20"

10 #并发数11 sidekiq['concurrency']= 1612 #数据库缓存13 postgresql['shared_buffers']= "256MB"

14 #数据库并发数15 postgresql['max_worker_processes']= 8

参考CSDN博主"欧阳鹏",原文链接:https://blog.csdn.net/ouyang_peng/article/details/84066417

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值