redis installation from the main cluster Sentinel docker

Install redis official documents

  • docker run -d --net host -v /opt/myconfig/redis/redis.conf:/usr/local/etc/redis/redis.conf --name redis redis redis-server /usr/local/etc/redis/redis.conf

    • Using cluster network with --net host host mode
    • With host mode do not have to specify the port mapping. Otherwise it will errorWARNING: Published ports are discarded when using host network mode
  • redis.conf official documents

Availability master-slave Sentinel

Master-slave configuration

  • Minimum configuration replicaof masterip masterport
  • Configured separately from the main cluster is not supported when changed cluster-enabled no
  • Disposed in a cluster from the master to specify the number of slaves through --cluster-replicas when creating a cluster

Master-slave management

  • View from the main information

    • redis-cli -h 127.0.0.1 -p 6379 info replication
  • Slave Configuration

    • slaveof MASTER_IP MASTER_PORT

Sentinel structures selected from a host machine

Build Sentry System
  • Under redis installation package contains the system does not go back down, do not be a
  • Minimum configuration file
#指示 Sentinel 去监视一个名为 mymaster 的主服务器, 这个主服务器的 IP 地址为 127.0.0.1 , 端口号为 6379 ,  
# 这个主服务器判断为失效至少需要 2 个 Sentinel 同意 (只要同意 Sentinel 的数量不达标,自动故障迁移就不会执行)
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
daemonize yes
  • Start command redis-server /path/to/sentinel.conf --sentinel
Sentry System Management
  • Enter the default port 26379 can set their own redis-cli -p 26379
  • Management Command official documents

Cluster (sharing data between multiple nodes) official documents

Build a cluster redis5

  • Minimum configuration file
port 7000  
cluster-enabled yes
#设定保存节点配置文件的路径  由 Redis 集群在启动时创建, 并自动进行更新,无须人为修改
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes  
  • Cluster creation command
    redis-cli --cluster create 节点1 节点2 ...... --cluster-replicas 2

    • --cluster-replicas 2 is provided with two master slave
    • [OK] All 16384 slots covered A description of all the slots available to prove the point to build a successful centralization
  • redis cluster does not support port mapping under docker to specify --net host

Currently Redis Cluster does not support NATted environments and in general environments where IP addresses or TCP ports are remapped.
In order to make Docker compatible with Redis Cluster you need to use the host networking mode of Docker. 
Please check the --net=host option in the Docker documentation for more information.

Cluster Management

Node Manager
  • Show all the nodes

    • redis-cli -h 127.0.0.1 -p 6379 cluster nodes

      • myself refers to the current node
  • Add a node

    • Adding a dummy node and the master node default data piece

      • redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000

        • A new address for the first node to the second address is within any cluster
        • To address successfully added unify all else though because the same cluster can not be recognized as a net external / internal network
    • Increase from the node

      • redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 --cluster-slave --cluster-master-id 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e
      • Do not specify a primary node increases from a

        • redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 --cluster-slave
        • redis 127.0.0.1:7006> cluster replicate 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e In operation the node
  • Delete Node

    • redis-cli --cluster del-node 127.0.0.1:7000 ``

      • The first node is a random node in the cluster
      • The second parameter is the id you want to delete a node in the cluster
Slot management point
  • Check Point groove

    • redis-cli --cluster check 127.0.0.1:7000
      * Re slice grooves point
    • redis-cli --cluster reshard 127.0.0.1:7000

      • [OK] All 16384 slots covered. DESCRIPTION point successfully fragmented groove

Guess you like

Origin www.cnblogs.com/eatandsleep/p/12219152.html