centos7安装redis
文章目录一、准备工作二、安装redis三、配置redis四、配置redis服务五、其他一、准备工作关闭防火墙等linux时间校对试验环境虚拟机服务器版本:centos7虚拟机IP地址:192.168.1.10win端测试软件:Another Redis Desktop Manager[root@localhost]# yum install -y gcc#redis需要gcc环境二、安装redis
·
一、准备工作
虚拟机服务器版本:centos7
虚拟机IP地址:192.168.1.10
win端测试软件:Another Redis Desktop Manager
[root@localhost]# yum install -y gcc #redis需要gcc环境
二、安装redis
[root@localhost ~]# mkidr /home/redis
[root@localhost ~]# cd /home/redis/
[root@localhost redis]# wget http://download.redis.io/releases/redis-6.0.10.tar.gz #下载
[root@localhost redis]# tar -zxvf redis-6.0.10.tar.gz #解压
[root@localhost redis]# cd redis-6.0.10
[root@localhost redis-6.0.10]# make PREFIX=/usr/local/redis install #安装
Hint: It's a good idea to run 'make test' ;)
INSTALL install #提示则install 安装成功
三、配置redis
[root@localhost redis-6.0.10]# mkdir /usr/local/redis/etc
[root@localhost redis-6.0.10]# cp redis.conf /usr/local/redis/etc/redis.conf #复制配置文件
[root@localhost redis-6.0.10]# cp sentinel.conf /usr/local/redis/etc/redis-sentinel.conf #复制配置文件
[root@localhost ~]# vim /usr/local/redis/etc/redis.conf #修改配置
#By default Redis does not run as a daemon. Use 'yes' if you need it.
#Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no #修改成daemonize yes,允许在后台运行
bind 127.0.0.1 #找到这行,添加#注释掉。
#requirepass foobared #去掉注释,foobared改成密码
logfile "" #添加日志保存路径,比如/var/log/redis.log
[root@localhost ~]# cd /usr/local/redis/bin
[root@localhost bin]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf #运行
[root@localhost bin]# ./redis-cli #进入redis
127.0.0.1:6379> set test hello
OK
127.0.0.1:6379> get test
"hello"
win端测试
四、配置redis服务
[root@localhost ~]# touch /usr/lib/systemd/system/redis.service
[root@localhost ~]# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
[Service]
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
ExecStop=/usr/local/bin/redis-cli -p 6397 shutdown
Type=forking
User=redis
Group=redis
RuntimeDirectory=redis
[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl enable redis
[root@localhost ~]# systemctl restart redis
五、其他
5.1、报错server.c:5491:15: 错误:‘struct redisServer’没有名为‘maxmemory’的成员等
解决办法:
[root@localhost redis-6.0.10]# gcc -v #查看版本低于5.3以下都要升级
[root@localhost redis-6.0.10]# yum -y install centos-release-scl
[root@localhost redis-6.0.10]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@localhost redis-6.0.10]# echo “source /opt/rh/devtoolset-9/enable” >> /etc/profile
5.2、win连接正常,centos连接异常,报错Invalid URI scheme
解决办法:
[root@localhost bin]# ./redis-cli -u 127.0.0.1 -p 6379 -a 123456
Invalid URI scheme
[root@localhost bin]# ./redis-cli
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> set test hello
OK
127.0.0.1:6379> get test
"hello"
更多推荐
已为社区贡献2条内容
所有评论(0)