這是本文件的舊版!


CentOS7 安裝 Redis5

  • CentOS7 from PVE6 CT-template
  • 因為 EPEL 的 redis 版本只到 3 , 發現透過 IUS repo 可以安裝版本 4 或 5
  • 安裝
    yum install -y https://repo.ius.io/ius-release-el7.rpm
    yum install redis5
  • 啟動
    systemctl enable redis
    systemctl start redis
  • 檢查 redis 服務版本狀態
    redis-cli info server

    呈現結果如下:<xtermrtf># Server

redis_version:5.0.9 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:977de8e50f63afe8 redis_mode:standalone os:Linux 3.10.0-1127.13.1.el7.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll atomicvar_api:atomic-builtin gcc_version:4.8.5 process_id:1869 run_id:e0ff9930e953b9fd6fcc9cb155402a79751539e8 tcp_port:6379 uptime_in_seconds:50 uptime_in_days:0 hz:10 configured_hz:10 lru_clock:16610448 executable:/usr/bin/redis-server config_file:/etc/redis.conf </xtermrtf>

啟動時 redis.log 出現以下需要修正的事項
  1. The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 修正語法
    vi /etc/sysctl.conf
    :
    net.core.somaxconn=1024
  2. 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. 修正語法
    vi /etc/sysctl.conf
    :
    vm.overcommit_memory=1
  3. 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. 修正語法
    vi /etc/rc.d/rc.local
    :
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    chmod a+x /etc/rc.d/rc.local
  4. 重新開機讓設定生效
  • 觀察 redis 服務運作狀態(使用記憶體/連結數..)
    redis-cli --stat

    顯示訊息大概會如下<xtermrtf>

——- data —— ——————— load ——————– - child - keys mem clients blocked requests connections 505 1.35M 1 0 8 (+0) 2 505 1.35M 1 0 9 (+1) 2 505 1.35M 1 0 10 (+1) 2 505 1.35M 1 0 11 (+1) 2 505 1.35M 1 0 12 (+1) 2 522 1.83M 2 0 135 (+123) 3 954 2.87M 2 0 1400 (+1265) 3 961 2.92M 3 0 1486 (+86) 4 961 2.92M 3 0 1487 (+1) 4 961 2.94M 4 0 1530 (+43) 5 961 2.96M 5 0 1573 (+43) 6 961 2.96M 5 0 1574 (+1) 6 963 3.06M 6 0 2120 (+546) 7 1060 3.43M 7 0 2530 (+410) 8 1060 3.43M 7 0 2531 (+1) 8 1060 3.49M 8 0 2583 (+52) 9 1060 3.45M 8 0 2601 (+18) 9 1060 3.45M 8 0 2645 (+44) 9 1060 3.45M 8 0 2689 (+44) 9 1060 3.45M 8 0 2690 (+1) 9 </xtermrtf>

  • 參考應用 : Wordpress Plugin - W3 Total Cache
    • 需要安裝 php-redis 套件
      yum install php-redis

      <xtermrtf>

Dependencies Resolved

Package Arch Version Repository Size

Installing: php-pecl-redis5 x86_64 5.3.0-1.el7.remi.7.3 remi-php73 239 k Installing for dependencies: liblzf x86_64 3.6-7.el7 epel 22 k libzstd x86_64 1.4.5-3.el7 epel 331 k php-pecl-igbinary x86_64 3.1.2-1.el7.remi.7.3 remi-php73 99 k php-pecl-msgpack x86_64 2.1.0-1.el7.remi.7.3 remi-php73 58 k

Transaction Summary

Install 1 Package (+4 Dependent packages) </xtermrtf>

  • tech/centos7-redis.1593739239.txt.gz
  • 上一次變更: 2020/07/03 09:20
  • jonathan_tsai