重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要介绍redis cluster如何安装,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
目前成都创新互联已为上1000家的企业提供了网站建设、域名、网页空间、成都网站托管、企业网站设计、大丰网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
1.安装redis
tar xzf redis-3.0.1.tar.gz
cd redis-3.0.1
make
mkdir cluster
mkdir /etc/redis mkdir -p /data/store/redis
mkdir -p /data/outputs/logs/redis
在两边都要走
2,配置redis
[root@slave2 redis-3.0.0]# vim redis.conf //解压的根目录,有redis.conf,做以下修改 port 6379 pidfile redis-6379.pid dbfilename dump-6379.rdb appendfilename "appendonly-6379.aof" cluster-config-file nodes-6379.conf cluster-enabled yes cluster-node-timeout 5000 appendonly yes dir /data/store/redis/
cp redis.conf /etc/redis/redis-6379.conf
cp redis.conf /etc/redis/redis-6380.conf
cp redis.conf /etc/redis/redis-6381.conf
sed -i "s/6379/6380/g" /etc/redis/redis-6380.conf
sed -i "s/6379/6381/g" /etc/redis/redis-6381.conf
scp /etc/redis/redis-6379.conf 10.1.10.223:/etc/redis/redis-6379.conf scp /etc/redis/redis-6380.conf 10.1.10.223:/etc/redis/redis-6380.conf
scp /etc/redis/redis-6381.conf 10.1.10.223:/etc/redis/redis-6381.conf 3启动 ./redis-server /etc/redis/redis-6379.conf > /data/outputs/logs/redis/redis-6379.log 2>&1 & ./redis-server /etc/redis/redis-6380.conf > /data/outputs/logs/redis/redis-6380.log 2>&1 &
./redis-server /etc/redis/redis-6381.conf > /data/outputs/logs/redis/redis-6381.log 2>&1 & 两边都启动
netstat -tpnl |grep redis tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 18201/./redis-serve tcp 0 0 0.0.0.0:6380 0.0.0.0:* LISTEN 18204/./redis-serve tcp 0 0 0.0.0.0:6381 0.0.0.0:* LISTEN 18207/./redis-serve tcp 0 0 0.0.0.0:16379 0.0.0.0:* LISTEN 18201/./redis-serve tcp 0 0 0.0.0.0:16380 0.0.0.0:* LISTEN 18204/./redis-serve tcp 0 0 0.0.0.0:16381 0.0.0.0:* LISTEN 18207/./redis-serve tcp 0 0 :::6379 :::* LISTEN 18201/./redis-serve tcp 0 0 :::6380 :::* LISTEN 18204/./redis-serve tcp 0 0 :::6381 :::* LISTEN 18207/./redis-serve tcp 0 0 :::16379 :::* LISTEN 18201/./redis-serve tcp 0 0 :::16380 :::* LISTEN 18204/./redis-serve tcp 0 0 :::16381 :::* LISTEN 18207/./redis-serve
ll /data/store/redis/ 4安装ruby,rubygem yum -y install gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-d yum -y install ruby rubygems 替换掉源 gem source -l gem sources --remove gem sources -a gem install redis --version 3.0.1 5 建立cluster
redis-trib.rb create --replicas 1 10.1.10.90:6379 10.1.10.90:6380 10.1.10.90:6381 10.1.10.223:6379 10.1.10.223:6380 10.1.10.223:6381 >>> Creating cluster Connecting to node 10.1.10.90:6379: OK Connecting to node 10.1.10.90:6380: OK Connecting to node 10.1.10.90:6381: OK Connecting to node 10.1.10.223:6379: OK Connecting to node 10.1.10.223:6380: OK Connecting to node 10.1.10.223:6381: OK >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 10.1.10.223:6379 10.1.10.90:6379 10.1.10.223:6380 Adding replica 10.1.10.90:6380 to 10.1.10.223:6379 Adding replica 10.1.10.223:6381 to 10.1.10.90:6379 Adding replica 10.1.10.90:6381 to 10.1.10.223:6380 M: 365b339b2585ca27fd5ba4383e626bf1ffa14bff 10.1.10.90:6379 slots:5461-10922 (5462 slots) master S: cecc5521194616ce1175000de91a40d514993250 10.1.10.90:6380 replicates 7b0ea5f49bb33a74cdb956febed94bda260c1ad9 S: ac87e0b7fee4d54c0cf5af6b579f9256f66cd35d 10.1.10.90:6381 replicates e0063b5583add6b18b7c2d93cae070fcf5f9e176 M: 7b0ea5f49bb33a74cdb956febed94bda260c1ad9 10.1.10.223:6379 slots:0-5460 (5461 slots) master M: e0063b5583add6b18b7c2d93cae070fcf5f9e176 10.1.10.223:6380 slots:10923-16383 (5461 slots) master S: a64d338f828698b207835a5a3a83c78ffd44a101 10.1.10.223:6381 replicates 365b339b2585ca27fd5ba4383e626bf1ffa14bff Can I set the above configuration? (type 'yes' to accept): yes >>> Nodes configuration updated >>> Assign a different config epoch to each node >>> Sending CLUSTER MEET messages to join the cluster Waiting for the cluster to join... >>> Performing Cluster Check (using node 10.1.10.90:6379) M: 365b339b2585ca27fd5ba4383e626bf1ffa14bff 10.1.10.90:6379 slots:5461-10922 (5462 slots) master M: cecc5521194616ce1175000de91a40d514993250 10.1.10.90:6380 slots: (0 slots) master replicates 7b0ea5f49bb33a74cdb956febed94bda260c1ad9 M: ac87e0b7fee4d54c0cf5af6b579f9256f66cd35d 10.1.10.90:6381 slots: (0 slots) master replicates e0063b5583add6b18b7c2d93cae070fcf5f9e176 M: 7b0ea5f49bb33a74cdb956febed94bda260c1ad9 10.1.10.223:6379 slots:0-5460 (5461 slots) master M: e0063b5583add6b18b7c2d93cae070fcf5f9e176 10.1.10.223:6380 slots:10923-16383 (5461 slots) master M: a64d338f828698b207835a5a3a83c78ffd44a101 10.1.10.223:6381 slots: (0 slots) master replicates 365b339b2585ca27fd5ba4383e626bf1ffa14bff [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
以上是“redis cluster如何安装”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!