Centons7上安装Redis3.2.8并配置多端口


********************** 安装部分 *****************************

先进入一个目录,并下载Redis

cd /usr/local
wget http://download.redis.io/releases/redis-3.2.8.tar.gz

解压下载Redis源码压缩包,生成新的目录redis-3.2.8
tar xzf redis-3.2.8.tar.gz

进入目录,执行make编译
cd redis-3.2.8
make 

继续执行:
make install

配置6379端口,开机启动

执行./utils/install_server.sh配置Redis配置之后Redis能随系统启动。执行期间会让你选择端口,文件名称等,我都选默认。
./utils/install_server.sh

查看开机启动列表
chkconfig --list


********************** 配置多节点访问部分 *****************************

redis-server默认启动的端口是6379,使用的是默认的配置文件/etc/redis/6379.conf

比如现在要开启6380端口,先复制默认的配置文件为6380:
sudo cp /etc/redis/6379.conf /etc/redis/6380.conf

编辑6380.conf文件(此文件很长,可能要下拉很久才能找到):
sudp vim /etc/redis/6380.conf
pidfile /var/run/redis-server6380.pid
port 6380

logfile /var/log/redis-server6380.log

dbfilename dump6380.rdb

如果需要其他机器能够访问,需配置服务器IP:
bind 127.0.0.1   改为当前服务器IP,例如:bind 10.40.3.29

退出并保存!

还需编辑6379.conf文件(此文件很长,可能要下拉很久才能找到):
sudp vim /etc/redis/6379.conf

如果需要其他机器能够访问,需配置服务器IP:
bind 127.0.0.1   改为当前服务器IP,例如:bind 10.40.3.29

退出并保存!

配置6380端口,开机启动

cd /usr/local/redis-3.2.8/utils/
sudo cp install_server.sh install_server6380.sh

vim install_server6380.sh

将里面的6379的端口,全部改为6380,并保存!

执行./utils/install_server6380.sh配置Redis配置之后Redis能随系统启动。执行期间会让你选择端口,文件名称等,我都选默认。
./utils/install_server6380.sh

查看开机启动列表
chkconfig --list


********************** 配置防火墙 *****************************

firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --zone=public --add-port=6380/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all

********************** 启动和停止服务 *****************************

查看当前Redis的进程:
ps auxf | grep redis-server

启动:
redis-server /etc/redis/6379.conf
redis-server /etc/redis/6380.conf

全部停止:
redis-cli shutdown

单独停止:
redis-cli -p 6379 shutdown
redis-cli -p 6380 shutdown

********************** 验证是否可用 *****************************
方法1:
[root@localhost bin]# redis-cli
127.0.0.1:6379> flushdb  --清空当前选择的数据库
OK
127.0.0.1:6379> set testkey 2
OK
127.0.0.1:6379> get testkey
"2"

方法2:
在Windwos上安装RedisDesktopManager,配置Redis服务器的IP,端口测试是否可用链接

如果不能链接,尝试关闭Redis所在服务器的防火墙
systemctl stop firewalld.service

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值