docker搭建redis集群 - xixicat
序
这里参照了Docker 搭建redis 集群这篇文章来,非常顺利。
下载镜像
docker pull redis
准备配置文件
mkdir/data/docker/redis/ wget https://raw.githubusercontent.com/antirez/redis/3.0/redis.conf \ -O /data/docker/redis/redis.confcd /data/docker/redis/ sed -i 's/# slaveof <masterip> <masterport>/slaveof redis-master 6379/g' redis.conf
启动redis容器
docker run --name redis-master -p 6379:6379 -d redisdocker run --link redis-master:redis-master -v /data/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf --name redis-slave1 -d redis redis-server /usr/local/etc/redis/redis.confdocker run --link redis-master:redis-master -v /data/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf --name redis-slave2 -d redis redis-server /usr/local/etc/redis/redis.confdocker run --link redis-master:redis-master -v /data/docker/redis/redis.conf:/usr/local/etc/redis/redis.conf --name redis-slave3 -d redis redis-server /usr/local/etc/redis/redis.conf
查看redis集群
redis-cli 127.0.0.1:6379> info# Serverredis_version:3.0.6redis_git_sha1:00000000redis_git_dirty:0redis_build_id:48bba53ba79f07acredis_mode:standaloneos:Linux 3.13.0-27-generic x86_64arch_bits:64multiplexing_api:epollgcc_version:4.9.2process_id:1run_id:6d552d47e50137b6ee40697d7254891aa5dbdb68tcp_port:6379uptime_in_seconds:21554uptime_in_days:0hz:10lru_clock:10637013config_file:# Clientsconnected_clients:1client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0# Memoryused_memory:1926248used_memory_human:1.84Mused_memory_rss:4419584used_memory_peak:1963096used_memory_peak_human:1.87Mused_memory_lua:36864mem_fragmentation_ratio:2.29mem_allocator:jemalloc-3.6.0# Persistenceloading:0rdb_changes_since_last_save:0rdb_bgsave_in_progress:0rdb_last_save_time:1453456066rdb_last_bgsave_status:okrdb_last_bgsave_time_sec:0rdb_current_bgsave_time_sec:-1aof_enabled:0aof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:okaof_last_write_status:ok# Statstotal_connections_received:5total_commands_processed:64476instantaneous_ops_per_sec:3total_net_input_bytes:2426080total_net_output_bytes:92455instantaneous_input_kbps:0.14instantaneous_output_kbps:0.02rejected_connections:0sync_full:3sync_partial_ok:0sync_partial_err:0expired_keys:0evicted_keys:0keyspace_hits:0keyspace_misses:0pubsub_channels:0pubsub_patterns:0latest_fork_usec:222migrate_cached_sockets:0# Replicationrole:masterconnected_slaves:3slave0:ip=172.17.0.2,port=6379,state=online,offset=30087,lag=1slave1:ip=172.17.0.3,port=6379,state=online,offset=30101,lag=0slave2:ip=172.17.0.4,port=6379,state=online,offset=30087,lag=1master_repl_offset:30101repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:30100# CPUused_cpu_sys:7.37used_cpu_user:5.34used_cpu_sys_children:0.00used_cpu_user_children:0.00# Clustercluster_enabled:0# Keyspace