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.
原因:忘了以前在这台机器上已经装了gitlab,且使用了gitlab自带在redis导致冲突了。
解决方法:先停了gitlab自带redis,改用新装的redis。
1.修改gitlab配置文件
打开配置文件:
vim /etc/gitlab/gitlab.rb
于 #### Redis TCP connection 处修改配置信息,redis['enable']=false为关闭自动启动,redis_host、redis_port分别对应新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.重新生成应用配置信息
gitlab-ctl reconfigure
# ......
# Running handlers:
# Running handlers complete
# Chef Client finished, 24/476 resources updated in 08 seconds
# gitlab Reconfigured!
3.修改启动配置
打开配置:
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启动信息中,没有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.重载启动配置、启动redis
systemctl daemon-reload
systemctl start redis
6.确认是否已启动
systemctl status redis
状态信息:
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.
注意:有在一起运行gitlab的话,务必保证redis在正常,不然将导致gitlab报500错误。