Linux operation and Architecture-redis cluster

Source: Internet
Author: User
Tags redis cluster install redis

First, Introduction

after Redis cluster 3.0, you need at least 3 (Master) +3 (Slave) to build a cluster, a decentralized, distributed storage architecture that can share data across multiple nodes . resolves issues such as redis high availability, scalability, and more.

II. Installation and Deployment

1. Environment

[Email protected] ~]# cat/etc/redhat-6.9~]# uname-R2.6. -696~]#/etc/init.d/is ~~]# hostname-I  10.0. 0.2

2. Redis cluster is based on a redis that has been installed on the previous blog post

① Creating a cluster node directory

mkdir/usr/local/redis-cluster/{9001..9006}/data-P[[email protected] Redis-cluster]# ll/usr/local/redis-cluster/ Total -drwxr-xr-x5Root root4096 2018- to- -  -: - 9001drwxr-xr-x5Root root4096 2018- to- -  -: at 9002drwxr-xr-x5Root root4096 2018- to- -  -: - 9003drwxr-xr-x5Root root4096 2018- to- -  -: - 9004drwxr-xr-x5Root root4096 2018- to- -  -: - 9005drwxr-xr-x5Root root4096 2018- to- -  -: the 9006drwxr-xr-x2Root root4096 2018- to- -  -: WuBin

② Creating a command directory

Mkdir/usr/local/redis-cluster/bin-/server/tools/redis-3.2. 8/SRCCP mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli Redis-server Redis-trib.rb/usr/local/redis-cluster/bin

③ Creating a Redis instance

CP-A/usr/local/redis/*  /usr/local/redis-cluster/9001/

Modifying the redis.conf configuration file

Port9001                                 #每个节点的端口号daemonize yesbind10.0.0.2                             #绑定当前机器 IPdir/usr/local/redis-cluster/9001/data/# data File storage location Pidfile/var/run/redis_9001.pid #pid 9001 and port to correspond to cluster-enabled Yes #启动集群模式cluster-config-file nodes9001.conf #9001和port要对应cluster-node-timeout15000appendonly Yes

④ Create another 5 Redis instances

Cp-a/usr/local/redis-cluster/9001/*  /usr/local/redis-cluster/9002cp-a/usr/local/ redis-cluster/9001/*/usr/local/redis-cluster/9003cp-a/usr/local/redis-cluster/9001/*/usr/local/redis-cluster/ 9004cp-a/usr/local/redis-cluster/9001/*/usr/local/redis-cluster/9005cp-a/usr/local/redis-cluster/9001/*/usr/ local/redis-cluster/9006

Modify the redis.conf configuration file in turn

9001                                #修改以下4处, change to 9002, 9003, 9004, 9005, 9006/usr/local/redis-cluster/9001/data/  /  var/run/redis_9001.pid         cluster-config-file nodes9001.conf       

# # #到此为止基础环境已准备好 # #

Third, install the Ruby environment

# # # #直接执行gem Install Redis, error # # #

gem install Redis      Error:  error installing Redis:              2.2.  2.  

① Installation and Installation RVM

GPG2--keyserver HKP://keys.gnupg.net  --recv-keysd39dc0e3get. Rvm.io | bash- S Stable   /-name Rvm-print  

② View a known version of Ruby in the RVM library

③ Installing a ruby version

2.3. 3

④ using a ruby version

2.3. 3  

⑤ Setting the default version

2.3. 3 --default

⑥ uninstalling a known version

2.0. 0

⑦ Installing Redis

⑧ View Ruby version

Four, cluster construction

1. Start a redis with six nodes

redis-server/usr/local/redis-cluster/9001/redis.conf Redis-server/usr/local/redis-cluster/9002/redis.conf Redis-server/usr/local/redis-cluster/9003/redis.conf Redis-server/usr/local/redis-cluster/9004/redis.conf Redis-server/usr/local/redis-cluster/9005/redis.conf Redis-server/usr/local/redis-cluster/9006/redis.conf# # # #查看进程 # # #[email protected]~]# PS aux|grep redisroot2441  0.1  0.9 135592  9788? Ssl ,: -   0: +Redis-server10.0.0.2:9001[cluster] root2445  0.1  0.9 135592  9800? Ssl ,: in   0: -Redis-server10.0.0.2:9002[cluster] root2449  0.1  0.9 135592  9792? Ssl ,: in   0: +Redis-server10.0.0.2:9003[cluster] root2453  0.1  0.7 133544  7728? Ssl ,: in   0: +Redis-server10.0.0.2:9004[cluster] root2457  0.1  0.9 135592  9808? Ssl ,: in   0: -Redis-server10.0.0.2:9005[cluster] root2461  0.1  0.9 135592  9784? Ssl ,: in   0: -Redis-server10.0.0.2:9006[Cluster]

2. Create a cluster

1 10.0. 0.2:900110.0. 0.2:900210.0. 0.2:900310.0. 0.2:900410.0. 0.2:900510.0. 0.2:9006

# # #命令说明 # #

1 1:116383 Solt, the default will give us an average distribution, of course you can specify that the subsequent increase or decrease of nodes can also be reassigned.

# # #输入yes后开始创建集群 # #

# # #如所示, Cluster creation Success # # #

3. Cluster verification

① connecting cluster nodes using client commands

[Email protected] ~]# redis-cli-h10.0.0.2-c-p900110.0.0.2:9001>Setname Lulu-Redirected to slot [5798] located at10.0.0.2:9002#自动连接到了9002节点, this is a data distribution feature of the clusterOK10.0.0.2:9002>Getname"Lulu"

② Connection Other node verification

10.0. 0.2 9003 10.0. 0.2:9003get  name, redirected to slot [579810.0.  0.2:9002"Lulu"

# # # #至此, Redis cluster Setup Complete # # #

Linux operation and Architecture-redis cluster

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.