systemctl status redis -l
redis.service - redis-server
Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)
Active: failed (Result: timeout) since 日 2023-04-09 16:13:33 CST; 4min 24s ago
Process: 14691 ExecStart=/usr/local/redis-6.2.6/src/redis-server /usr/local/redis-6.2.6/redis.conf (code=exited, status=0/SUCCESS)
4月 09 16:13:33 localhost.root systemd[1]: redis.service start operation timed out. Terminating.
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:signal-handler (1681028013) Received SIGTERM scheduling shutdown...
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:M 09 Apr 2023 16:13:33.383 # User requested shutdown...
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:M 09 Apr 2023 16:13:33.383 * Saving the final RDB snapshot before exiting.
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:M 09 Apr 2023 16:13:33.398 * DB saved on disk
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:M 09 Apr 2023 16:13:33.398 * Removing the pid file.
4月 09 16:13:33 localhost.root redis-server[14691]: 14691:M 09 Apr 2023 16:13:33.398 # Redis is now ready to exit, bye bye...
4月 09 16:13:33 localhost.root systemd[1]: Failed to start redis-server.
4月 09 16:13:33 localhost.root systemd[1]: Unit redis.service entered failed state.
4月 09 16:13:33 localhost.root systemd[1]: redis.service failed.
原因:忘了以前在這臺(tái)機(jī)器上已經(jīng)裝了gitlab,且使用了gitlab自帶在redis導(dǎo)致沖突了。
解決方法:先停了gitlab自帶redis,改用新裝的redis。
1.修改gitlab配置文件
打開配置文件:
vim /etc/gitlab/gitlab.rb
于 #### Redis TCP connection 處修改配置信息,redis['enable']=false為關(guān)閉自動(dòng)啟動(dòng),redis_host、redis_port分別對(duì)應(yīng)新redis的信息。
#### Redis TCP connection
redis['enable']=false
gitlab_rails['redis_host'] = "127.0.0.1"
gitlab_rails['redis_port'] = 6379
#gitlab_rails['redis_password'] = nil
修改完成,保存退出。
2.重新生成應(yīng)用配置信息
gitlab-ctl reconfigure
# ......
# Running handlers:
# Running handlers complete
# Chef Client finished, 24/476 resources updated in 08 seconds
# gitlab Reconfigured!
3.修改啟動(dòng)配置
打開配置:
vim /etc/systemd/system/redis.service
注釋掉:Type=forking
[Unit]
Description=redis-server
After=network.target
[Service]
#Type=forking
ExecStart=/usr/local/redis-6.2.6/src/redis-server /usr/local/redis-6.2.6/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
4.重啟gitlab
gitlab-ctl restart
gitlab啟動(dòng)信息中,沒有redis了。
ok: run: gitaly: (pid 26962) 0s
ok: run: gitlab-monitor: (pid 26982) 1s
ok: run: gitlab-workhorse: (pid 26985) 0s
ok: run: logrotate: (pid 27038) 0s
ok: run: nginx: (pid 27044) 0s
ok: run: node-exporter: (pid 27091) 0s
ok: run: postgres-exporter: (pid 27099) 1s
ok: run: postgresql: (pid 27108) 0s
ok: run: prometheus: (pid 27117) 1s
ok: run: sidekiq: (pid 27186) 0s
ok: run: unicorn: (pid 27195) 1s
5.重載啟動(dòng)配置、啟動(dòng)redis
systemctl daemon-reload
systemctl start redis
6.確認(rèn)是否已啟動(dòng)
systemctl status redis
狀態(tài)信息:
redis.service - redis-server
Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2023-04-09 16:58:07 CST; 10s ago
Main PID: 25695 (redis-server)
Tasks: 5
CGroup: /system.slice/redis.service
└─25695 /usr/local/redis-6.2.6/src/redis-server 127.0.0.1:6379
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.901 * monotonic clock: POSIX
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.902 * Running mode=standalon
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.902 # Server initialized
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.902 # WARNING overcommit_mem
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 * Loading RDB produced b
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 * RDB age 755 seconds
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 * RDB memory usage when
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 # Done loading RDB, keys
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 * DB loaded from disk: 0
4月 09 16:58:07 localhost.qzx redis-server[25695]: 25695:M 09 Apr 2023 16:58:07.903 * Ready to accept connec
Hint: Some lines were ellipsized, use -l to show in full.
注意:有在一起運(yùn)行g(shù)itlab的話,務(wù)必保證redis在正常,不然將導(dǎo)致gitlab報(bào)500錯(cuò)誤。