yum install gcc-c++ -y
node
redis_version=5.0.5 wget http://download.redis.io/releases/redis-${redis_version}.tar.gz tar xzf redis-${redis_version}.tar.gz mv ./redis-${redis_version} /usr/local/redis cd /usr/local/redis make && make install
/usr/local/redis/src/redis-server /usr/local/redis/redis.conf &c++
ps -ef | grep redis
redis
/usr/local/redis/src/redis-cliruby
/usr/local/redis/src/redis-cli shutdownapp
或者
pkill /usr/local/redis/src/redis-serverspa
或者插件
kill + 進程號code
daemonize no 改成 daemonize yes protected-mode yes 改成 protected-mode no 註釋 bind 127.0.0.1
mkdir -p /usr/local/redis-cluster mkdir -p {8001,8002,8003,8004,8005,8006}
ps:要複製6份cp /usr/local/redis/redis.conf /usr/local/redis-cluster/8001/
server
port 8001 #端口 cluster-enabled yes #啓用集羣模式 cluster-config-file nodes.conf cluster-node-timeout 15000 #超時時間 appendonly yes daemonize yes #後臺運行 protected-mode no #非保護模式 pidfile /var/run/redis_8001.pid bind 127.0.0.1(去掉bind綁定訪問ip信息) cluster-config-file nodes-8001.conf(集羣節點信息文件,這裏800x最好和port對應上)
ps: 先修改一個 而後用sed命令修改
命令以下:sed -i s/8001/8002/g
/usr/local/redis-cluster/8001/redis.conf進程
/usr/local/redis/src/redis-server /usr/local/redis-cluster/8001/redis.conf /usr/local/redis/src/redis-server /usr/local/redis-cluster/8002/redis.conf /usr/local/redis/src/redis-server /usr/local/redis-cluster/8003/redis.conf /usr/local/redis/src/redis-server /usr/local/redis-cluster/8004/redis.conf /usr/local/redis/src/redis-server /usr/local/redis-cluster/8005/redis.conf /usr/local/redis/src/redis-server /usr/local/redis-cluster/8006/redis.conf
ps -ef | grep redis
/usr/local/redis/src/redis-cli --cluster create --cluster-replicas 1 172.17.0.5:8001 172.17.0.5:8002 172.17.0.5:8003 172.17.0.5:8004 172.17.0.5:8005 172.17.0.5:8006
ps:期間點擊yes
該圖爲網上圖片
到此集羣搭建完畢!!!
./redis-cli -c -a xxx -h 192.168.5.100 -p 8001
提示:-a訪問服務端密碼,-c表示集羣模式,指定ip地址和端口號
進入以後額外命令
進行驗證: cluster info(查看集羣信息)、cluster nodes(查看節點列表)
/usr/local/redis/src/redis-cli -a xxx -c -h 192.168.0.60 -p 8001 shutdown
集羣命令須要一個一個關