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

How CentOS6.6 installs Redis3.0.3 clusters

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces CentOS6.6 how to install Redis3.0.3 cluster, the article is very detailed, has a certain reference value, interested friends must read it!

A Redis cluster requires at least 6 nodes, 3 master and 3 slaves.

IP

Port

Node

127.0.0.1

7000

Master

127.0.0.1

7001

Master

127.0.0.1

7002

Master

127.0.0.1

7003

Slave

127.0.0.1

7004

Slave

127.0.0.1

7005

Slave

Installation steps:

Download redis3.0.3

# cd / usr/local

# wget http://download.redis.io/releases/redis-3.0.3.tar.gz

2. Decompress and compile

# tar-zxvf redis-3.0.3.tar.gz

# cd redis-3.0.3

# make

# make test

# make install

After executing make install, you can see that some files have been generated in the / usr/local/bin directory:

# ls / usr/local/bin/

Redis-benchmark redis-check-dump redis-sentinel

Redis-check-aof redis-cli redis-server

Third, create the directory needed by the cluster and copy redis

# mkdir-p / usr/local/cluster

# mkdir-p / usr/local/cluster/7000

# mkdir-p / usr/local/cluster/7001

# mkdir-p / usr/local/cluster/7002

# mkdir-p / usr/local/cluster/7003

# mkdir-p / usr/local/cluster/7004

# mkdir-p / usr/local/cluster/7005

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7000/

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7001/

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7002/

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7003/

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7004/

# cp-rf / usr/local/redis-3.0.3/* / usr/local/cluster/7005/

4. Modify the configuration file redis.conf

# vi / usr/local/cluster/7000/redis.conf

Modify the following options in the configuration file

Daemonize yes

Port 7000

Appendonly yes

Cluster-enabled yes

Cluster-config-file nodes.conf

Cluster-node-timeout 5000

Use 7000/redis.conf to cover the redis.conf under the directory 7001, 7002, 7003, 7004, 7005.

# cp / usr/local/cluster/7001/redis.conf / usr/local/cluster/7001

# cp / usr/local/cluster/7001/redis.conf / usr/local/cluster/7002

# cp / usr/local/cluster/7001/redis.conf / usr/local/cluster/7003

# cp / usr/local/cluster/7001/redis.conf / usr/local/cluster/7004

# cp / usr/local/cluster/7001/redis.conf / usr/local/cluster/7005

Then modify the port in the redis.conf under 7001 and 7002, so that the port in redis.conf is the same as the name of its parent directory, for example, the port in 7001/redis.conf is 7001 and 7002, and the port in 7001/redis.conf is 7002.

5. Start 6 redis

# cd / usr/local/cluster/7000/src

# redis-server.. / redis.conf

# cd / usr/local/cluster/7001/src

# redis-server.. / redis.conf

# cd / usr/local/cluster/7002/src

# redis-server.. / redis.conf

# cd / usr/local/cluster/7003/src

# redis-server.. / redis.conf

# cd / usr/local/cluster/7004/src

# redis-server.. / redis.conf

# cd / usr/local/cluster/7005/src

# redis-server.. / redis.conf

After startup, use the command to check the startup status of redis

# ps-ef | grep redis

Root 9656 1 0 20:35? 00:00:00 redis-server *: 7000 [cluster]

Root 9684 1 0 20:37? 00:00:00 redis-server *: 7001 [cluster]

Root 9725 1 0 20:43? 00:00:00 redis-server *: 7002 [cluster]

Root 9730 1 0 20:43? 00:00:00 redis-server *: 7003 [cluster]

Root 9734 1 0 20:43? 00:00:00 redis-server *: 7004 [cluster]

Root 9739 1 0 20:43? 00:00:00 redis-server *: 7005 [cluster]

Root 9743 3288 0 20:43 pts/0 00:00:00 grep redis

Create a redis cluster

1 execution of the command to create a redis cluster will report an error, indicating that the ruby cannot be found

# cd / usr/local/redis-3.0.3/src

#. / redis-trib.rb create-- replicas 1 127.0.0.1VR 7000 127.0.0.1V 7001 127.0.0.1V 7002 127.0.0.1R 7003 127.0.1R 7003 127.0.1V 7004 127.0.1V 7005

/ usr/bin/env: ruby: there is no such file or directory

To solve this error, you need to install ruby. Yum install ruby is recommended.

# yum install ruby

2 when you execute the command to create a cluster, an error will be reported, indicating that the rubygems component is missing

#. / redis-trib.rb create-- replicas 1 127.0.0.1VR 7000 127.0.0.1V 7001 127.0.0.1V 7002 127.0.0.1R 7003 127.0.1R 7003 127.0.1V 7004 127.0.1V 7005

