CentOS安装redis 本文共有2550个字,关键词: yum install centos-release-scl yum install devtoolset-8 scl enable devtoolset-8 bash cd /usr/local/src/ wget https://download.redis.io/releases/redis-7.0.4.tar.gz tar -zxvf redis-7.0.4.tar.gz #mv redis-7.0.4 redis #cd redis/ cd redis-7.0.4 make && make install #前台启动 ./redis-server #后台启动 & cd .. vim redis.conf # 修改以下配置 并保存退出 daemonize yes # 把no改成yes,后台运行 bind * -::1 protected-mode no ./src/redis-server redis.conf ps -ef |grep redis #设置开机启动 vim /etc/init.d/redis # 输入以下内容 #!/bin/sh # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/bin/redis-server REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/usr/local/src/redis/redis.conf" # 修改为redis.conf 所在路径 case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $REDIS_CLI -p $REDISPORT SHUTDOWN while [ -x ${PIDFILE} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac #修改权限 chmod 755 /etc/init.d/redis #启动测试 /etc/init.d/redis start #添加到服务列表 chkconfig --add /etc/init.d/redis #设置开机启动 chkconfig redis on 「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」 赞赏 × 梦白沙 (๑>ڡ<)☆谢谢老板~ 1元 2元 5元 10元 50元 任意金额 2元 使用微信扫描二维码完成支付 版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。 随手发现,CentOS 2022-07-21 评论 384 次浏览