开发者社区> 问答> 正文

在CentOS 6 运行 redis-sentinel 程序

云友“ptao” 提出 在ECS里无法成功运行 redis-sentinel 程序,提示端口无法绑定使用。

环境:CentOS 6 64位,redis-3.2.3

1. 执行更新
yum update
[attachment=116301]


2. 下载redis安装文件
wget http://download.redis.io/releases/redis-3.2.3.tar.gz3. 解压缩安装包
tar -xzvf redis-3.2.3.tar.gz4. 移动文件
mv redis-3.2.3 /usr/local/redis5. 转到工作目录
cd /usr/local/redis6. 编译
make7. 安装
make install
[attachment=116302]


8. 创建新的配置文件,
mkdir -p /etc/redis
cp redis.conf /etc/redis
9. 修改配置文件 /etc/redis/redis.conf,将 daemonize 值从 no 更改为 yes, 使之后台运行:
daemonize yes
[attachment=116303]


10.运行,测试可正常运行
/usr/local/bin/redis-server /etc/redis/redis.conf
[attachment=116304]


11.但运行出错,提示无法绑定使用相应的端口:
redis-sentinel /usr/local/redis/sentinel.conf

Creating Server TCP listening socket *:26379: unable to bind socket

12.修改配置文件 sentinel.conf 在 定义监听端口一行前添加监听IP参数,如 bind 0.0.0.0 ,表示仅监听IPv4。因为阿里云的ECS Linux系统暂时没有启用IPv6,所以 redis-sentinel 尝试在所有的(IPv4 + IPv6)的网络接口启动时,会报错
# port <sentinel-port>
# The port that this sentinel instance will run on
bind 0.0.0.0
port 26379

[attachment=116305]


13.再次尝试启动 redis-sentinel ,正常
[attachment=116306]


参考:
1. https://segmentfault.com/a/1190000002685224?spm=5176.bbsr298662.0.0.5G17qE
2. https://github.com/antirez/redis/issues/3431

展开
收起
dongshan8 2016-11-08 15:07:39 6641 0
4 条回答
写回答
取消 提交回答

  • 优秀文章-欢迎进行技术分享,感谢你的支持!

    -------------------------


    优秀文章-欢迎进行技术分享,感谢你的支持!

    2018-01-25 11:48:23
    赞同 展开评论 打赏
  • Re在CentOS 6 运行 redis-sentinel 程序
    赞,多谢帮助
    2016-11-09 09:20:09
    赞同 展开评论 打赏
  • 旺旺:nectar2。
    回 1楼(小柒2012) 的帖子
    您好,

    这个警告我也不知道是关于哪方面的,因为我对 redis 很陌生,例子中 redis-sentinel 运行后,可以看到相应的监听端口使用状态。
    2016-11-08 17:18:10
    赞同 展开评论 打赏
  • 一个程序员,欢迎骚扰!!!
    最后 怎么还有一个警告?
    2016-11-08 17:04:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Redis集群演化的心路历程——从2.x到3.0时代 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载