差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:centos7-redis [2020/07/03 09:07] – 還原成舊版 (2020/07/02 14:28) jonathan_tsaitech:centos7-redis [2021/03/26 15:42] (目前版本) jonathan
行 1: 行 1:
 +====== CentOS7/Debian10 安裝 Redis5 ======
 +
 +  * CentOS7 from PVE6 CT-template
 +    * 因為 EPEL 的 redis 版本只到 3 , 發現透過 IUS repo 可以安裝版本 4 或 5 
 +  * Debian10 from PVE6 TurnKey CT-template
 +
 +===== CentOS7 安裝啟動程序 =====
 +  * 安裝 <cli>
 +yum install -y https://repo.ius.io/ius-release-el7.rpm
 +yum install redis5
 +</cli>
 +  * 啟動 <cli>
 +systemctl enable redis
 +systemctl start redis
 +</cli>
 +
 +===== Debian10 安裝啟動程序 =====
 +  * 安裝 <cli>
 +sudo apt update
 +sudo apt install redis-server
 +</cli>
 +  * 啟動 : 在上面的安裝後就會自動設定啟動程序
 +
 +===== Redis 啟動檢查 =====
 +  * 檢查 redis 服務版本狀態 <code sh>
 +redis-cli info server
 +</code>呈現結果如下:<cli># 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
 +</cli>
 +
 +<note warning>
 +**啟動時 redis.log 出現以下需要修正的事項**
 +  - The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 修正語法<code sh>
 +vi /etc/sysctl.conf</code><file>
 +:
 +net.core.somaxconn=1024
 +</file>
 +  - 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. 修正語法<code sh>
 +vi /etc/sysctl.conf</code><file>
 +:
 +vm.overcommit_memory=1
 +</file>
 +  - 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. 修正語法<code sh>
 +vi /etc/rc.d/rc.local</code><file>
 +:
 +echo never > /sys/kernel/mm/transparent_hugepage/enabled
 +</file><code sh>
 +chmod a+x /etc/rc.d/rc.local
 +</code>
 +  - 重新開機讓設定生效
 +</note>
 +  * 觀察 redis 服務運作狀態(使用記憶體/連結數..) <code sh>
 +redis-cli --stat
 +</code>顯示訊息大概會如下<cli>
 +------- data ------ --------------------- load -------------------- - child -
 +keys       mem      clients blocked requests            connections
 +505        1.35M    1             8 (+0)              2
 +505        1.35M    1             9 (+1)              2
 +505        1.35M    1             10 (+1)             2
 +505        1.35M    1             11 (+1)             2
 +505        1.35M    1             12 (+1)             2
 +522        1.83M    2             135 (+123)          3
 +954        2.87M    2             1400 (+1265)        3
 +961        2.92M    3             1486 (+86)          4
 +961        2.92M    3             1487 (+1)           4
 +961        2.94M    4             1530 (+43)          5
 +961        2.96M    5             1573 (+43)          6
 +961        2.96M    5             1574 (+1)           6
 +963        3.06M    6             2120 (+546)         7
 +1060       3.43M    7             2530 (+410)         8
 +1060       3.43M    7             2531 (+1)           8
 +1060       3.49M    8             2583 (+52)          9
 +1060       3.45M    8             2601 (+18)          9
 +1060       3.45M    8             2645 (+44)          9
 +1060       3.45M    8             2689 (+44)          9
 +1060       3.45M    8             2690 (+1)           9
 +</cli>
 +
 +  * 參考應用 : Wordpress Plugin - [[https://wordpress.org/plugins/w3-total-cache/|W3 Total Cache]]
 +    * 需要安裝 php-redis 套件<code sh>
 +yum install php-redis
 +</code><cli>
 +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)
 +</cli>
 +
 +===== 參考網址 =====
 +  * https://blog.yowko.com/yum-install-redis5/
 +  * https://blog.csdn.net/mawming/article/details/51952411
 +  * https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-debian-10
 +
 +{{tag>memdb redis debian centos}}