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

Redis cluster installation

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article redis version 3.2.9

Introduction

IP port role 127.0.0.17000Master127.0.0.17001Master127.0.0.17002Master127.0.0.17003Slave127.0.0.17004Slave127.0.0.17005Slave

I. installation

1.1 create a directory

Mkdir-p / redis/cluster mkdir 7000 7001 7002 7003 7004 7005

1.2 download installation package

Wget http://download.redis.io/releases/redis-3.2.9.tar.gz

1.3 decompression installation

Tar zxvf redis-3.2.9.tar.gz cd redis-3.2.9 make & & make PREFIX=/usr/local/redis install Note: PREFIX can change the storage location according to the needs of the environment

1.4 yum Source

Vi / etc/yum.repos.d/yum.repo [base] name=Red Hat Enterprise Linux baseurl= file:///media/Server enabled=1 gpgcheck=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Resource Kit yum install gcc yum install tcl

1.5 copy and modify configuration fil

Cp / redis/redis-3.2.9/redis.conf / redis/cluster/7000 cp / redis/redis-3.2.9/redis.conf / redis/cluster/7001 cp / redis/redis-3.2.9/redis.conf / redis/cluster/7002 cp / redis/redis-3.2.9/redis.conf / redis/cluster/7003 cp / redis/redis-3.2.9/ Redis.conf / redis/cluster/7004 cp / redis/redis-3.2.9/redis.conf / redis/cluster/7005

1.6 modify the configuration file

# Port number port 7000 # launch daemonize yes in the background # Open Cluster cluster-enabled yes # Cluster Node profile cluster-config-file nodes-7000.conf # Cluster connection timeout cluster-node-timeout 5000 # process Pid file location pidfile / var/run/redis-7000.pid # enable aof appendonly yes # aof file path appendfilename "appendonly-7005.aof" # rdb file path dbfilename dump-7000.rdb

1.7 create a startup script

/ redis/redis-3.2.9/bin/redis-server / redis/cluster/7000/redis.conf / redis/redis-3.2.9/bin/redis-server / redis/cluster/7001/redis.conf / redis/redis-3.2.9/bin/redis-server / redis/cluster/7002/redis.conf / redis/redis-3.2.9/bin/redis-server / redis/cluster/7003/redis.conf / redis/redis-3.2.9/bin/redis-server / redis/cluster/7004/redis.conf / redis/redis-3.2.9/bin/redis-server / redis/cluster/7005/redis.conf

II. Cluster

2.1 Resource Pack

[root@redis2 ~] # yum install ruby rubygems- y [root@redis2 ~] # tar zxvf rubygems-2.4.6.tgz [root@redis2 ~] # chown-R root:root rubygems-2.4.6 [root@redis2 ~] # cd rubygems-2.4.6 ruby setup.rb gem sources-remove https://rubygems.org/ gem install redis-3.3.3.gem

2.2 create a cluster

Redis-trib create-- replicas 1 127.0.0.1VL 7000 127.0.0.1V 7001 127.0.1V 7002 127.0.0.1V 7003 127.0.1V 7003 127.0.1V 7004 127.0.1V 7005

The meaning of the command is as follows:

The command of the redis-trib.rb program is create, Cluster.

The option-replicas 1 means that we want to create a slave node for each master node in the cluster.

The other parameters that follow are the address lists of the instances, and we want the program to use the instances indicated by these addresses to create a new cluster.

To put it simply, the above command means that the redis-trib program will help us create a cluster of three master nodes and three slave nodes.

Then, redis-trib will print out a copy of the expected configuration to show you. If you think it is all right, you can type yes, and redis-trib will apply this configuration to the cluster:

> Creating cluster > Performing hash slots allocation on 6 nodes... Using 3 masters: 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 Adding replica 127.0.0.1:7003 to 127.0.0.1:7000 Adding replica 127.0.0.1:7004 to 127.0.0.1:7001 Adding replica 127. 0.0.1 to 7005 to 127.0.0.1 slots:0 7002 M: b681e1a151890cbf957d1ff08352ee48f6ae39e6 127.0.0.1 slots:0 7000 slots:0-5460 (5461 slots) master M: b85519795fa42aa33d4e88d25104cbae895933a6 127.0.0.1 to 7001 slots:5461-10922 (5462 slots) slots:0 M: b681e1a151890cbf957d1ff08352ee48f6ae39e6 127.0.0.1 slots:0 7002 Slots:10923-16383 (5461 slots) master S: d403713ab9db48aeac5b5393b69e1201026ef479 127.0.0.1 d403713ab9db48aeac5b5393b69e1201026ef479 7003 replicates bdcddddd3d78a866b44b68c7ae0e5ccf875c446a S: b7ec92919e5bcffa76c8eee338f8ca5155293c64 127.0.0.1 master 7004 replicates b85519795fa42aa33d4e88d25104cbae895933a6 S: 8a0d2a3f271b349744a971e1b0a545405de2742e 127.0.0.1 master 7005 replicates b681e1a151890cbf957d1ff08352ee48f6ae39e6 Can I set the above configuration? (type 'yes' to accept):

2.3 Cluster usage

[root@centos1 redis] #. / redis-cli-c-p 7000 127.0.0.1 root@centos1 redis 7000 > set name leo-> Redirected to slot [5798] located at 127.0.0.1 set name leo 7001 OK 127.0.1 set name leo 7001 > get name "leo"

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

Wechat

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

12
Report