Redis安装+主从配置 过程中 的几个小 Tips
来源:互联网 发布:网络推广月度工作计划 编辑:程序博客网 时间:2024/05/24 07:23
首先Redis的安装前,先执行下面的命令:
# echo "vm.overcommit_memory=1" >>/etc/sysctl.conf
# echo "vm.swappiness=1" >>/etc/sysctl.conf
redis 安装是否成功,测试方法:
# /opt/redis/bin/redis-cli ping
PONG # 正常安装显示结果。
redis 日志报错:
问题1:
# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
解决办法:
# echo 511 > /proc/sys/net/core/somaxconn
问题2:
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis.
To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,
and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
解决办法:
# echo never > /sys/kernel/mm/transparent_hugepage/enabled
# vi /etc/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
问题3:
# telnet 192.168.56.10 6379
Trying 192.168.56.10...
Connected to 192.168.56.10.
Escape character is '^]'.
-DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface.
If you want to connect from external computers to Redis you may adopt one of the following solutions:
1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.
2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.
3) If you started the server manually just for testing, restart it with the '--protected-mode no' option.
4) Setup a bind address or an authentication password.
NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
Connection closed by foreign host.
解决办法:
1. # /opt/redis/bin/redis-cli
127.0.0.1:6379> config set protected-mode no
2. vi /data/redis/redis6379/6379.conf
protected-mode no
3. 启动服务 加选项。
# /opt/redis/sbin/redis-server /data/redis/redis6379/6379.conf --protected-mode no
4. 设置 bind 地址或者 权限认证密码
a. bind 地址 (主服务的配置文件设置,从不需要设置)
bind 127.0.0.1 192.168.56.10
b. 权限认证密码
主配置文件:
# vi /data/redis/redis6379/6379.conf
port 6379
requirepass redis
从配置文件:
# vi /data/redis/redis6379/6379.conf
port 6379
slaveof 192.168.56.10 6379
masterauth redis
requirepass redis # 如果还有从服务器,需要否则不需要。
主服务器上执行:
# /opt/redis/bin/redis-cli -h 192.168.56.10 -a redis set city beijing
从服务器上执行:
# /opt/redis/bin/redis-cli -h 192.168.56.20 get city
0 0
- Redis安装+主从配置 过程中 的几个小 Tips
- redis 主从安装配置
- redis 的安装以及主从配置
- Redis的安装、部署、主从配置
- Redis主从配置详细过程
- Redis主从配置详细过程
- redis的主从配置
- Redis的主从配置
- Redis安装及主从配置
- Redis主从服务器安装配置
- Redis安装与主从配置
- redis 安装 ,主从配置,选举
- Redis安装及主从配置
- Redis安装及主从配置
- Redis安装及主从配置
- Redis安装及主从配置
- redis安装及主从配置
- Redis安装及主从配置
- app检测更新
- mysql语句或者phpmyadmin操作取消外键约束
- 几个 Context 上下文的区别
- python中几种不同类型的参数的区分及其定义时的顺序
- 【RT-Thread学习笔记 2】RT-Thread的线程(任务)处理
- Redis安装+主从配置 过程中 的几个小 Tips
- 利用Digester实现xml和bean之间的转换(二)
- rsyslog研究
- LA 2995 Image Is Everything
- 给DotSpatial实现中距离/长度测量图层
- OData Edm.Geography和Edm.Geometry基本类型
- JQuery定时器
- 【RT-Thread学习笔记 3】线程优先级抢占实验
- 框架