CentOS 1908 配置 Redis 5.0.7 集群 一(单节点)

CentOS 下载:http://mirrors.aliyun.com/centos/

Redis:http://download.redis.io/releases/

CentOS 1908 配置 Redis 5.0.7 集群 二(主从复制)

CentOS 1908 配置 Redis 5.0.7 集群 三(哨兵模式)


  1. 下载 Redis 5.0.7:
    wget http://download.redis.io/releases/redis-5.0.7.tar.gz
  2. 解压 Redis:
    tar -zxvf redis-5.0.7.tar.gz
  3. 安装 gcc:
    yum -y install gcc
    如未安装,可能出现如下问题:
    /bin/sh: cc: command not found
  4. 安装 tcl:
    yum -y install tcl
    如未安装,可能出现如下问题:
    You need tcl 8.5 or newer in order to run the Redis test
    
  5. 进入 Redis 文件夹:
    [root@192 ~]# cd redis-5.0.7/
    [root@192 redis-5.0.7]# 
  6. 编译:
    make
    编译时如果出现:
    zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
     #include <jemalloc/jemalloc.h>
    使用以下命令编译:
    make MALLOC=libc
  7. 编译测试:
    make test
  8. 测试安装没有问题后,进行编译安装:
    make install
  9. 启动 Redis:
    [root@192 redis-5.0.7]# src/redis-server redis.conf 
    57110:C 13 Jan 2020 21:31:05.240 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    57110:C 13 Jan 2020 21:31:05.240 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=57110, just started
    57110:C 13 Jan 2020 21:31:05.240 # Configuration loaded
    57110:M 13 Jan 2020 21:31:05.241 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
      .-`` .-```.  ```\/    _.,_ ''-._                                   
     (    '      ,       .-`  | `,    )     Running in standalone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 57110
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    57110:M 13 Jan 2020 21:31:05.243 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    57110:M 13 Jan 2020 21:31:05.243 # Server initialized
    57110:M 13 Jan 2020 21:31:05.243 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    57110:M 13 Jan 2020 21:31:05.243 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    57110:M 13 Jan 2020 21:31:05.244 * Ready to accept connections
    
    Ctrl + C 停止。
     
  10. 打开 CentOS 的 Redis 端口:
    firewall-cmd --zone=public --add-port=6379/tcp --permanent
  11. 重新加载防火墙:
    firewall-cmd --reload
  12. 查看已开放的端口和服务:
    firewall-cmd --list-all
    [root@192 ~]# firewall-cmd --list-all
    public (active)
      target: default
      icmp-block-inversion: no
      interfaces: ens33 ens34
      sources: 
      services: dhcpv6-client ssh
      ports: 6379/tcp
      protocols: 
      masquerade: no
      forward-ports: 
      source-ports: 
      icmp-blocks: 
      rich rules: 
    	
    [root@192 ~]# 
    
  13. 开放远程连接:
    修改 redis.conf:
    # 注释 bind,如下:
    # bind 127.0.0.1
    
    # 修改 protected-mode 为 no,如下:
    protected-mode no
    修改完成,重启 Redis。
     
  14. 远程连接:

     
  15. 如要开启后台运行,需要在 redis.conf 中将 daemonize 设置为 yes。
发布了94 篇原创文章 · 获赞 32 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/103964264