In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to configure one master and two slaves to separate reading and writing from Redis5". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Experimental environment:
System: CentOS7
Software: redis-5.0.2
1. Decompress redis-5.0.2
Three nodes
[root@red1 software] # cd / usr/local/ [root@red1 local] # lltotal 1912drwxr-xr-x. 2 root root 134 Apr 10 21:45 bindrwxr-xr-x. 2 root root 6 Apr 11 2018 etcdrwxr-xr-x. 2 root root 6 Apr 11 2018 gamesdrwxr-xr-x. 2 root root 6 Apr 11 2018 includedrwxr-xr-x. 2 root root 6 Apr 11 2018 libdrwxr-xr-x. 2 root root 6 Apr 11 2018 lib64drwxr-xr-x. 2 root root 6 Apr 11 2018 libexecdrwxrwxr-x. 6 root root 4096 Apr 11 11:49 redis-rw-r--r--. 1 root root 1952989 Apr 10 21:42 redis-5.0.2.tar.gzdrwxr-xr-x. 2 root root 6 Apr 11 2018 sbindrwxr-xr-x. 5 root root 49 Oct 22 10:25 sharedrwxr-xr-x. 2 root root 6 Apr 11 2018 src
Second, install Redis
Three nodes
Make
Make install
Third, modify environmental variables
Three nodes
After installing Redis, some scripts are generated at / usr/local/bin
[root@red1 local] # cd / usr/local/bin/ [root@red1 bin] # lltotal 32628-rwxr-xr-x. 1 root root 4365456 Apr 10 21:45 redis-benchmark-rwxr-xr-x. 1 root root 8084864 Apr 10 21:45 redis-check-aof-rwxr-xr-x. 1 root root 8084864 Apr 10 21:45 redis-check-rdb-rwxr-xr-x. 1 root root 4786592 Apr 10 21:45 redis-clilrwxrwxrwx. 1 root root 12 Apr 10 21:45 redis-sentinel-> redis-server-rwxr-xr-x. 1 root root 8084864 Apr 10 21:45 redis-server
Modify environment variabl
PATH=\ $PATH:/mysql/app/mysql/bin:/mysql/app/xtrabackup/bin:$HOME/bin:/usr/bin:/sbin:/bin:/usr/local/binsource .bash _ profile
Configure the Redis configuration file
Primary node 192.168.8.11
Port 6000 # Port number requirepass 123456 # Login password bind 192.168.8.11 # bind IPdaemonize yes # run redis in the background
From Node one
Port 6001 # Port number bind 192.168.8.12 # bind IPslaveof 192.168.8.11 6000 # set master node information masterauth 123456 # master node password requirepass 123456 # login password slave-read-only yes # read-only mode daemonize yes # run redis in the background
Slave Node two
Port 6002 # Port number bind 192.168.8.13 # bind IPslaveof 192.168.8.11 6000 # set master node information masterauth 123456 # master node password requirepass 123456 # login password slave-read-only yes # read-only mode daemonize yes # run redis in the background
5. Start Redis
Start the master node first, and then start the slave node
Primary node
[root@red1 redis] # redis-server / usr/local/redis/redis.conf [root@red1 redis] # [root@red1 redis] # [root@red1 redis] # ps-ef | grep redisroot 2012 10 21:35? 00:00:00 redis-server 192.168.8.11:6000root 2017 1384 0 21:35 pts/0 00:00:00 grep-color=auto redis
You can see that the redis service with port number 6000 has been started
From Node one
Root@red2 ~] # redis-server / usr/local/redis/redis.conf [root@red2 ~] # ps-ef | grep redisroot 1968 1 0 21:36? 00:00:00 redis-server 192.168.8.12:6001root 1973 1386 0 21:36 pts/0 00:00:00 grep-- color=auto redis
You can see that the redis service with port number 6001 has been started
Slave Node two
[root@red3 ~] # ps-ef | grep redisroot 1943 10 21:36? 00:00:00 redis-server 192.168.8.13:6002root 1956 1034 0 21:36 pts/0 00:00:00 grep-- color=auto redis
You can see that the redis service with port number 6002 has been started
VI. Usability verification
Primary node
[root@red1 redis] # redis-cli-p 6000-a 123456-h 192.168.8.11Warning: Using a password with'- a'or'- u' option on the command line interface may not be safe.192.168.8.11:6000 > get 1 "hello" 192.168.11 worldOK192.168.8.11:6000 > get 3 (nil) 192.168.11 worldOK192.168.8.11:6000 > set 3 worldOK192.168.8.11:6000 > get 3 "world"
From Node one
[root@red2] # redis-cli-p 6001-a 123456-h 192.168.8.12Warning: Using a password with'- a'or'- u 'option on the command line interface may not be safe.192.168.8.12:6001 > get 3 "world"
Slave Node two
[root@red3] # redis-cli-p 6002-h 192.168.8.13-a 123456Warning: Using a password with'- a'or'- u 'option on the command line interface may not be safe.192.168.8.13:6002 > get 3 "world"how to configure one master and two slaves to separate reads and writes" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.