Cent OS Linux 单机两个Redis实例 主从配置

 

[adminroot@localhost ~]$ su
Password:
[root@localhost adminroot]# vim /etc/redis/6379.conf
/slaveof
n
slaveof 192.168.1.108 6379
masterauth mypassword123
:wq
[root@localhost adminroot]# redis-server /etc/redis/6379.conf &
Error condition on socket for SYNC: Connection refused
[root@localhost adminroot]#reboot

 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              

3421:S 22 May 01:13:55.426 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3421:S 22 May 01:13:55.427 # Server started, Redis version 3.2.0
3421:S 22 May 01:13:55.427 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
3421:S 22 May 01:13:55.428 # 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

[root@localhost adminroot]# vim /etc/sysctl.conf
vm.overcommit_memory = 1
[root@localhost adminroot]# reboot

                _._                                                 
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 3.2.0 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 3386
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              

3386:S 22 May 01:28:23.293 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3386:S 22 May 01:28:23.293 # Server started, Redis version 3.2.0
3386:S 22 May 01:28:23.294 # 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.
3386:S 22 May 01:28:23.295 * DB loaded from disk: 0.000 seconds
3386:S 22 May 01:28:23.295 * The server is now ready to accept connections on port 6379

[root@localhost adminroot]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@localhost adminroot]# vim /etc/rc.local
touch /var/lock/subsys/local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@localhost adminroot]# echo 511 > /proc/sys/net/core/somaxconn

4590:S 22 May 01:48:29.024 * Connecting to MASTER 192.168.1.108:6379
4590:S 22 May 01:48:29.025 * MASTER <-> SLAVE sync started
4590:S 22 May 01:48:29.025 # Error condition on socket for SYNC: Connection refused

==============================================================================

bash-4.2$ su
密码:
[root@dbserver latte]# redis-server /etc/redis/6379.conf &
[root@dbserver latte]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> get name
"master"
127.0.0.1:6379> get age
"28"

[root@dbserver latte]# redis-server /etc/redis/6380.conf &
17591:S 24 May 13:32:58.751 * DB loaded from disk: 0.000 seconds
17591:S 24 May 13:32:58.751 * The server is now ready to accept connections on port 6380
17591:S 24 May 13:32:58.751 * Connecting to MASTER 127.0.0.1:6379
17591:S 24 May 13:32:58.751 * MASTER <-> SLAVE sync started
17591:S 24 May 13:32:58.751 * Non blocking connect for SYNC fired the event.
17591:S 24 May 13:32:58.752 * Master replied to PING, replication can continue...
17591:S 24 May 13:32:58.752 * Partial resynchronization not possible (no cached master)
17591:S 24 May 13:32:58.754 * Full resync from master: e2ed64ea513418cdcc4cdefd7f0ef6711d9ef4ac:1
17591:S 24 May 13:32:59.141 * MASTER <-> SLAVE sync: receiving 40 bytes from master
17591:S 24 May 13:32:59.141 * MASTER <-> SLAVE sync: Flushing old data
17591:S 24 May 13:32:59.141 * MASTER <-> SLAVE sync: Loading DB in memory
17591:S 24 May 13:32:59.141 * MASTER <-> SLAVE sync: Finished with success
[root@dbserver latte]# redis-cli -h 127.0.0.1 -p 6380
127.0.0.1:6380> keys *
1) "name"
2) "age"
127.0.0.1:6380> get name
"master"
127.0.0.1:6380> get age
"28"
127.0.0.1:6380>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值