Linux下编译安装Redis以及主从复制配置(4)

[28584] 16 Apr 23:48:55.614 # 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.

[28584] 16 Apr 23:48:55.614 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

[28584] 16 Apr 23:48:55.615 * DB loaded from disk: 0.000 seconds

[28584] 16 Apr 23:48:55.615 * The server is now ready to accept connections on port 6379

四、主从配置

①、配置

在从机上按照上面的步骤安装redis,然后在从机的redis.conf里面新增如下配置项目:


#指定redis主机的IP地址和端口(默认未设置密码认证)
slaveof 192.168.10.124 6379


#指定redis主机的IP地址和端口(默认未设置密码认证)

slaveof 192.168.10.124 6379


保存后启动redis即可完成简单的主从配置。

②、测试

测试很简单,先在主机上通过客户端 redis-cli 执行新增键值命令:


[root@localhost ~]# /usr/local/redis/bin/redis-cli
127.0.0.1:6379> set newkey slavetest
OK

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

127.0.0.1:6379> set newkey slavetest

OK


然后,登录从机上同样执行 redis-cli 执行查询命令:


[root@localhost ~]# /usr/local/redis/bin/redis-cli       
127.0.0.1:6379> get newkey
"slavetest"

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

127.0.0.1:6379> get newkey

"slavetest"


很明显主机上新增的键值已经自动同步到了从机,主从同步成功!

本文只是记录一下基本的编译安装和主从配置,当然,redis还有其可以继续进行自定义设置或优化的项目,后续有机会再继续整理补充一下。

Ubuntu 14.04下Redis安装及简单测试

Redis集群明细文档

Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis

Redis系列-安装部署维护篇

CentOS 6.3安装Redis

Redis安装部署学习笔记

Redis配置文件redis.conf 详解

Redis 的详细介绍请点这里
Redis 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/580554b0bebbc0b1481d4319b04bd99e.html