Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system: build Redis single station and Sentinel cluster environment in Centos7 environment

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Source code of this article: GitHub click here | | GitEE click here |

I. Environment and version

Linux:centos7 3

Three Linux services 192.168.72.129192.168.72.130192.168.72.131REDISREDISR-4.0.14II, upload Redis software 1, create a software directory [root@localhost local] # cd / usr/local/ [root@localhost local] # mkdir mysoft2, Xftp upload software, decompress [root@localhost mysoft] # cd / usr/local/mysoft/ [root@localhost mysoft] # lltotal 1704 RWMLR root@localhost mysoft. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz [root@localhost mysoft] # tar-zxvf redis-4.0.14.tar.gz3, compilation project [root@localhost mysoft] # lltotal 1708drwxrwxr-x. 6 root root 4096 Mar 19 00:23 redis-4.0.14-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz [root@localhost mysoft] # cd redis-4.0.14/ [root@localhost redis-4.0.14] # make MALLOC=libc4, install Redi [root @ localhost redis-4.0.14] # cd src & & make install5, start the service [root@localhost redis-4.0.14] # cd src [root@localhost src] #. / redis-server6, start the configuration process

Modify redis.conf

Daemonize yes7, process View closes [root@localhost redis-4.0.14] #. / src/redis-server redis.conf11320:C 05 May 14 src/redis-server redis.conf11320:C 26 May 26 May 26 May 31.053 # Redis is starting11320:C 05 May 14 14 V V 26V 31.053 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11320, just started11320:C 05 May 14 V 26 # Configuration loaded [root@localhost redis-4.0.14] # ps-aux | grep redisroot 11321 0.1 141840 2028? Ssl 14:26 0:00. / src/redis-server *: 6379root 11338 0.0 112708 980 pts/1 S + 14:27 grep-- color=auto redis [root@localhost redis-4.0.14] # kill-9 11321 III, configuration boot 1, Related configuration [root@localhost init.d] # cd / etc [root@localhost etc] # mkdir redis [root@localhost etc] # cp / usr/local/mysoft/redis-4.0.14/redis.conf / etc/redis/6379.conf [root@localhost etc] # cd redis/ [root@localhost redis] # lltotal 60 RWKui. 1 root root 58767 May 5 14:36 redis-6379.conf [root@localhost redis] # cp / usr/local/mysoft/redis-4.0.14/utils/redis_init_script / etc/init.d/redisd [root@localhost redis] # chkconfig redisd on # Boot Command 2, Service Startup / shutdown [root@localhost redis] # service redisd startStarting Redis server...3163:C 05 May 14VOV 59 May 13.872 # Redis is starting 3163 May 05RU 5913.872 # Redis version=4.0.14, bits=64 Commit=00000000, modified=0, pid=3163, just started3163:C 05 May 14pid=3163 13.872 # Configuration loaded [root@localhost redis] # service redisd stopStopping... Waiting for Redis to shutdown... Redis stopped3, restart the virtual machine to view the Redis status [root@localhost] # ps-aux | grep redisroot 987 0.1 0.1 141836 2012? Ssl 15:02 0:00 / usr/local/bin/redis-server *: 6379root 2966 0.0 112712 980 pts/1 S + 15:04 0:00 grep-- color=auto redis IV, solve the client connection problem

Turn off the firewall or open port 6379

Basic use of firewalld startup: systemctl start firewalld off: systemctl stop firewalld View status: systemctl status firewalld boot disabled: systemctl disable firewalld boot enabled: systemctl enable firewalld

Modify redis.conf configuration

Comment out: # bind 127.0.0.1 modify protection mode: protected-mode no V, sentinel Sentinel Mode 1, basic configuration 192.168.72.129 Master Service 192.168.72.130 Slave Service 192.168.72.131 Slave Service 2, configure Master Service redis.confrequirepass 123456masterauth 1234563, configure Slave Service redis.confrequirepass 123456slaveof 192.168.72.129 6379masterauth 1234564, configure sentinel.confprotected-mode no# sentinel monitor for Monitoring # mymaster represents the name of the server, can be customized # 192.168.72.129 represents the monitored master server, 6379 represents the port, and # 2 ID > = 2 Sentinel thinks that the master server is unavailable and performs failover operation. Sentinel monitor mymaster 192.168.72.129 6379 2sentinel auth-pass mymaster 1234565, startup service

First master service, then slave service

[root@localhost src] #. / redis-server.. / redis.conf [root@localhost src] #. / redis-sentinel.. / sentinel.conf

Yes, that's how it was built!

Source code address GitHub address https://github.com/cicadasmile/linux-system-baseGitEE address https://gitee.com/cicadasmile/linux-system-base

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report