1、下载redis
2、上传至/usr/files
3、解压至/usr/local/redis-6.0.6
tar xzf redis-6.0.6.tar.gz -C /usr/local/redis-6.0.6
4、进入解压文件夹
cd redis-6.0.6
5、make
6、src/redis-server
如果大家在centos7下编译redis6.0版本,如果出现以下错误
In file included from server.c:30:0:
server.h:1022:5: error: expected specifier-qualifier-list before ‘_Atomic’
_Atomic unsigned int lruclock; /* Clock for LRU eviction */
请先检查gcc的版本是否低于5,如果是请先升级,可以使用以下命令:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
官方教程
redis 6.0.6 下载 — Redis中国用户组(CRUG)
7、配置自启动
a、vim redis.conf
b、配置:
#线程守护
daemonize yes
#开启远程任意IP访问
#bind 127.0.0.1
#关闭保护模式
protected-mode no
c、vim /etc/init.d/redis
输入以下内容:
#!/bin/bash #chkconfig: 22345 10 90#description: Start and Stop redis REDISPORT=6379EXEC=/usr/local/redis-6.0.6/redis-6.0.6/src/redis-server CLIEXEC=/usr/local/redis-6.0.6/redis-6.0.6/src/redis-cli PIDFILE=/var/run/redis.pid CONF="/usr/local/redis-6.0.6/redis-6.0.6/redis.conf"case "$1" instart)if [ -f $PIDFILE ];then echo "$PIDFILE exists,process is already running or crashed"elseecho "Starting Redis server..."$EXEC $CONF fi ;; stop)if [ ! -f $PIDFILE ];then echo "$PIDFILE does not exist,process is not running"elsePID=$(cat $PIDFILE) echo "Stopping..."$CLIEXEC -p $REDISPORT shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown..."sleep 1done echo "Redis stopped"fi ;; restart)"$0" stop sleep 3"$0" start ;;*) echo "Please use start or stop or restart as first argument";; esac
d、赋权
chmod +x /etc/init.d/redis
e、添加到服务
chkconfig –add redis
f、启动服务
chkconfig redis on
g、服务列表
chkconfig —list
h、重启实例测试自启是否生效
以上是centos7如何安装redis6.0.6的详细内容。更多信息请关注PHP中文网其他相关文章!