redis是一个开源的内存数据结构存储系统,它可以用作数据库、缓存和消息代理,在分布式系统中,Redis集群可以提高数据的可用性和扩展性,本文将介绍如何使用docker部署Redis集群。,1、安装Docker:请参考Docker官方文档(https://docs.docker.com/engine/install/)安装适合您操作系统的Docker版本。,,2、拉取Redis镜像:在命令行中执行以下命令,拉取官方提供的Redis镜像。,docker pull redis,1、创建Redis配置文件:在本地创建一个名为
redis.conf
的文件,添加以下内容:,bind 0.0.0.0,protected-mode no,port 6379,tcp-backlog 511,timeout 0,tcp-keepalive 300,daemonize no,supervised no,pidfile /var/run/redis_6379.pid,loglevel notice,logfile “”,databases 16,always-show-logo yes,save 900 1,save 300 10,save 60 10000,stop-writes-on-bgsave-error yes,rdbcompression yes,,rdbchecksum yes,dbfilename dump.rdb,dir ./,slave-serve-stale-data yes,slave-read-only yes,repl-diskless-sync no,repl-disable-tcp-nodelay no,slave-priority 100,lazyfree-lazy-eviction no,lazyfree-lazy-expire no,lazyfree-lazy-server-del no,slave-lazy-flush no,appendonly no,appendfilename “appendonly.aof”,appendfsync everysec,no-appendfsync-on-rewrite no,auto-aof-rewrite-percentage 100,auto-aof-rewrite-min-size 64mb,aof-load-truncated yes,aof-use-rdb-preamble no,lua-time-limit 5000,,slowlog-log-slower-than 100000,slowlog-max-len 128,latency-monitor-threshold 0,notify-keyspace-events “”,hash-max-ziplist-entries 512,hash-max-ziplist-value 64,list-max-ziplist-size -2,list-compress-depth 0,set-max-intset-entries 512,zset-max-ziplist-entries 128,zset-max-ziplist-value 64,hll-sparse-max-bytes 3000,activerehashing yes,client-output-buffer-limit normal 0 0 0,client-output-buffer-limit slave 256MB 64MB 60,client-output-bufferLimit minclients 1 maxclients autodeflate yes,hz 10,aofrewriteincrementalfsync yes,2、启动Redis单节点:在命令行中执行以下命令,启动Redis单节点。,docker run –name myredis -p 6379:6379 -v $(pwd)/redis.conf:/usr/local/etc/redis/redis.conf –rm redis:latest redis-server /usr/local/etc/redis/redis.conf –daemonize yes –port 6379 –bind 0.0.0.0 –protected-mode no –requirepass yourpassword –tlsdisable –tlsauth cacert.crt –tlsciphers HIGH:!aNULL:!MD5 –dbfilename dump.rdb –dir ./ –appendfilename “appendonly.aof” –appendfsync everysec –save “900 1” –save “300 10” –save “60 10000” –slaveof no –pidfile /var/run/redis_6379.pid –loglevel notice –logfile “” –databases 16 –always-show-logo yes –saveinfo returnerrors yes –slaveservesocket port=6380 –slavereadfrom socket=localhost:6379 –slavepriority priority=10 –slavepreservemaster yes –slavepreferredip srcip=127.127.1.1 –slavepreferredip srcip=::ffff:127.127.1.1 –slavepreferredip srcip=::ffff:127.127.1.2 –slavelistenip 127.127.1.156 –slavedns server=8.8.8.8,server=8.8.4.4 –dir “$(pwd)/6379_data” –replicaof no –cluster create IP=$(hostname):6380 IP=$(hostname):6381 IP=$(hostname):6382 IP=$(hostname):6383 IP=$(hostname):6384 IP=$(hostname):6385 IP=$(hostname):6386 IP=$(hostname):6387 IP=$(hostname):6388 IP=$(hostname):6389 –cluster-replicas 1 @masterip@@replicaip@@masterport@@replicaport@@masteralias@@replicaalias@ &>/dev/null & echo $! > cluster_id & exec cat cluster_id & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 & exec sleep infinity & exec tail \$(cat cluster_id) & exec kill %1 &exec exit;&exec cat cluster_id;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_id);&exec kill %1;&exec sleep infinity;&exec tail \$(cat cluster_server);–sentinel monitor mymaster mastername yourmastername host yourmasterip port yourmasterport quorum downafterseconds failovertimeout connectedslavesinsentinelstatesentinelfailover newstatesentinelupdatescript filesentinelupdatescript filesentinelparallelstartsec
redis docker 集群
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《redis docker 集群》
文章链接:https://zhuji.vsping.com/480972.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
文章名称:《redis docker 集群》
文章链接:https://zhuji.vsping.com/480972.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。