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
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论