经常使用Docker-Compose轻松搭建高可用Redis集群指南 (经常使用dou+会不会被限流)
当初业务系统关于缓存的依赖似乎是必无法少的,咱们可以在各种各样的系统中看到Redis的身影。思索到系统运转的稳固性,Redis的运行和数据库一样须要做到高可用部署。
一、Redis的多种高可用打算
经常出现的Redis的高可用打算有以下几种:
在选用高可用打算时,须要思索系统的可用性需求、数据分歧性要求、网络拓扑等要素。同时,也要留意启动适当的测试和监控,确保Redis集群的稳固性和高可用性。
二、经常使用Compose装置Redis并性能哨兵形式(RedisSentinel)
1.环境预备
集群的架构普通主机为奇数台,所以,假设是驳回集群形式,那么至少预备3台主机,受消费环境所限,咱们只要两台Linux主机,然而咱们可以经常使用Docker搭建多个Redis服务(Redis主服务1、Redis从服务2、Redis从服务3):
2.预备Redis文件寄存目录
mkdir-p/opt/contner/redis/master/data/opt/container/redis/master/conf/opt/container/redis/master/logs/opt/container/redis/sentinel/data/opt/container/redis/sentinel/conf/opt/container/redis/sentinel/logschmod-R777/opt/container/redis/master/data/opt/container/redis/master/conf/opt/container/redis/master/logs/opt/container/redis/sentinel/data/opt/container/redis/sentinel/conf/opt/container/redis/sentinel/logs
在192.168.0.210主机上口头Redis从服务2所需目录及权限命令
mkdir-p/opt/container/redis/slave1/data/opt/container/redis/slave1/conf/opt/container/redis/slave1/logs/opt/container/redis/sentinel1/data/opt/container/redis/sentinel1/conf/opt/container/redis/sentinel1/logschmod-R777/opt/container/redis/slave1/data/opt/container/redis/slave1/conf/opt/container/redis/slave1/logs/opt/container/redis/sentinel1/data/opt/container/redis/sentinel1/conf/opt/container/redis/sentinel1/logs
在192.168.0.195主机上口头Redis从服务3所需目录及权限命令
mkdir-p/opt/container/redis/slave2/data/opt/container/redis/slave2/conf/opt/container/redis/slave2/logs/opt/container/redis/sentinel2/data/opt/container/redis/sentinel2/conf/opt/container/redis/sentinel2/logschmod-R777/opt/container/redis/slave2/data/opt/container/redis/slave2/conf/opt/container/redis/slave2/logs/opt/container/redis/sentinel2/data/opt/container/redis/sentinel2/conf/opt/container/redis/sentinel2/logs
/opt/container/redis/**/data用于寄存Redis数据文件/opt/container/redis/**/conf用于寄存Redis性能文件/opt/container/redis/**/logs用于寄存Redis日志文件
/opt/container/sentinel/**/data用于寄存Redis哨兵数据文件/opt/container/sentinel/**/conf用于寄存Redis哨兵性能文件/opt/container/sentinel/**/logs用于寄存Redis哨兵日志文件
3.Redis主机docker-compose.yml文件
version:'3'services:##redis主性能redisMaster:image:redis:latestrestart:alwayscontainer_name:redis-mastercommand:redis-server/usr/local/etc/redis/redis.conf##将26381映射到26381上ports:-"26381:26381"volumes:##数据目录,要确保先创立好-/opt/container/redis/master/data:/data-/opt/container/redis/master/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/master/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"##redis从性能redisSlave1:image:redis:latestrestart:alwayscontainer_name:redis-slave-1command:redis-server/usr/local/etc/redis/redis.conf##将26382映射到26382上ports:-"26382:26382"volumes:##数据目录,要确保先创立好-/opt/container/redis/slave1/data:/data-/opt/container/redis/slave1/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/slave1/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"sentinel:image:redis:latestrestart:alwayscontainer_name:redis-sentinelports:-36381:36381command:redis-sentinel/opt/redis/sentinel/sentinel.confvolumes:-/opt/container/redis/sentinel/data:/data-/opt/container/redis/sentinel/conf/sentinel.conf:/opt/redis/sentinel/sentinel.conf-/opt/container/redis/sentinel/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"sentinel1:image:redis:latestrestart:alwayscontainer_name:redis-sentinel-1ports:-36382:36382command:redis-sentinel/opt/redis/sentinel/sentinel1.confvolumes:-/opt/container/redis/sentinel1/data:/data-/opt/container/redis/sentinel1/conf/sentinel1.conf:/opt/redis/sentinel/sentinel1.conf-/opt/container/redis/sentinel1/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"
version:'3'services:##redis从2性能redisSlave2:image:redis:latestrestart:alwayscontainer_name:redis-slave-2command:redis-server/usr/local/etc/redis/redis.conf##将26383映射到26383上ports:-"26383:26383"volumes:##数据目录,要确保先创立好-/opt/container/redis/slave2/data:/data-/opt/container/redis/slave2/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/slave2/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"sentinel2:image:redis:latestrestart:alwayscontainer_name:redis-sentinel-2ports:-36383:36383command:redis-sentinel/opt/redis/sentinel/sentinel2.confvolumes:-/opt/container/redis/sentinel2/data:/data-/opt/container/redis/sentinel2/conf/sentinel2.conf:/opt/redis/sentinel/sentinel2.conf-/opt/container/redis/sentinel2/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"
4.预备Redis服务的性能文件
endonlyyesport26381appendfilenameappendonly.aofappendfsynceverysecauto-aof-rewrite-min-size10Mauto-aof-rewrite-percentage100requirepass"设置明码"masterauth"设置明码"replica-read-onlyno
appendonlyyesport26382appendfilenameappendonly.aofappendfsynceverysecauto-aof-rewrite-min-size10Mauto-aof-rewrite-percentage100requirepass"设置明码"replicaof192.168.0.21026381masterauth"设置明码"replica-read-onlyno
appendonlyyesport26383appendfilenameappendonly.aofappendfsynceverysecauto-aof-rewrite-min-size10Mauto-aof-rewrite-percentage100requirepass"设置明码"replicaof192.168.0.21026381masterauth"设置明码"replica-read-onlyno
4.预备Redis哨兵的性能文件,每个Redis服务对应一个哨兵性能
#哨兵sentinel实例运转的端口port36381daemonizenopidfile/var/run/redis-sentinel.piddir/tmpsentinelmonitormymaster192.168.0.210263812sentinelauth-passmymaster"Redis明码"#指定多少毫秒之后主节点没有应对哨兵sentinel此时哨兵客观上以为主节点下线自动30秒sentineldown-after-millisecondsmymaster30000#指定了在出现failover主备切换时最多可以有多少个slave同时对新的master启动同步,这个数字越小,成功failover所需的期间就越长sentinelparallel-syncsmymaster1#缺点转移的超时期间sentinelfailover-timeoutmymaster180000sentineldeny-scripts-reconfigyes
#哨兵sentinel实例运转的端口port36382daemonizenopidfile/var/run/redis-sentinel1.piddir/tmpsentinelmonitormymaster192.168.0.210263812sentinelauth-passmymaster"Redis明码"#指定多少毫秒之后主节点没有应对哨兵sentinel此时哨兵客观上以为主节点下线自动30秒sentineldown-after-millisecondsmymaster30000#指定了在出现failover主备切换时最多可以有多少个slave同时对新的master启动同步,这个数字越小,成功failover所需的期间就越长sentinelparallel-syncsmymaster1#缺点转移的超时期间sentinelfailover-timeoutmymaster180000sentineldeny-scripts-reconfigyes
appendonlyyesport26383appendfilenameappendonly.aofappendfsynceverysecauto-aof-rewrite-min-size10Mauto-aof-rewrite-percentage100requirepass"设置明码"replicaof192.168.0.21026381masterauth"设置明码"replica-read-onlyno
5.在两台主机上区分口头docker-compose装置启动命令
将docker-compose-redis.yml上行至/opt/software目录,这个目录可以自己选用,而后到目录下口头装置启动命令
docker-compose-fdocker-compose-redis.ymlup-d
[root@localhostsoftware]#docker-compose-fdocker-compose-redis.ymlup-d[+]Running10/10⠿sentinel1Pulled15.7s⠿redisSlave1Pulled15.7s⠿sentinelPulled3.4s⠿a2abf6c4d29dAlreadyexists0.0s⠿c7a4e4382001Pullcomplete0.4s⠿4044b9ba67c9Pullcomplete1.0s⠿c8388a79482fPullcomplete2.3s⠿413c8bb60be2Pullcomplete2.3s⠿1abfd3011519Pullcomplete2.4s⠿redisMasterPulled15.7sWARN[0015]Foundorphancontainers([mysql])forthisproject.Ifyouremovedorrenamedthisserviceinyourcomposefile,youcanrunthiscommandwiththe--remove-orphansflagtocleanitup.[+]Running4/4⠿Containerredis-sentinel-1Started0.5s⠿Containerredis-slave-1Started0.6s⠿Containerredis-masterStarted0.6s⠿Containerredis-sentinelStarted0.5s
经过dockerps命令可以看到redis和redis哨兵曾经装置并启动成功
[root@localhostsoftware]#dockerpsCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESf609322cabaaredis:latest"docker-entrypoint.s…"59secondsagoUp58seconds6379/tcp,0.0.0.0:26381->26381/tcp,:::26381->26381/tcpredis-master18b75828b5b7redis:latest"docker-entrypoint.s…"59secondsagoUp58seconds6379/tcp,0.0.0.0:36381->36381/tcp,:::36381->36381/tcpredis-sentinelf0f9a037c7aeredis:latest"docker-entrypoint.s…"59secondsagoUp58seconds6379/tcp,0.0.0.0:26382->26382/tcp,:::26382->26382/tcpredis-slave-1e51d3b0bc696redis:latest"docker-entrypoint.s…"59secondsagoUp58seconds6379/tcp,0.0.0.0:36382->36382/tcp,:::36382->36382/tcpredis-sentinel-1
6.经过命令检查redis哨兵形态
dockerexec-itf609322cabaabash
cd/usr/local/bin
./redis-cli-h127.0.0.1-p26381-a"明码"infoReplication#Replicationrole:masterconnected_slaves:2slave0:ip=172.18.0.1,port=26382,state=online,offset=700123,lag=0slave1:ip=192.168.0.195,port=26383,state=online,offset=700123,lag=0master_failover_state:no-failovermaster_replid:9ee56f68d25b71158544f6cfafc677822c401ec3master_replid2:0000000000000000000000000000000000000000master_repl_offset:700123second_repl_offset:-1repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:1repl_backlog_histlen:700123
root@fba6d91e10f6:/usr/local/bin#./redis-cli-h127.0.0.1-p36381INFOSentinel#Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster,status=ok,address=192.168.0.210:26381,slaves=2,sentinels=3
7.测试redis哨兵主备切换
dockerstop5541698b65a1
root@fba6d91e10f6:/usr/local/bin#./redis-cli-h127.0.0.1-p36381INFOSentinel#Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0sentinel_simulate_failure_flags:0master0:name=mymaster,status=ok,address=192.168.0.195:26383,slaves=3,sentinels=3
./redis-cli-h127.0.0.1-p26383-a"明码"infoReplicationWarning:Usingapasswith'-a'or'-u'optiononthecommandlineinterfacemaynotbesafe.#Replicationrole:masterconnected_slaves:1slave0:ip=192.168.0.210,port=26382,state=online,offset=894509,lag=0master_failover_state:no-failovermaster_replid:e9ebebdff0a5f7b7622c6c5fbfed7b1e44d84ae2master_replid2:9ee56f68d25b71158544f6cfafc677822c401ec3master_repl_offset:894509second_repl_offset:884279repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:846repl_backlog_histlen:893664
三、性能并测试Redis集群形式(RedisCluster)
Redis哨兵形式其实质还是主从复制,只不过加了哨兵启动智能主备切换,Redis集群形式(RedisCluster)才是真正意义上的集群部署,它可以将数据启动散布式分片存储,然而其只能存储到db0。
1.环境预备
咱们依然经常使用下面的Linux主机环境启动装置redis集群:在192.168.0.210上装置redisCluster1、redisCluster2、redisCluster3三台Reids服务;在在192.168.0.195上装置redisCluster4、redisCluster5、redisCluster6三台Reids服务。
2.预备Redis文件寄存目录
mkdir-p/opt/container/redis/cluster1/data/opt/container/redis/cluster1/conf/opt/container/redis/cluster1/logs/opt/container/redis/cluster2/data/opt/container/redis/cluster2/conf/opt/container/redis/cluster2/logs/opt/container/redis/cluster3/data/opt/container/redis/cluster3/conf/opt/container/redis/cluster3/logschmod-R777/opt/container/redis/cluster1/data/opt/container/redis/cluster1/conf/opt/container/redis/cluster1/logs/opt/container/redis/cluster2/data/opt/container/redis/cluster2/conf/opt/container/redis/cluster2/logs/opt/container/redis/cluster3/data/opt/container/redis/cluster3/conf/opt/container/redis/cluster3/logs
在192.168.0.195主机上口头Redis集群所需目录及权限命令
mkdir-p/opt/container/redis/cluster4/data/opt/container/redis/cluster4/conf/opt/container/redis/cluster4/logs/opt/container/redis/cluster5/data/opt/container/redis/cluster5/conf/opt/container/redis/cluster5/logs/opt/container/redis/cluster6/data/opt/container/redis/cluster6/conf/opt/container/redis/cluster6/logschmod-R777/opt/container/redis/cluster4/data/opt/container/redis/cluster4/conf/opt/container/redis/cluster4/logs/opt/container/redis/cluster5/data/opt/container/redis/cluster5/conf/opt/container/redis/cluster5/logs/opt/container/redis/cluster6/data/opt/container/redis/cluster6/conf/opt/container/redis/cluster6/logs
port12381cluster-enabledyes#启动集群形式cluster-config-filenodes-1.confcluster-node-timeout5000cluster-announce-ip192.168.0.210cluster-announce-port12381cluster-announce-bus-port22381bind0.0.0.0protected-modenoappendonlyyes#假设要设置明码须要参与如下性能:#(设置redis访问明码)requirepass明码#(设置集群节点间访问明码,跟下面分歧)masterauth明码
3.Redis主机docker-compose.yml文件
version:'3'services:##redis节点1性能redisCluster1:image:redis:latestrestart:alwayswork_mode:"host"container_name:redis-cluster1command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster1/data:/data-/opt/container/redis/cluster1/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster1/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"##redis节点2性能redisCluster2:image:redis:latestrestart:alwaysnetwork_mode:"host"container_name:redis-cluster2command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster2/data:/data-/opt/container/redis/cluster2/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster2/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"##redis节点3性能redisCluster3:image:redis:latestrestart:alwaysnetwork_mode:"host"container_name:redis-cluster3command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster3/data:/data-/opt/container/redis/cluster3/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster3/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"
version:'3'services:##redis节点4性能redisCluster4:image:redis:latestrestart:alwaysnetwork_mode:"host"container_name:redis-cluster4command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster4/data:/data-/opt/container/redis/cluster4/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster4/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"##redis节点5性能redisCluster5:image:redis:latestrestart:alwaysnetwork_mode:"host"container_name:redis-cluster5command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster5/data:/data-/opt/container/redis/cluster5/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster5/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"##redis节点6性能redisCluster6:image:redis:latestrestart:alwaysnetwork_mode:"host"container_name:redis-cluster6command:redis-server/usr/local/etc/redis/redis.confvolumes:##数据目录,要确保先创立好-/opt/container/redis/cluster6/data:/data-/opt/container/redis/cluster6/conf/redis.conf:/usr/local/etc/redis/redis.conf-/opt/container/redis/cluster6/logs:/logs-"/etc/localtime:/etc/localtime"-"/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone"
4.在两台主机上区分口头docker-compose装置启动命令
将docker-compose-redis-cluster.yml上行至/opt/software目录,这个目录可以自己选用,而后到目录下口头装置启动命令
docker-compose-fdocker-compose-redis-cluster.ymlup-d
[+]Running3/3⠿Containerredis-cluster3Started0.5s⠿Containerredis-cluster2Started0.4s⠿Containerredis-cluster1Started0.5s
经过dockerps命令可以看到redis和redis哨兵曾经装置并启动成功
[root@localhostsoftware]#dockerpsCONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES67a48962160dredis:latest"docker-entrypoint.s…"10secondsagoUp9seconds6379/tcp,0.0.0.0:52381->52381/tcp,:::52381->52381/tcpredis-cluster1b10f669691b3redis:latest"docker-entrypoint.s…"10secondsagoUp9seconds6379/tcp,0.0.0.0:52383->52383/tcp,:::52383->52383/tcpredis-cluster3d3899c9c01f6redis:latest"docker-entrypoint.s…"10secondsagoUp9seconds6379/tcp,0.0.0.0:52382->52382/tcp,:::52382->52382/tcpredis-cluster2
5.在两台主机上区分口头docker-compose装置启动命令
dockerexec-it67a48962160dbash
cd/usr/local/binroot@localhost:/usr/local/bin#./redis-cli--clustercreate192.168.0.210:12381192.168.0.210:12382192.168.0.210:12383192.168.0.195:12384192.168.0.195:12385192.168.0.195:12386--cluster-replicas1-a"明码"Warning:Usingapasswordwith'-a'or'-u'optiononthecommandlineinterfacemaynotbesafe.>>>Performinghashslotsallocationon6nodes...Master[0]->Slots0-5460Master[1]->Slots5461-10922Master[2]->Slots10923-16383Addingreplica192.168.0.195:12386to192.168.0.210:12381Addingreplica192.168.0.210:12383to192.168.0.195:12384Addingreplica192.168.0.195:12385to192.168.0.210:12382M:061d7b1bf2f93df7cbf261e47a7981800d636e63192.168.0.210:12381slots:[0-5460](5461slots)masterM:6cfbf9677ab802483ddc7cbb715fe770c8de884a192.168.0.210:12382slots:[10923-16383](5461slots)masterS:5afc2e7d2da8f9d7f7ad6e99d5ad04ffbf5bdfe5192.168.0.210:12383replicatesd54562615048044b43e368db71789829d76fa263M:d54562615048044b43e368db71789829d76fa263192.168.0.195:12384slots:[5461-10922](5462slots)masterS:9137f05da40ce173a975fa4a5e86e65b9d3fe4e3192.168.0.195:12385replicates6cfbf9677ab802483ddc7cbb715fe770c8de884aS:de04b0b6d207bd8653f2cb738cb47443c427810e192.168.0.195:12386replicates061d7b1bf2f93df7cbf261e47a7981800d636e63CanIsettheaboveconfiguration?(type'yes'toaccept):yes>>>Nodesconfigurationupdated>>>Assignadifferentconfigepochtoeachnode>>>SendingCLUSTERMEETmessagestojointheclusterWaitingfortheclustertojoin>>>PerformingClusterCheck(usingnode192.168.0.210:12381)M:061d7b1bf2f93df7cbf261e47a7981800d636e63192.168.0.210:12381slots:[0-5460](5461slots)master1additionalreplica(s)S:5afc2e7d2da8f9d7f7ad6e99d5ad04ffbf5bdfe5192.168.0.210:12383slots:(0slots)slavereplicatesd54562615048044b43e368db71789829d76fa263S:9137f05da40ce173a975fa4a5e86e65b9d3fe4e3192.168.0.195:12385slots:(0slots)slavereplicates6cfbf9677ab802483ddc7cbb715fe770c8de884aM:d54562615048044b43e368db71789829d76fa263192.168.0.195:12384slots:[5461-10922](5462slots)master1additionalreplica(s)S:de04b0b6d207bd8653f2cb738cb47443c427810e192.168.0.195:12386slots:(0slots)slavereplicates061d7b1bf2f93df7cbf261e47a7981800d636e63M:6cfbf9677ab802483ddc7cbb715fe770c8de884a192.168.0.210:12382slots:[10923-16383](5461slots)master1additionalreplica(s)[OK]Allnodesagreeaboutslotsconfiguration.>>>Checkforopenslots...>>>Checkslotscoverage...[OK]All16384slotscovered.
#检查集群信息clusterinfo#检查节点列表clusternodes
[root@localhostsoftware]#dockerexec-it407e3847371abashroot@localhost:/data#cd/usr/local/binroot@localhost:/usr/local/bin#redis-cli-c-h127.0.0.1-p12383-a"明码"127.0.0.1:12383>clusterinfocluster_state:okcluster_slots_assigned:16384cluster_slots_ok:16384cluster_slots_pfail:0cluster_slots_fail:0cluster_known_nodes:6cluster_size:3cluster_current_epoch:6cluster_my_epoch:4cluster_stats_messages_ping_sent:173cluster_stats_messages_pong_sent:163cluster_stats_messages_meet_sent:1cluster_stats_messages_sent:337cluster_stats_messages_ping_received:163cluster_stats_messages_pong_received:174cluster_stats_messages_received:337127.0.0.1:12383>clusternodes061d7b1bf2f93df7cbf261e47a7981800d636e63192.168.0.210:12381@22381master-016969523665411connected0-5460de04b0b6d207bd8653f2cb738cb47443c427810e192.168.0.195:12386@22386slave061d7b1bf2f93df7cbf261e47a7981800d636e63016969523665411connected5afc2e7d2da8f9d7f7ad6e99d5ad04ffbf5bdfe5192.168.0.210:12383@22383slaved54562615048044b43e368db71789829d76fa263016969523660394connected9137f05da40ce173a975fa4a5e86e65b9d3fe4e3192.168.0.195:12385@22385slave6cfbf9677ab802483ddc7cbb715fe770c8de884a016969523670432connected6cfbf9677ab802483ddc7cbb715fe770c8de884a192.168.0.210:12382@22382master-016969523655372connected10923-16383d54562615048044b43e368db71789829d76fa263192.168.0.195:12383@22384myself,master-016969523660004connected5461-10922
搭建Redis集群形式必定要留意,docker-compose性能必定要将network_mode设置为"host"形式,且不须要端口映射。假设创立集群时,不时显示期待衔接,那么须要性能防火墙,开放Redis集群端口。
用docker搭建一个高可用可扩展的服务支撑系统怎么做
一种方案为Haproxy+etcd+confd,采用松散式的组织结构,但各个组件之间的通讯是非常严密的,且扩展性更强,定制也更加灵活。
一、架构优势
约定由Haproxy+etcd+confd+Docker构建的基础服务平台简称“HECD” 架构,整合了多种开源组件,看似松散的结构,事实上已经是一个有机的整体,它们互相联系、互相作用,是Docker生态圈中最理想的组合之一,具有以下优势:
docker-compose 常用配置
1、docker-compose中容器设置上海时区 2、总是重启容器 3、端口映射 4、开启容器特权 5、使用Dockerfile的形式,重新bulid docker-compose up --build 6、目录挂载 ps: 修改crontab文件不能马上刷新到容器里,需要重启容器 7、容器启动失败,进入容器排查问题 进入容器不了,一下子就停止。 让容器不退出的方法: command:sleep 8、java环境 这里的11.11.11.11就是指定的ip 启动时输出: Creating network redis_hx_net with driver bridge Creating redis_redis_1 ... network_mode: host
免责声明:本文转载或采集自网络,版权归原作者所有。本网站刊发此文旨在传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及版权、内容等问题,请联系本网,我们将在第一时间删除。同时,本网站不对所刊发内容的准确性、真实性、完整性、及时性、原创性等进行保证,请读者仅作参考,并请自行核实相关内容。对于因使用或依赖本文内容所产生的任何直接或间接损失,本网站不承担任何责任。