Centos8 yum方式安装最新Redis
你好! 这里为MBV微服务器系统搭建环境,默认你已准备好Centos8,在其基础上先安装部署docker.一、安装:
使用yum默认安装其最新版本
yum install redis
是否安装[y/N]: y
等待安装即可
二、设置开机自动启动:
systemctl enable redis.service
结果如下
三、启动:
1.在启动之前,先查看redis服务器状态
systemctl status redis.service
如下图所示,服务器是关闭状态
输入q,则退出状态查询。
2.启动redis服务
systemctl start redis.service
或者
systemctl start redis
可以看到状态已变为:enabled
注:这里先设置了开机自启动,后启动服务。我试着反过来,disabled状态没有变。
四、登录:
1.查看redis版本
redis-cli --version
2.客户端登录命令
redis-cli -h 127.0.0.1 -p 6379
3.redis服务操作命令
systemctl start redis.service #启动redis服务
systemctl stop redis.service #停止redis服务
systemctl restart redis.service #重新启动服务
systemctl status redis.service #查看服务当前状态
systemctl enable redis.service #设置开机自启动
systemctl disable redis.service #停止开机自启动
五、开放远程连接:
1.在redis的配置文件/etc/redis.conf中
将bind 127.0.0.1 注释为 #bind 127.0.0.1
1.打开/etc/redis.conf
>vi /etc/redis.conf
2.按下字母 i,切换到输入模式
>i
3.输入:wq!强制保存退出
>:wq!
六、打开防火墙:
//添加防火墙端口到防火墙
sudo firewall-cmd --add-port=6379/tcp --permanent
//重新加载防火墙规则
sudo firewall-cmd --reload
//重启redis
systemctl restart redis
参考:
CentOS8上安装redis
CentOS8使用yum安装Redis的方法
Centos8 yum方式安装Redis
Centos8安装Redis及初步使用