主要参考 cluster-tutorial
查看端口占用
netstat -tunlp创建集群路径以及端口
拷贝原有的【redis.conf】,并更改以下配置
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
daemonize yes
注释原有的port
“#port 6379”执行脚本【dump.sh】
for((i=0;i<6;i++))
do
port= ((7000+i))mkdir−p ( ( 7000 + i ) ) m k d i r − p port
echo “port port"> p o r t "> {port}/redis.conf
cat redis.conf >> ${port}/redis.conf
done
node.conf 系统可以不用做,系统自动创建
后续参见:
cluster-tutorial 启动集群服务测试 test_cluster.py
from rediscluster import StrictRedisCluster
startup_nodes = [{“host”: “127.0.0.1”, “port”: “7000”},
{“host”: “127.0.0.1”, “port”: “7001”} ]
rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
rc.set(“whoisyoudad”, “huzhichao”)
print(rc.get(“whoisyoudad”))
centos
centos 版本存在两个问题:ruby,版本低,以及ssh版本低,导致服务创建集群。
- open ssh 安装
tar -xf openssl-1.0.2n.tar.gz
./config -fPIC –prefix=/usr/local/ –openssldir=/usr/local/ssl/ –libdir=lib shared zlib-dynamic
make && make install
cp /lib64/libssl* /lib64/sslbak/ && cp /lib64/crypto* /lib64/sslbak/
cp -rf /usr/local/lib/libcrypto.* /lib64/ && cp -rf /usr/local/lib/libssl.* /lib64/
cp libcrypto.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/libcrypto.pc
cp libssl.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/libssl.pc
cp openssl.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/openssl.pc
- ruby安装
下载: ww.ruby-lang.org/en/downloads/
sudo
./configure
make ; make install