Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

CentOS 7.0 安裝 Redis 3.2.1 與常見問題

安裝與啟動

本文以 CentOS 7.0 與 Redis 3.2.1 為例。下載並解壓後,在原始碼目錄執行 make 即可完成編譯。

wget https://download.redis.io/releases/redis-3.2.1.tar.gz
tar xzf redis-3.2.1.tar.gz
cd redis-3.2.1
make

啟動時建議明確指定設定檔,否則修改 redis.conf 可能不會生效。

./src/redis-server ../redis.conf
CentOS 7.0 安裝 Redis 3.2.1 與常見問題

常見啟動警告

若出現 overcommit_memory 警告,可設定 vm.overcommit_memory = 1。若 TCP backlog 過低,可調整 somaxconn。

echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
echo 511 > /proc/sys/net/core/somaxconn

外部訪問與 protected mode

Redis 3.2 之後引入 protected mode。若未設定 bind 或密碼,預設只允許本機回環位址存取。

CentOS 7.0 安裝 Redis 3.2.1 與常見問題

若要讓外部主機連線,可設定 bind 位址與 requirepass,或依需求關閉 protected mode。生產環境強烈建議設定密碼與防火牆。

CentOS 7.0 安裝 Redis 3.2.1 與常見問題CentOS 7.0 安裝 Redis 3.2.1 與常見問題

常用檢查指令

ps -ef | grep redis
netstat -ano | grep 6379
./src/redis-cli
./src/redis-cli -a yourpassword
CentOS 7.0 安裝 Redis 3.2.1 與常見問題

CentOS 7 可使用 systemctl stop firewalld 與 systemctl disable firewalld 管理防火牆。

Copyright © Linux教程網 All Rights Reserved