参考

CentOS上完全卸载gitlab_51CTO博客_centos 卸载

使用 Linux 软件包安装极狐GitLab | 极狐GitLab

本文主要记录2023/11/8在Centos7上卸载Gitlab私有仓库的操作过程,以及过程中问题的处理。

1.停止gitlab

[root@gitlab ~]# gitlab-ctl stop
ok: down: alertmanager: 1s, normally up
ok: down: gitaly: 0s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-kas: 0s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: puma: 0s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 0s, normally up

2.在删除软件包(使用 apt 或 yum)之前,删除由 Linux 软件包创建的所有用户和群组

[root@gitlab ~]# sudo gitlab-ctl stop && sudo gitlab-ctl remove-accounts
ok: down: alertmanager: 387s, normally up
ok: down: gitaly: 386s, normally up
ok: down: gitlab-exporter: 386s, normally up
ok: down: gitlab-kas: 375s, normally up
ok: down: gitlab-workhorse: 375s, normally up
ok: down: logrotate: 375s, normally up
ok: down: nginx: 374s, normally up
ok: down: node-exporter: 374s, normally up
ok: down: postgres-exporter: 373s, normally up
ok: down: postgresql: 373s, normally up
ok: down: prometheus: 372s, normally up
ok: down: puma: 371s, normally up
ok: down: redis: 371s, normally up
ok: down: redis-exporter: 371s, normally up
ok: down: sidekiq: 360s, normally up
[2023-11-08T15:40:48+08:00] INFO: Started Cinc Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook)
Cinc Client, version 17.10.0
Patents: https://www.chef.io/patents
Infra Phase starting
[2023-11-08T15:40:48+08:00] INFO: *** Cinc Client 17.10.0 ***
[2023-11-08T15:40:48+08:00] INFO: Platform: x86_64-linux
[2023-11-08T15:40:48+08:00] INFO: Cinc-client pid: 27359
[2023-11-08T15:41:02+08:00] WARN: Run List override has been provided.
[2023-11-08T15:41:02+08:00] WARN: Original Run List: [recipe[gitlab]]
[2023-11-08T15:41:02+08:00] WARN: Overridden Run List: [recipe[gitlab::remove_accounts]]
[2023-11-08T15:41:02+08:00] INFO: Run List is [recipe[gitlab::remove_accounts]]
[2023-11-08T15:41:02+08:00] INFO: Run List expands to [gitlab::remove_accounts]
[2023-11-08T15:41:02+08:00] INFO: Starting Cinc Client Run for gitlab
[2023-11-08T15:41:02+08:00] INFO: Running start handlers
[2023-11-08T15:41:02+08:00] INFO: Start handlers complete.
Resolving cookbooks for run list: ["gitlab::remove_accounts"]
[2023-11-08T15:41:03+08:00] INFO: Loading cookbooks [gitlab@0.0.1, package@0.1.0, logrotate@0.1.0, postgresql@0.1.0, redis@0.1.0, monitoring@0.1.0, registry@0.1.0, mattermost@0.1.0, consul@0.1.0, gitaly@0.1.0, praefect@0.1.0, gitlab-kas@0.1.0, gitlab-pages@0.1.0, letsencrypt@0.1.0, nginx@0.1.0, runit@5.1.7, acme@4.1.6, crond@0.1.0]
[2023-11-08T15:41:03+08:00] INFO: Skipping removal of obsoleted cookbooks from the cache
Synchronizing cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - logrotate (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - registry (0.1.0)
  - monitoring (0.1.0)
  - mattermost (0.1.0)
  - consul (0.1.0)
  - gitaly (0.1.0)
  - praefect (0.1.0)
  - gitlab-kas (0.1.0)
  - gitlab-pages (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - runit (5.1.7)
  - acme (4.1.6)
  - crond (0.1.0)
Installing cookbook gem dependencies:
Compiling cookbooks...
Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
Loading Cinc Auditor profile files:
Loading Cinc Auditor input files:
Loading Cinc Auditor waiver files:
[2023-11-08T15:41:04+08:00] INFO: Generating default secrets
[2023-11-08T15:41:05+08:00] INFO: Generating gitlab-secrets.json file
Converging 16 resources
Recipe: gitlab::remove_accounts
  * account[git] action remove
    * linux_user[git] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[git] removed

      - remove user git

  * account[gitlab-www] action remove
    * linux_user[gitlab-www] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[gitlab-www] removed

      - remove user gitlab-www

  * account[gitlab-redis] action remove
    * linux_user[gitlab-redis] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[gitlab-redis] removed

      - remove user gitlab-redis

  * account[gitlab-psql] action remove
    * linux_user[gitlab-psql] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[gitlab-psql] removed

      - remove user gitlab-psql

  * account[mattermost] action remove
    * linux_user[mattermost] action remove (up to date)
     (up to date)
  * account[registry] action remove
    * linux_user[registry] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[registry] removed

      - remove user registry

  * account[gitlab-prometheus] action remove
    * linux_user[gitlab-prometheus] action remove[2023-11-08T15:41:05+08:00] INFO: linux_user[gitlab-prometheus] removed

      - remove user gitlab-prometheus

  * account[gitlab-consul] action remove
    * linux_user[gitlab-consul] action remove (up to date)
     (up to date)
  * account[git] action remove
    * group[git] action remove (up to date)
     (up to date)
  * account[gitlab-www] action remove
    * group[gitlab-www] action remove (up to date)
     (up to date)
  * account[gitlab-redis] action remove
    * group[gitlab-redis] action remove (up to date)
     (up to date)
  * account[gitlab-psql] action remove
    * group[gitlab-psql] action remove (up to date)
     (up to date)
  * account[mattermost] action remove
    * group[mattermost] action remove (up to date)
     (up to date)
  * account[registry] action remove
    * group[registry] action remove (up to date)
     (up to date)
  * account[gitlab-consul] action remove
    * group[gitlab-consul] action remove (up to date)
     (up to date)
  * account[gitlab-prometheus] action remove
    * group[gitlab-prometheus] action remove (up to date)
     (up to date)
[2023-11-08T15:41:05+08:00] WARN: Skipping final node save because override_runlist was given
[2023-11-08T15:41:05+08:00] INFO: Cinc Client Run complete in 3.522262855 seconds
[2023-11-08T15:41:05+08:00] INFO: Skipping removal of unused files from the cache

Running handlers:
[2023-11-08T15:41:05+08:00] INFO: Running report handlers
Running handlers complete
[2023-11-08T15:41:05+08:00] INFO: Report handlers complete
Infra Phase complete, 12/32 resources updated in 17 seconds

3.删除所有数据

[root@gitlab ~]# sudo gitlab-ctl cleanse && sudo rm -r /opt/gitlab
    *******************************************************************
    * * * * * * * * * * *       STOP AND READ       * * * * * * * * * *
    *******************************************************************
    This command will delete *all* local configuration, log, and
    variable data associated with gitlab.

    You have 60 seconds to hit CTRL-C before configuration,
    logs, and local data for this application are permanently
    deleted.
    *******************************************************************

ok: down: alertmanager: 551s, normally up
ok: down: gitaly: 550s, normally up
ok: down: gitlab-exporter: 550s, normally up
ok: down: gitlab-kas: 539s, normally up
ok: down: gitlab-workhorse: 539s, normally up
ok: down: logrotate: 539s, normally up
ok: down: nginx: 538s, normally up
ok: down: node-exporter: 538s, normally up
ok: down: postgres-exporter: 537s, normally up
ok: down: postgresql: 537s, normally up
ok: down: prometheus: 536s, normally up
ok: down: puma: 535s, normally up
ok: down: redis: 535s, normally up
ok: down: redis-exporter: 535s, normally up
ok: down: sidekiq: 524s, normally up
alertmanager disabled, not stopping
gitaly disabled, not stopping
gitlab-exporter disabled, not stopping
gitlab-kas disabled, not stopping
gitlab-workhorse disabled, not stopping
logrotate disabled, not stopping
nginx disabled, not stopping
node-exporter disabled, not stopping
postgres-exporter disabled, not stopping
postgresql disabled, not stopping
prometheus disabled, not stopping
puma disabled, not stopping
redis disabled, not stopping
redis-exporter disabled, not stopping
sidekiq disabled, not stopping
Terminating processes running under application users. This will take a few seconds.
Your config files have been backed up to /root/gitlab-cleanse-2023-11-08T15:43.

4.上一步好像没有成功,卸载gitlab

rpm -r gitlab-ce
...

警告:文件 /opt/gitlab/LICENSE: 移除失败: 没有那个文件或目录
警告:文件 /opt/gitlab: 移除失败: 没有那个文件或目录

5.查看gitlab进程,杀掉第一个进程,杀掉后,再确认一遍

[root@gitlab ~]# ps aux | grep gitlab
root     28662  0.0  0.0   4384   480 ?        Ss   15:43   0:00 runsvdir -P /opt/gitlab/service log: does not exist runsvdir /opt/gitlab/service: warning: unable to stat /opt/gitlab/service: file does not exist runsvdir /opt/gitlab/service: warning: unable to stat /opt/gitlab/service: file does not exist runsvdir /opt/gitlab/service: warning: unable to stat /opt/gitlab/service: file does not exist runsvdir /opt/gitlab/service: warning: unable to stat /opt/gitlab/service: file does not exist
root     31259  0.0  0.0 112824   980 pts/0    S+   15:49   0:00 grep --color=auto gitlab
[root@gitlab ~]# kill -9 28662
[root@gitlab ~]# ps aux | grep gitlab
root     31414  0.0  0.0 112824   980 pts/0    S+   15:50   0:00 grep --color=auto gitlab

6.还有gitlab的进程,使用如下命令杀死所有进程

[root@gitlab ~]# ps -ef | grep gitlab | xargs kill -s 9
kill: 找不到进程“root”
kill: 向 32607 发送信号失败: 没有那个进程

──────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <Return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

7.重连终端,删除所有包含gitlab文件

[root@gitlab ~]# find / -name gitlab
/run/gitlab
[root@gitlab ~]# find / -name gitlab | xargs rm -rf
[root@gitlab ~]#

8.再次删除软件包,删除所有数据

[root@gitlab ~]# sudo gitlab-ctl stop && sudo gitlab-ctl remove-accounts
sudo: gitlab-ctl:找不到命令
[root@gitlab ~]# sudo gitlab-ctl cleanse && sudo rm -r /opt/gitlab
sudo: gitlab-ctl:找不到命令

总结:

有效卸载步骤

# 停止gitlab
gitlab-ctl stop  
# 卸载gitlab
rpm -e gitlab-ce  
# 查看gitlab进程
ps aux | grep gitlab  
# 杀掉第一个进程
kill -9 28662  #(28662 是第一个进程的pid号,根据显示情况输入)  
# 杀掉后ps aux | grep gitlab确认一遍,还有没有gitlab的进程,如果还有进程请用以下命令杀死所有进程
ps -ef | grep gitlab | xargs kill -s 9
# 删除所有包含gitlab文件
find / -name gitlab | xargs rm -rf  

更多推荐