redis 搭建主从

来源:互联网 发布:57是什么意思网络用语 编辑:程序博客网 时间:2024/05/19 03:29
redis 主:将主从redis配置文件redis.conf中的aemonize no 改为 yesjrhrpt01:/etc/redis# grep port redis.conf # Accept connections on the specified port, default is 6379.# If port 0 is specified Redis will not listen on a TCP socket.port 6379jrhrpt01:/etc/redis# grep slaveof  redis.conf # Master-Slave replication. Use slaveof to make a Redis instance a copy of# slaveof <masterip> <masterport>redis 从:jrhrpt02:/etc/redis# grep slaveof  redis.conf # Master-Slave replication. Use slaveof to make a Redis instance a copy of# slaveof <masterip> <masterport>slaveof 11.40.69.216 6379  ---redis 主# If the master is password protected (using the "requirepass" configuration# directive below) it is possible to tell the slave to authenticate before# starting the replication synchronization process, otherwise the master will# refuse the slave request.##masterauth <master-password>masterauth xxxxx启动redis:redis-server /etc/redis.conf测试:主test-redis:/root# cat a1.pl use Redis;my $r = Redis->new( server => "192.168.32.167:6379",reconnect => 1,every=>60); $r = Redis->new( password =>  'xxxxx' );  $r->set('zhoucui','111222333');  $r->save;  $r->quit;perl a1.pl从:test-redis2:/data01/redis# redis-server --/etc/redis.conf^Ctest-redis2:/data01/redis# redis-cli 127.0.0.1:6379> auth 'xxx'OK127.0.0.1:6379> get zhoucui"111222333"127.0.0.1:6379> 

0 0
原创粉丝点击