Linux System: Centos7 Environment Builds Redis Single and Cluster Environment

Keywords: Linux Redis SSL github

I. Environment and Version

Linux: centos7

Three Linux Services
192.168.72.129
192.168.72.130
192.168.72.131
Redis: redis-4.0.14

Uploading Redis Software

1. Creating Software Catalogue

[root@localhost local]# cd /usr/local/
[root@localhost local]# mkdir mysoft

2. Xftp upload software, decompression

[root@localhost mysoft]# cd /usr/local/mysoft/
[root@localhost mysoft]# ll
total 1704
-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz
[root@localhost mysoft]# tar -zxvf redis-4.0.14.tar.gz

3. Compilation project

[root@localhost mysoft]# ll
total 1708
drwxrwxr-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=libc

4. Installing Redis

[root@localhost redis-4.0.14]# cd src && make install

5. Start-up services

[root@localhost redis-4.0.14]# cd src
[root@localhost src]# ./redis-server

6. Configuration process startup

Modify redis.conf

daemonize yes

7. Process View Closed

[root@localhost redis-4.0.14]# ./src/redis-server redis.conf
11320:C 05 May 14:26:31.053 # Redis is starting
11320:C 05 May 14:26:31.053 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11320, just started
11320:C 05 May 14:26:31.053 # Configuration loaded
[root@localhost redis-4.0.14]# ps -aux |grep redis
root 11321 0.1 0.1 141840 2028 ? Ssl 14:26 0:00 ./src/redis-server *:6379
root 11338 0.0 0.0 112708 980 pts/1 S+ 14:27 0:00 grep --color=auto redis
[root@localhost redis-4.0.14]# kill -9 11321

3. Configuration Start-up

1. Relevant 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]# ll
total 60
-rw-r--r--. 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 Start Command

2. Service startup and shutdown

[root@localhost redis]# service redisd start
Starting Redis server...
3163:C 05 May 14:59:13.872 # Redis is starting 
3163:C 05 May 14:59:13.872 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=3163, just started
3163:C 05 May 14:59:13.872 # Configuration loaded
[root@localhost redis]# service redisd stop
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped

3. Restart Virtual Machine to View Redis Status

[root@localhost ~]# ps -aux |grep redis
root 987 0.1 0.1 141836 2012 ? Ssl 15:02 0:00 /usr/local/bin/redis-server *:6379
root 2966 0.0 0.0 112712 980 pts/1 S+ 15:04 0:00 grep --color=auto redis

4. Solving the problem of client connection

Close the firewall or open port 6379

Basic use of firewalld
 Start: system CTL start firewalld
 Close: system CTL stop firewalld
 View status: system CTL status firewalld
 Boot Disabled: System CTL disable firewalld
 Boot-up: system CTL enable firewalld

Modify redis.conf configuration

Comment out: # bind 127.0.0.1
 Modify protection mode: protected-mode no

V. sentinel Sentinel Model

1. Basic configuration

192.168.72.129 main services
 192.168.72.130 Slave Service
 192.168.72.131 Slave Service

2. Configuring redis.conf

requirepass 123456
masterauth 123456

3. Configuring redis.conf from services

requirepass 123456
slaveof 192.168.72.129 6379
masterauth 123456

4. Configuring sentinel.conf

protected-mode no
# sentinel monitor representative monitoring
# mymaster represents the name of the server and can be customized.
# 192.168.72.129 represents the main server of monitoring and 6379 represents the port.
# 2 ID >= 2 Sentinel considers the primary server unavailable and performs failover operation.
sentinel monitor mymaster 192.168.72.129 6379 2
sentinel auth-pass mymaster 123456

5. Start-up services

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!

6. Source code address

GitHub Address: Know a smile
https://github.com/cicadasmile
 Code Yun Address: Know a smile
https://gitee.com/cicadasmile


Posted by matto on Thu, 10 Oct 2019 11:09:10 -0700