Docker環境搭建redis叢集(主從模式)
Docker環境搭建redis叢集(主從模式)
序
本文將介紹如何在docker中部署redis叢集(主從模式)。
部署環境
CentOS 7 host A 192.168.199.200 (master)
CentOS 7 host B 192.168.199.201 (slave)
部署
host A 部署master
寫主服務配置檔案redis_master.conf
daemonize no
pidfile "/var/run/redis.pid"
port 6379
timeout 300
loglevel warning
logfile "redis.log"
databases 16
rdbcompression yes
dbfilename "redis.rdb"
dir "/data"
requirepass password
masterauth password
maxclients 10000
maxmemory 1000mb
maxmemory-policy allkeys-lru
appendonly no
appendfsync always
啟動主redis服務
docker run --name redis_master -p 6379:6379 -v $(pwd)/redis_master.conf:/data/redis_master.conf --restart=always -d redis:latest redis-server redis_master.conf
host B 部署slave
寫從服務配置檔案redis_slave.conf
daemonize no
pidfile "/var/run/redis.pid"
port 6379
timeout 300
loglevel warning
logfile "redis.log"
databases 16
rdbcompression yes
dbfilename "redis.rdb"
dir "/data"
requirepass password
masterauth password
maxclients 10000
maxmemory 1000mb
maxmemory-policy allkeys-lru
appendonly no
appendfsync always
slaveof 192.168.199.200 6379
啟動從redis服務
docker run --name redis_slave -p 6379:6379 -v $(pwd)/redis_slave.conf:/data/redis_slave.conf --restart=always -d redis:latest redis-server redis_slave.conf
寫哨兵叢集配置檔案sentinel.conf
daemonize no
port 26379
dir "/tmp"
sentinel monitor mymaster 192.168.199.200 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel auth-pass mymaster password
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
啟動sentinel服務
docker run --name sentinel -p 26379:26379 -v $(pwd)/sentinel.conf:/data/sentinel.conf --restart=always -d redis:latest redis-sentinel sentinel.conf
檢視部署結果
host A 執行如下命令
[root@localhost ~]# docker inspect redis_master | grep IPA
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAMConfig": null,
"IPAddress": "172.17.0.2",
[root@localhost ~]# docker run -it redis redis-cli -h 172.17.0.2
172.17.0.2:6379> info
NOAUTH Authentication required.
172.17.0.2:6379> auth password
OK
172.17.0.2:6379> info
# Server
redis_version:3.2.8
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:9c531c9c1d171a62
redis_mode:standalone
os:Linux 3.10.0-514.10.2.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.9.2
process_id:1
run_id:3f9915c39a62b684e2f20594c72fe3d1633f115b
tcp_port:6379
uptime_in_seconds:5289
uptime_in_days:0
hz:10
lru_clock:13508852
executable:/data/redis-server
config_file:/data/redis_master.conf
# Clients
connected_clients:3
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:1932944
used_memory_human:1.84M
used_memory_rss:6893568
used_memory_rss_human:6.57M
used_memory_peak:1973896
used_memory_peak_human:1.88M
total_system_memory:1023963136
total_system_memory_human:976.53M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:1048576000
maxmemory_human:1000.00M
maxmemory_policy:allkeys-lru
mem_fragmentation_ratio:3.57
mem_allocator:jemalloc-4.0.3
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1489900357
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
# Stats
total_connections_received:7
total_commands_processed:8721
instantaneous_ops_per_sec:1
total_net_input_bytes:416036
total_net_output_bytes:1265209
instantaneous_input_kbps:0.03
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:1
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:4755
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.199.201,port=6379,state=online,offset=237002,lag=0
master_repl_offset:237002
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:237001
# CPU
used_cpu_sys:9.30
used_cpu_user:3.33
used_cpu_sys_children:0.05
used_cpu_user_children:0.02
# Cluster
cluster_enabled:0
# Keyspace
相關文章
- 基於docker環境下搭建redis主從叢集DockerRedis
- Redis主從同步叢集搭建Redis主從同步
- Docker構建redis叢集環境DockerRedis
- 基於Dokcer搭建Redis叢集(主從叢集)Redis
- Redis叢集環境搭建實踐Redis
- 12. Redis叢集環境搭建Redis
- linux系統——Redis叢集搭建(主從+哨兵模式)LinuxRedis模式
- Redis叢集搭建 三主三從Redis
- Redis叢集搭建(三主三從)Redis
- Docker搭建Redis叢集DockerRedis
- Mac 環境下 Redis 叢集的搭建MacRedis
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- Redis搭建主從複製、哨兵叢集Redis
- 從 0 開始使用 Docker 快速搭建 Hadoop 叢集環境DockerHadoop
- 【環境搭建】RocketMQ叢集搭建MQ
- CentOS7.8 環境搭建 Redis 主從複製和哨兵模式CentOSRedis模式
- 生產環境的redis高可用叢集搭建Redis
- 搭建Redis“主-從-從”模式叢集並使用 RedisTemplate 實現讀寫分離Redis模式
- Docker Compose搭建MySQL主從複製叢集DockerMySql
- Zookeeper 叢集環境搭建
- Docker Redis 5.0 叢集(cluster)搭建DockerRedis
- Docker LNMP Redis 環境搭建DockerLNMPRedis
- Redis三種高可用模式:主從、哨兵、叢集Redis模式
- CentOS 7.9 環境下搭建k8s叢集(一主兩從)CentOSK8S
- docker 配置 Mysql主從叢集DockerMySql
- redis主從叢集搭建及容災部署(哨兵sentinel)Redis
- linux虛擬機器環境快速搭建redis5.x版本的主從叢集總結Linux虛擬機Redis
- Docker 容器搭建及 Redis 叢集原理DockerRedis
- Redis多例項及主從複製環境搭建Redis
- es 5.5.3叢集環境搭建
- hadoop叢集環境搭建Hadoop
- Glassfish叢集環境的搭建
- Docker Swarms 跨主機叢集搭建DockerSwarm
- Hadoop框架:叢集模式下分散式環境搭建Hadoop框架模式分散式
- 5分鐘實現用docker搭建Redis叢集模式和哨兵模式DockerRedis模式
- Redis叢集環境安裝指南Redis
- Docker部署系列之Docker Compose安裝Redis三主三從叢集DockerRedis
- Redis高可用-主從,哨兵,叢集Redis