centos7安装redis

一、安装gcc依赖
[root@localhost /]# yum install -y gcc

二、下载并解压安装包
[root@localhost opt]# wget http://download.redis.io/releases/redis-6.0.9.tar.gz
[root@localhost opt]# tar -zxvf redis-6.0.9.tar.gz

三、cd切换到redis解压目录下,编译
[root@localhost local]# cd redis-6.0.9
[root@localhost redis-6.0.9]# make

四、安装并指定安装目录
[root@localhost redis-6.0.9]# make install PREFIX=/usr/local/redis

五、启动服务

5.1前台启动
[root@localhost redis-6.0.9]# cd /usr/local/redis/bin/
[root@localhost bin]# ./redis-server

5.2后台启动并设置密码
从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录
[root@localhost bin]# cp /usr/local/redis-6.0.9/redis.conf /usr/local/redis/bin/
[root@localhost bin]# vim redis.conf
修改 redis.conf 文件中:daemonize no 改为 daemonize yes
修改redis.conf文件中:requirepass foobared取消注释(改为:requirepass 123456)

启动
[root@localhost bin]# ./redis-server redis.conf

六、设置开机启动
添加开机启动服务
[root@localhost bin]# vim /etc/systemd/system/redis.service
添加以下内容:
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

设置开机启动
[root@localhost bin]# systemctl daemon-reload
[root@localhost bin]# systemctl start redis.service
[root@localhost bin]# systemctl enable redis.service

七、安装报错

7.1错误示例:
‘struct redisServer’ has no member named ‘server_cpulist’ redisSetCpuAff
在这里插入图片描述
在这里插入图片描述
7.2错误原因:
gcc版本问题,新版本的。redis6.0以上

7.3解决方式:
[root@localhost /]#yum -y install centos-release-scl
[root@localhost /]#yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost /]#scl enable devtoolset-9 bash
[root@localhost /]#echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值