当前位置:网站首页>Install redis and deploy redis high availability cluster
Install redis and deploy redis high availability cluster
2022-04-23 15:58:00 【aserendipper】
One 、 Environmental Science
1、 Two servers 10.213.120.80、10.213.120.81
2、redis edition 4.0.6 install (redis5 You can also follow this procedure )
Two 、 install redis
1、 adopt ftp hold redis-4.0.6.tar.gz Upload to 81 Server's /opt/software Under the table of contents
2、 Copy redis-4.0.6.tar.gz To /usr/local Under the table of contents
cp /opt/software/redis-4.0.6.tar.gz /usr/local/
3、 decompression redis-4.0.6.tar.gz
tar -zxvf redis-4.0.6.tar.gz
6、 Get into redis-4.0.6 Compile under Directory
cd redis-4.0.6
make
3、 ... and 、 Start the test redis
1、 modify redis The configuration file vi redis.conf
daemonize yes ( Background start )
2、 start-up redis
src/redis-server redis.conf
3、 Connect redis client
src/redis-cli
4、 Exit client
quit
5、 sign out redis service ( Three ways )
(1)pkill redis‐server
(2)kill Process number
(3)src/redis-cli shutdown
Four 、 install ruby(redis5 After that, you don't need to install ruby, You can skip )
1、 stay redis Installation directory src There is a file in the directory : redis-trib.rb. This is a ruby Version of redis Service installation script , To use it , Please install... First ruby. install ruby and ruby gem Tools (redis3 Cluster configuration is required ruby Of gem Tools , similar yum)
yum -y install ruby rubygems
2、 Use gem download redis Cluster configuration script
gem install redis
(1) error : No response , Can't access gem Source
Solution : Use an alicloud image to install redis 了
gem sources -a http://mirrors.aliyun.com/rubygems/
(2) At this time , A second mistake has occurred :
Fetching: redis-4.2.1.gem (100%),ERROR: Error installing redis:
redis requires Ruby version >= 2.3.0.
error analysis : ruby The version of is too low , requirement 2.3 above , Now check with the command ruby Version of
ruby --version
Solution : upgrade ruby
3、 upgrade ruby edition
(1) Update curl Protocol version of the command
yum update -y nss curl libcurl
sudo yum update nss nss-util nss-sysinit nss-tools
(2) modify hosts file , Plus American ip and raw.githubusercontent.com
vi /etc/hosts
stay hosts Add... To the document :
199.232.68.133 raw.githubusercontent.com
(3) install RAM: RAM(Ruby Version Manager ) Is a RAM Command line tools for , have access to RAM Easy installation , management Ruby edition .RVM Contains Ruby Version management and Gem Library management (gemset)
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
(4) Refresh environment variable
source /etc/profile.d/rvm.sh
(5) List ruby The version that can be installed
rvm list known
(6) install Ruby2.4.1 edition ( This command takes a long time , It is recommended to download in the background ), Download failed in process , Re execute the command to download
rvm install 2.4.1
(7) Use Ruby2.4.1 edition
rvm use 2.4.1
(8) Re install Redis
gem install redis
5、 ... and 、 Deployment cluster
1、 stay 81 Server's /usr/local Create under directory redis-cluster Catalog , Then create three folders in its directory
mkdir -p /usr/local/redis-cluster
mkdir 7001 7002 7003
2、 Put the previous redis.conf copy to 7001 Under the folder , Modify its configuration
daemonize yes ( Background start )
port 7001( Set the port number of each machine separately )
dir /usr/local/redis‐cluster/7001/( Specify the data file storage location , You must specify a different directory location , Otherwise, data will be lost )
cluster‐enabled yes( Start cluster mode )
cluster‐config‐file nodes‐7001.conf( Cluster node information file , here 700x The best and port Corresponding upper )
cluster‐node‐timeout 5000
# bind 127.0.0.1( Get rid of bind Binding access ip Information )
protected‐mode no ( Turn off protection mode )
appendonly yes
pidfile /var/run/redis_7001.pid
#redis5 Then you can configure the password , Cannot be configured before
requirepass credit_redis( Set up redis Access password )
masterauth credit_redis( Set the access password between cluster nodes , Same as above )
3、 Put the modified redis.conf, copy to 7002、7003 Under the table of contents , modify 2、3、5、12 Port number , It can be replaced in batches :
:%s/ The source string / Destination string /g
4、 hold 80 The server also follows the above operation , The catalog uses 7004、7005、7006
5、 To start, respectively, 3 individual redis example , Then check for success
/usr/local/redis‐4.0.6/src/redis‐server /usr/local/redis‐cluster/700*/redis.conf
# Check to see if startup succeeded
ps ‐ef | grep redis
6、 Create the whole redis colony (redis5 Previous versions of clustering relied on ruby Script redis‐trib.rb Realization ,redis5 After use redis-cli Realization )
# In the following order 1 Represents the creation of a slave server node for each primary server node created
# To execute this command, you need to confirm the connection between the three machines redis Instances should be accessible to each other , You can simply turn off all the machine firewalls first , If you don't turn off the firewall
You need to turn on redis Service ports and cluster nodes gossip Communication port
# Turn off firewall
# systemctl stop firewalld # Turn off firewall temporarily
# systemctl disable firewalld # Do not start
(1)redis5 After the version
/usr/local/redis‐5.0.3/src/redis‐cli ‐a credit_redis ‐‐cluster create ‐‐cluster‐replicas 1 10.213.120.81:7001 10.213.120.81:7002 10.213.120.81:7003 10.213.120.80:7004 10.213.120.80:7005 10.213.120.80:7006
(2)redis5 Version before
/usr/local/redis/src/redis-trib.rb create --replicas 1 10.213.120.81:7001 10.213.120.81:7002 10.213.120.81:7003 10.213.120.80:7004 10.213.120.80:7005 10.213.120.80:7006
7、 Verification cluster :
(1) Connect to any client :./redis‐cli ‐c ‐h ‐p (‐a Access server password ,‐c Represents the cluster mode , Appoint ip Address and port number ) Such as :/usr/local/redis/src/redis‐cli ‐c ‐h 10.213.120.81 ‐p 7001
(2) To verify : cluster info( View cluster information )、cluster nodes( View the list of nodes )
(3) Perform data operation verification
(4) To shut down the cluster, you need to shut down one by one , Use command :
/usr/local/redis/src/redis‐cli ‐c ‐h 10.213.120.81 ‐p 7001 shutdown
5、 ... and 、 Problems encountered during deployment
1、 An error occurred while creating the cluster
/usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError) from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/redis/src/redis-trib.rb:25:in `<main>'
reason :ruby Of redis The interface is not installed , Go back to step 4 to install ruby that will do
2、 An error occurred while creating the cluster
>>> Creating cluster
[ERR] Sorry, can't connect to node 10.213.120.81:7001
reason : If redis.conf Added in requirepass password and masterauth password, because redis5 I used to use redis‐trib.rb When creating a cluster , Can't recognize -a password, So I need to comment these two lines
6、 ... and 、 Reference material
1、https://my.oschina.net/u/4318340/blog/4326379/print
版权声明
本文为[aserendipper]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231557111213.html
边栏推荐
猜你喜欢
R语言中实现作图对象排列的函数总结
Best practices of Apache APIs IX high availability configuration center based on tidb
王启亨谈Web3.0与价值互联网“通证交换”
捡起MATLAB的第(9)天
Codejock Suite Pro v20. three
Load Balancer
大型互联网为什么禁止ip直连
Method 2 of drawing ROC curve in R language: proc package
IronPDF for . NET 2022.4.5455
Redis master-slave replication process
随机推荐
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
Why disable foreign key constraints
捡起MATLAB的第(2)天
Named in pytoch_ parameters、named_ children、named_ Modules function
One brush 313 sword finger offer 06 Print linked list from end to end (E)
Accumulation of applet knowledge points
Day (9) of picking up matlab
MySQL集群模式與應用場景
PS add texture to picture
Load Balancer
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
Upgrade MySQL 5.1 to 5.67
[split of recursive number] n points K, split of limited range
捡起MATLAB的第(9)天
shell_2
js正则判断域名或者IP的端口路径是否正确
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
Master vscode remote GDB debugging
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Day (7) of picking up matlab