Redis stand-alone cluster environment construction:

Redis stand-alone cluster environment construction:

Note: The cluster requires a version greater than 5.0

1. Prepare the redis.tar.gz resource package;

2. Stored in the /usr/u02/ directory;

3. Unzip redis.tar.gz

tar -zxvf redis.tar.gz

4. Enter the decompressed redis directory;

5. Execute the make command;

6. Execute make PREFIX=/home/redis/redis-7.04/

(execute the redis installation directory, if not specified, it will be installed in
/usr/local/bin by default);

7. You can copy redis.conf in the decompression directory to the installation directory /home/redis/redis-7.04/;

8.vim /home/redis/redis-7.04/redis.conf

Lift the ip restriction of local access to redis

bind 0.0.0.0

9. Create cluster_one/ under /home/redis/

(Copy 6 redis.conf files, 6 nodes, marked with ports)

Each configuration file needs to modify the following parameters:

'''
Edit /home/redis/workspace/cluster_one/redis_7001.conf
Set service port: port 7001
Unbind this machine: # bind 127.0.0.1 -::1
Guardian mode start: daemonize yes
Set pid path: pidfile /home /redis/workspace/cluster_one/redis_7001.pid
Set storage path: dir /home/redis/workspace/cluster_one
Set connection password: requirepass 123456
AOF persistence: appendonly yes
AOF storage file name: appendfilename "appendonly_7001.aof"
AOF persistence Policy: appendfsync always
Enable cluster: cluster-enabled yes
Cluster Node name: luster-config-file nodes_7001.conf
Cluster timeout: cluster-node-timeout 5000

'''
10. Start redis service (6)

'''
redis-server /home/redis/workspace/cluster_one/redis_7001.conf

redis-server /home/redis/workspace/cluster_one/redis_7002.conf

redis-server /home/redis/workspace/cluster_one/redis_7003.conf

redis-server /home/redis/workspace/cluster_one/redis_7004.conf

redis-server /home/redis/workspace/cluster_one/redis_7005.conf

redis-server /home/redis/workspace/cluster_one/redis_7006.conf

'''
11. Create a cluster

../../redis-7.0.4/bin/redis-cli -a 123456 --cluster create --cluster-replicas 1 172.16.10.103:7001 172.16.10.103:7002 172.16.10.103:7003 172.16.10.103:7004 172.16.10.103:7005 172.16.10.103:7006

12. Log in to the client

../../redis-7.0.4/bin/redis-cli -a 123456 -c -h 192.168.1.4 -p 7001
../../redis-7.0.4/bin/redis-cli -a 123456 -c -h 192.168.1.4 -p 7002
../../redis-7.0.4/bin/redis-cli -a 123456 -c -h 192.168.1.4 -p 7003
../../redis-7.0.4/bin/redis-cli -a 123456 -c -h 192.168.1.4 -p 7004
...

13. Entering one of the clients will automatically jump to different nodes within the cluster

14. You can use kill -9 pid

exit node

pidfile /home/redis/workspace/alone/redis_6379.pid

Acho que você gosta

Origin blog.csdn.net/qq_37651894/article/details/130626063
Recomendado
Clasificación