
# Redis集群部署
1. 服务信息如下：
   表1服务信息5 
   | 服务名   | 服务器        | 安装目录             | 端口             | 密码           |
   |:---|:---|:---|:---|:---|
   | redis | 10.190.x.x | /app/redis-6.2.6 | 6379、6380、6381 | \*\*\*\*\*\* |
      
   
2. 安装redis
   1. 准备安装包
      ```
      cd /app
      wget https://download.redis.io/releases/redis-6.2.6.tar.gz
      tar -zxvf redis-6.2.6.tar.gz
      cd /app/redis-6.2.6
      ```
      
   
   2. 编译
      ```
      yum -y install gcc-c++
      yum -y install make
      ##首先进入deps目录，编译Redis依赖库
      cd deps/
      make -j4 hiredis lua jemalloc linenoise 
      ##再进行编译Redis
      cd ../redis-6.2.6/
      yum provides */ld
      yum install -y  binutils-2.31.1-13.h3.eulerosv2r8.aarch64
      [root@host-172-16-1-173 redis-6.2.6]# which ld
      /usr/bin/ld
      make -j4
      make install
      ```
      
   
   3. 修改6个实例的配置文件，端口分别为7000、7001、7002、7003、7004、7005
      ```
      cp redis.conf redis-7000.conf
      vim  redis-7000.conf
      bind 0.0.0.0
      protected-mode no
      port 7000
      daemonize yes   #守护进程
      pidfile ./redis_7000.pid
      Loglevel warning
      logfile ./redis-7000.log
      dbfilename "dump-7000.rdb"
      maxmemory 8GB
      maxmemory-policy allkeys-lru
      appendonly yes  #持久化
      cluster-enabled yes
      cluster-config-file "node-7000.conf"
      activedefrag yes #碎片整理
      masterauth "redis123"
      ##user default on 
      requirepass ****** #服务连接密码
      Ignore-warnings ARM64-COW-BUG   #配置ARM64内核bug问题选项
      ```
      
   
   4. 三节点分别启动服务
      ```
      nohup ./src/redis-server redis-7000.conf &
      nohup ./src/redis-server redis-7001.conf &
      nohup ./src/redis-server redis-7002.conf &
      nohup ./src/redis-server redis-7003.conf &
      nohup ./src/redis-server redis-7004.conf &
      nohup ./src/redis-server redis-7005.conf &
       cd  /opt/redis/redis-6.2.1/src/
      ./redis-cli --cluster create node1:7001 node2:7003 node3:7005 node2:7002 node3:7004 node1:7000 --cluster-replicas 1
      [root@zh-prod-redis-1 src]# ./redis-cli --cluster create 172.16.19.25:7001 172.16.19.26:7003 172.16.19.18:7005 172.16.19.26:7002 172.16.19.18:7004 172.16.19.25:7000  --cluster-replicas 1 -a 'redis123'
      [OK] All 16384 slots covered.
      ```
      
   
   5. 部署成redis一主两从三哨兵的集群模式
      ```
      mkdir /app/redis-5.0.5
       mkdir /app/redis-5.0.5/logs/
      [root@host-172-16-1-173 conf]# ls /app/redis-5.0.5
      conf  dump.rdb  logs  start.sh  stop.sh
      [root@host-172-16-1-173 conf]# ls
      redis.conf  sentinel1.conf  sentinel2.conf  sentinel3.conf  slave1.conf  slave2.conf
      ```
      
   
   6. 启动、停止
      ```
      ./start.sh
      ./stop.sh
      ```
      
    
 
