In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Without introducing the details, just start the installation.
Prepare the environment:
Using two centos servers, three instances are deployed on each machine, and the cluster is composed of three master nodes and three slave nodes: the first 192.168.1.107rider 7000 192.168.1.107purl 7001 192.168.1.107purl 7002 the second 192.168.1.108purl 7003 192.168.1.108purl 7004 192.168.1.108purl 7005
Installation configuration:
192.168.1.107 server
# yum-y install gcc zlib ruby rubygems#gem install redis#wget http://download.redis.io/releases/redis-3.2.8.tar.gz#tar-zxvf redis-3.2.8.tar.gz#cd redis-3.2.8#make & & make install copy redis-trib.rb to / usr/local/bin directory # cp src/redis-trib.rb / usr/local/bin/ # mkdir-p / data/redis/ {conf,data Logs} # cp redis.conf / data/redis/conf/redis-7000.conf # cp redis.conf / data/redis/conf/redis-7001.conf # cp redis.conf / data/redis/conf/redis-7002.conf
The configuration is as follows (redis-7000.conf is the same as other types):
Daemonize yes pidfile / data/redis/data/redis-7000.pid port 7000 bind 192.168.1.107 unixsocket / data/redis/data/redis-7000.sock unixsocketperm 700 timeout 300 loglevel verbose logfile / data/redis/logs/redis-7000.log databases 16 dbfilename dump-7000.rdb dir / data/redis/data/ # aof persistence appendonly yes appendfilename appendonly-7000.aof appendfsync everysec no-appendfsync-on-rewrite yes auto-aof-rewrite-percentage 80-100 auto-aof-rewrite-min-size 64mb Lua-time-limit 5000 # Cluster configuration cluster-enabled yes cluster-config-file / data/redis/data/nodes-7000.conf cluster-node-timeout 5000
Similarly, configure other ports on 192.168.1.108. After configuration, we start separately.
192.168.1.107 host # redis-server / data/redis/conf/redis-7000.conf#redis-server / data/redis/conf/redis-7001.conf#redis-server / data/redis/conf/redis-7002.conf192.168.1.108 host # redis-server / data/redis/conf/redis-7003.conf#redis-server / data/redis/conf/redis-7004.conf#redis-server / data/redis/conf/redis-7005.conf
View the startup process and port on the two hosts:
# ps-ef | grep redisroot 4663 10 10:53? 00:00:09 redis-server 192.168.1.107 grep redisroot 7000 [cluster] root 4667 10:53? 00:00:09 redis-server 192.168.1.107 ps 7001 [cluster] root 5566 10 12:12? 00:00:06 redis-server 192.168.1.107 redis-server 7002 [cluster] root 5611 5313 0 14: 49 pts/1 00:00:00 grep redis# netstat-tnlp | grep redistcp 00 192.168.1.107tnlp 7000 0.0.0.0LISTEN 4663/redis-server 1 tcp 00 192.168.1.107tnlp 7001 0.0.0.0tnlp * LISTEN 4667/redis-server 1 tcp 0 0 192.168.1.107LISTEN 4663/redis-server 7002 0.0.0.0 LISTEN 5566/redis-server * LISTEN 4663/redis-server 1 tcp 00 192.168.1.107 LISTEN 4663/redis-server 17001 0.0.0.0 LISTEN 4667/redis-server 1 tcp 00 192.168.1.107 LISTEN 5566/redis-server 17002 0.0.0.0
Create a cluster
For an introduction to the redis-trib.rb command, please refer to: http://weizijun.cn/2016/01/08/redis%20cluster%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7redis-trib-rb%E8%AF%A6%E8%A7%A3/# redis-trib.rb create-- replicas 1 192.168.1.107 replicas 7000 192.168.1.107 redis-trib.rb create 7001 192.168.1.107 7002 192.168.1.108 Virgo 7003 192.168.1.108 Performing hash slots allocation on 7004 192.168.1.108 masters:192.168.1.108:7003192.168.1.107:7000192.168.1.108:7004Adding replica 7005 > Creating cluster > 192.168.1.107 masters:192.168.1.108:7003192.168.1.107:7000192.168.1.108:7004Adding replica 192.168.1.107 to 192.168.12.108:7003Adding replica 192.168.1.108 to 192.168.12.107:7000Adding replica 192.168.1.108Creating cluster 7002 to 192.168.12.108Creating cluster 7004M: D0ce4d4eb8c503267ffea606e90d1c537a83a22e 192.168.1.107 masterS 7000 slots:5461-10922 (5462 slots) masterS: 24ca2753885db7f37c0e0077b1f43eb2b1a52e42 192.168.1.107 slots 7001 replicates 8ee448821d5e757af73bab65861340e557b8cd14S: 90c36924c71ae924b1179ff1a384c53e5ea2e484 192.168.1.107 slots 7002 replicates 5a93221a3281f88f9984c24b6e1d6f08b3685c89M: 8ee448821d5e757af73bab65861340e557b8cd14 192.168.1.108d0ce4d4eb8c503267ffea606e90d1c537a83a22e 7003 slots:0-5460 (5461 slots) masterM: 5a93221a3281f88f9984c24b6e1d6f08b3685c89 192.168.1.1088purl 7004 slots:10923-16383 (5461 slots) masterS: a63176f88cbf58ab879421148da3b171f169540d 192.168.1.108pur7005 replicates d0ce4d4eb8c503267ffea606e90d1c537a83a22eCan I set the above configuration? (type 'yes' to accept): yes # enter yes > Nodes configuration updated > > Assign a different config epoch to each node > > Sending CLUSTER MEET messages to join the clusterWaiting for the cluster to join. > > Performing Cluster Check (using node 192.168.1.107 slots 7000) M: d0ce4d4eb8c503267ffea606e90d1c537a83a22e 192.168.1.107 slots 7000 slots:5461-10922 (5462 slots) masterM: 24ca2753885db7f37c0e0077b1f43eb2b1a52e42 192.168.1.107 yes 7001 slots: (0 slots) master replicates 8ee448821d5e757af73bab65861340e557b8cd14M: 90c36924c71ae924b1179ff1a384c53e5ea2e484 192.168.1.107 yes 7002 slots : (0 slots) master replicates 5a93221a3281f88f9984c24b6e1d6f08b3685c89M: 8ee448821d5e757af73bab65861340e557b8cd14 192.168.1.108 slots:0 7003 slots:0-5460 (5461 slots) masterM: 5a93221a3281f88f9984c24b6e1d6f08b3685c89 192.168.1.108 slots 7004 slots:10923-16383 (5461 slots) masterM: a63176f88cbf58ab879421148da3b171f169540d 192.168.1.108 slots: (0 slots) master replicates d0ce4d4eb8c503267ffea606e90d1c537a83a22e [OK] All nodes agree about slots configuration. > > Check for open slots... > > Check slots coverage... [OK] All 16384 slots covered. # Cluster created successfully
Cluster verification
The node at port 7002 of 192.168.1.107 writes data and queries port 7005 of 192.168.1.108. The connection method is redis-cli-h 192.168.31.245-c-p 7002. Add the parameter-C to connect to the cluster. Because the above redis.conf changes bind to ip address, the-h parameter cannot be omitted. # redis-cli-h 192.168.1.107-c-p 7002192.168.108this is test01 7003 > set test01 "this is test01" OK192.168.1.108:7003 > # redis-cli-h 192.168.1.108-c-p 7005192.168.12.108Frey 7005 > get test01- > Redirected to slot [1840] located at 192.168.12.108this is test01 7003 "this is test01" indicates that the cluster is operating normally.
The Redis cluster stores the data in a master node and then synchronizes the data between the master and its corresponding salve. When the data is read, the data is also obtained from the corresponding master node according to the consistent hashing algorithm. Only when a master is dead will a corresponding salve node be started to act as a master.
It should be noted that there must be 3 or more master nodes, otherwise the creation of the cluster will fail, and when the number of surviving master nodes is less than half of the total number of nodes, the entire cluster will not be able to provide services.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.