基于keepalived、redis sentinel的多实例redis集群【2】---realserver配置
配置realserver
在realserver的lo上指定虚拟ip
lo:2
配置完成后执行service network restart
slave如果有多个实例配置文件则为
vim /etc/sysctl.conf,添加内容如下:
net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2
在realserver的lo上指定虚拟ip
有两种方法
1.命令:
ip addr add 192.168.0.7/32 dev lo
ip addr add 192.168.0.8/32 dev lo
2.修改/etc/sysconfig/network-scripts/下的配置文件,添加两个配置文件ifcfg-lo:1和ifcfg-lo:2
lo:1
DEVICE=lo:1 IPADDR=192.168.0.7 NETMASK=255.255.255.255 # If you're having problems with gated making 127.0.0.0/8 a martian, # you can change this to something else (255.255.255.255, for example) ONBOOT=yes
lo:2
DEVICE=lo:2 IPADDR=192.168.0.8 NETMASK=255.255.255.255 # If you're having problems with gated making 127.0.0.0/8 a martian, # you can change this to something else (255.255.255.255, for example) ONBOOT=yes
配置完成后执行service network restart
使用ip addr查看是否应绑定ip成功
完成所有配置后启动不同端口的redis
master,启动实例,并且将日志存放到/data/redis路径下
nohup redis-server --port 6379 >/data/redis/redis6379.log & nohup redis-server --port 6380 >/data/redis/redis6380.log &slave
nohup redis-server --port --slaveof 192.168.0.2 6379 >/data/redis/redisslave6379.log & nohup redis-server --port --slaveof 192.168.0.2 6380 >/data/redis/redisslave6380.log &
slave如果有多个实例配置文件则为
nohup redis-server /etc/redis/redis_slave_6379.conf >/data/redis/redisslave6379.log & nohup redis-server /etc/redis/redis_slave_6380.conf >/data/redis/redisslave6380.log &