Login
网站首页 > 文章中心 > 其它

Centos7安装Redis_centos7安装redis5

作者:小编 更新时间:2023-09-09 08:19:32 浏览量:439人看过

第一段:安装gcc依赖

由于 redis 是用 C 语言开发,安装之前必先确认是否安装 gcc 环境(gcc -v),如果没有安装,执行以下命令进行安装

[root@localhost local]# yum install -y gcc?

第三段:cd切换到redis解压目录下,执行编译

第四段:安装并指定安装目录

第五段:启动服务

Centos7安装Redis_centos7安装redis5-图1

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

从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录

修改 redis.conf?文件,把 daemonize no?改为 daemonize yes

[root@localhost bin]# vi redis.conf

Centos7安装Redis_centos7安装redis5

后台启动

Centos7安装Redis_centos7安装redis5-图2

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

Centos7安装Redis_centos7安装redis5

第六段:设置开机启动

添加开机启动服务

[root@localhost bin]# vi /etc/systemd/system/redis.service

复制粘贴以下内容:

[Unit]Description=redis-serverAfter=network.target

[Service]Type=forkingExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.confPrivateTmp=true

[Install]WantedBy=multi-user.target

注意:ExecStart配置成自己的路径?

设置开机启动

[root@localhost bin]# systemctl daemon-reload

[root@localhost bin]# systemctl start redis.service

[root@localhost bin]# systemctl enable redis.service

创建 redis 命令软链接

[root@localhost ~]# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis

测试 redis

Centos7安装Redis_centos7安装redis5

服务操作命令

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? ?#停止开机自启动

redis本地能访问外网不能访问问题

①确认配置文件bind的ip是否正确,一般想要外网能访问,需要填写为0.0.0.0,表示监听任何ip

注意任何人都能访问,一定要开启密码?requirepass?你的密码

service redis restart

service iptables status

service iptables stop

如果可以连接,表示防护墙规则有问题

vim /etc/sysconfig/iptables

注意这里的顺序很重要

service iptables restart

Centos7安装Redis_centos7安装redis5

Centos7安装Redis_centos7安装redis5

Centos7安装Redis_centos7安装redis5

以上就是土嘎嘎小编大虾米为大家整理的相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章