Redis backend monitoring and management Cachecloud

Source: Internet
Author: User
Tags failover redis cluster install redis

Cachecloud Environmental Requirements
    • Java 7
    • Maven 3
    • Mysql
    • Redis 3

For specific usage, refer to: Https://cachecloud.github.io

1. Download Cachecloud

Official website Https://github.com/sohutv/cachecloud

Download Cachecloud-master.zip

Unzip and move Cachecloud-master to/usr/local directory

2. Create a library in MySQL and authorize

Import Initial data

3. Edit the/usr/local/cachecloud-master/cachecloud-open-web/src/main/swap/online.properties file

3.1 Running under the Cachecloud root directory

-Ponline

3.2 Create a/opt/cachecloud-web directory and copy related files

Mkdir-p/opt/cachecloud-web

CP cachecloud-open-web/target/cachecloud-open-web-1.0-snapshot.war/opt/cachecloud-web/

CP cachecloud-open-web/src/main/resources/cachecloud-web.conf/opt/cachecloud-web/

Ln-s/opt/cachecloud-web/cachecloud-open-web-1.0-snapshot.war/etc/init.d/cachecloudweb

4. Start Cachecloud-web and access via http://IP:8585, username and password admin

/etc/init.d/cachecloudweb start

5. Use cachecloud-init.sh to install Redis and initialize to modify the version of Redis in the script as required

6. Create the Cachecloud SSH Connection account on the server, and keep the user name and password in the System Configuration Management page.

Useradd Cachecloud

passwd Cachecloud

6.1 Click on the top right corner management backend, machine management, add machine

6.2 Click the top right corner to import the app

7.redis cluster installation (to enable the cluster to function at least 3 primary nodes, here we will create 6 Redis nodes, of which three are the primary node, three are slave nodes)

172.17.20.127 redis-6379/1680
172.17.20.128 redis-6381/6382
172.17.20.129 redis-6383/6384

Redis clusters are implemented using data sharding (sharding) instead of a consistent hash (consistency hashing): A Redis cluster contains 16,384 hash slots (hash slots), and each key in the database belongs to one of these 16,384 hash slots , the cluster uses the formula CRC16 (key)% 16384来 to calculate which slot the key key belongs to, where the CRC16 (key) statement is used to calculate the CRC16 checksum of key keys. Each node in the cluster is responsible for processing a portion of the hash slot.

Download compile and install Redis

    • Http://download.redis.io/releases/redis-3.2.8.tar.gz

CP-PR Redis redis-6380 #其他类似按照端口号复制

Modify Redis.conf

Daemonize Yes
Port 6379 #其他配置改为6380/6381/6382/6383/6384pidfile/var/run/redis_6379.pid #其他配置按端口号修改
cluster-enabled Yes
Cluster-config-file nodes-6379.conf # Other configurations change by port number
Cluster-node-timeout 15000
AppendOnly Yes

Create a profile soft connect and start Redis

Ln-s/opt/cachecloud/redis-6379/redis.conf/etc/redis-6379.conf #其他按照类似配置

Start Cluster Redis separately

8. Installing the Ruby Tools required for Redis clusters

Yum install ruby RubyGems

Gem Install Redis

Go to the Reids directory and run

cd/opt/cachecloud/redis/src/

    1. REDIS-TRIB.RB Create sub-command build
    2. --replicas 1 specifies 1 slave nodes for each master node in the Redis cluster
    3. Node roles are determined by order, first after master and then slave

9. Common commands

View cluster status

REDIS-TRIB.RB Check Ip:port #检查集群状态

Redis-cli-c-H ip-p Port #使用-C Enter the cluster command mode

REDIS-TRIB.RB rebalance Ip:port--auto-weights #重新分配权重

Adding and removing cluster nodes

REDIS-TRIB.RB Add-node Ip:port (new node) Ip:port (active node)

REDIS-TRIB.RB Del-node ip:port ID (ID of the target node) #删除master节点之前首先要使用reshard移除master的全部slot

Re-dividing slots

REDIS-TRIB.RB Reshard Ip:port

10. Convert Master to Salve

Cluster replicate Master-id #转换前6380端必须没有slots

11. Analog Failover

Kill a Redis process and observe the failover situation

The Redis cluster is an election-based fault tolerance that ensures that a server hangs up and runs, and that this is an election in which more than half of the master in the cluster has found other master hangs, and the other corresponding slave nodes are upgraded to master.

12. Join Redis Cluster to Cachecloud

Redis backend monitoring and management Cachecloud

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.