当前位置: 代码网 > it编程>数据库>Redis > CentOS7.9编译安装Redis6.2.5指南分享

CentOS7.9编译安装Redis6.2.5指南分享

2026年08月18日 Redis 我要评论
gcc 11是自己编译安装的所以redis的makefile找不到cc,需要手动造一个链接cd /usr/binsudo ln -s /usr/local/gcc-11.2.0/bin/gcc cc编

gcc 11是自己编译安装的

所以redis的makefile找不到cc,需要手动造一个链接

cd /usr/bin
sudo ln -s /usr/local/gcc-11.2.0/bin/gcc cc

编译

 make -j7 use_systemd=yes prefix=/opt/redis/

安装

sudo make prefix=/opt/redis install

卸载

sudo make uninstall

自带的systemd启动文件有点问题,改为如下

[unit]
description=redis data structure server
documentation=https://redis.io/documentation
#before=your_application.service another_example_application.service
#assertpathexists=/var/lib/redis
wants=network-online.target
after=network-online.target
[service]
execstart=/opt/redis/bin/redis-server /opt/redis/redis.conf --supervised systemd --daemonize no
## alternatively, have redis-server load a configuration file:
#execstart=/usr/local/bin/redis-server /path/to/your/redis.conf
limitnofile=10032
nonewprivileges=yes
#oomscoreadjust=-900
privatetmp=yes
type=notify
timeoutstartsec=15
timeoutstopsec=15
umask=0077
#user=redis
#group=redis
#workingdirectory=/var/lib/redis
[install]
wantedby=multi-user.target

注意修改了timeout的值,否则会经常报timeout错误,例如

job for redis.service failed because a timeout was exceeded. see "systemctl status redis.service" and "journalctl -xe" for details.
# systemctl status redis.service
● redis.service - redis data structure server
   loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
   active: failed (result: timeout) since mon 2021-08-30 17:11:25 cst; 6min ago
     docs: https://redis.io/documentation
  process: 52802 execstart=/opt/redis/bin/redis-server /opt/redis/redis.conf --supervised systemd --daemonize no (code=killed, signal=term)
 main pid: 52802 (code=killed, signal=term)
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: starting redis data structure server...
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service start operation timed out. terminating.
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service stop-sigterm timed out. killing.
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service still around after sigkill. ignoring.
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: failed to start redis data structure server.
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: unit redis.service entered failed state.
aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service failed.

-- a session with the id c87 has been terminated.
aug 30 17:07:43 elcndc2yfzx01t polkitd[1042]: registered authentication agent for unix-process:52658:218121463 (system bus name :1.8843 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/policykit1/authe
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: starting redis data structure server...
-- subject: unit redis.service has begun start-up
-- defined-by: systemd
-- support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- unit redis.service has begun starting up.
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service start operation timed out. terminating.
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service stop-sigterm timed out. killing.
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: failed to start redis data structure server.
-- subject: unit redis.service has failed
-- defined-by: systemd
-- support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- unit redis.service has failed.
-- 
-- the result is failed.
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: unit redis.service entered failed state.
aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service failed.
aug 30 17:07:43 elcndc2yfzx01t polkitd[1042]: unregistered authentication agent for unix-process:52658:218121463 (system bus name :1.8843, object path /org/freedesktop/policykit1/authenticationagent, locale en_us.utf-8) (disconne

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2026  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com