. / redis-trib.rb:24:in `require': no such file to load-- rubygems (LoadError)

From. / redis-trib.rb:24

Rubygems is required to resolve this error

# yum install rubygems

3 if you execute the command to create the cluster again, there will be an error indicating that redis cannot be loaded because of the lack of redis interface

#. / redis-trib.rb create-- replicas 1 127.0.0.1VR 7000 127.0.0.1V 7001 127.0.0.1V 7002 127.0.0.1R 7003 127.0.1R 7003 127.0.1V 7004 127.0.1V 7005

/ usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load-- redis (LoadError)

From / usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

From. / redis-trib.rb:25

Redis is required to resolve this error

# gem install redis

Successfully installed redis-3.3.3

1 gem installed

Installing ri documentation for redis-3.3.3...

Installing RDoc documentation for redis-3.3.3...

Note that sometimes when it cannot be installed, you need to download and install it manually:

# wget https://rubygems.global.ssl.fastly.net/gems/redis-3.3.3.gem

# gem install-l. / redis-3.3.3.gem

4 execute the command to install the cluster again and execute it normally

#. / redis-trib.rb create-- replicas 1 127.0.0.1VR 7000 127.0.0.1V 7001 127.0.0.1V 7002 127.0.0.1R 7003 127.0.1R 7003 127.0.1V 7004 127.0.1V 7005

> Creating cluster

Connecting to node 127.0.0.1:7000: OK

Connecting to node 127.0.0.1:7001: OK

Connecting to node 127.0.0.1:7002: OK

Connecting to node 127.0.0.1:7003: OK

Connecting to node 127.0.0.1:7004: OK

Connecting to node 127.0.0.1:7005: OK

> 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:7005 to 127.0.0.1:7002

M: 747467b5f2e2a472afad96de6c88dc2f3bf5b426 127.0.0.1:7000

Slots:0-5460 (5461 slots) master

M: 4e4d8ba07d743c4e69fcd5df8867b996084ca4d9 127.0.0.1:7001

Slots:5461-10922 (5462 slots) master

M: a6fe3c0a16bcb465a23147de8a3e242deb87e800 127.0.0.1:7002

Slots:10923-16383 (5461 slots) master

S: 827ca514f4289dc4ac4d51308721f90851ae6180 127.0.0.1:7003

Replicates 747467b5f2e2a472afad96de6c88dc2f3bf5b426

S: be77a6f99e905109150ceaaa50d357ed86803a4c 127.0.0.1:7004

Replicates 4e4d8ba07d743c4e69fcd5df8867b996084ca4d9

S: 1285a04f3628c3e76f14d1036c59aef1cb36258d 127.0.0.1:7005

Replicates a6fe3c0a16bcb465a23147de8a3e242deb87e800

Can I set the above configuration? (type 'yes' to accept): yes

> Nodes configuration updated

> Assign a different config epoch to each node

> Sending CLUSTER MEET messages to join the cluster

Waiting for the cluster to join..

> Performing Cluster Check (using node 127.0.0.1v7000)

M: 747467b5f2e2a472afad96de6c88dc2f3bf5b426 127.0.0.1:7000

Slots:0-5460 (5461 slots) master

M: 4e4d8ba07d743c4e69fcd5df8867b996084ca4d9 127.0.0.1:7001

Slots:5461-10922 (5462 slots) master

M: a6fe3c0a16bcb465a23147de8a3e242deb87e800 127.0.0.1:7002

Slots:10923-16383 (5461 slots) master

M: 827ca514f4289dc4ac4d51308721f90851ae6180 127.0.0.1:7003

Slots: (0 slots) master

Replicates 747467b5f2e2a472afad96de6c88dc2f3bf5b426

M: be77a6f99e905109150ceaaa50d357ed86803a4c 127.0.0.1:7004

Slots: (0 slots) master

Replicates 4e4d8ba07d743c4e69fcd5df8867b996084ca4d9

M: 1285a04f3628c3e76f14d1036c59aef1cb36258d 127.0.0.1:7005

Slots: (0 slots) master

Replicates a6fe3c0a16bcb465a23147de8a3e242deb87e800

[OK] All nodes agree about slots configuration.

> Check for open slots...

> Check slots coverage...

[OK] All 16384 slots covered.

At this point, the redis cluster is built successfully!

Execute the redis-cli command to enter the cluster environment

# redis-cli-c-p 7000

127.0.0.1V7 000 > quit

#

These are all the contents of the article "how to install Redis3.0.3 clusters in CentOS6.6". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Database

Wechat

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

12
Report