Redis 3.2 Linux Environment cluster construction and Java operations

Source: Internet
Author: User
Tags install redis

Redis uses the redis-3.2.4 version.

installation process

1. Download and unzip

Cd/usr/localwget HTTP://DOWNLOAD.REDIS.IO/RELEASES/REDIS-3.2.4.TAR.GZTAR-ZXVF redis-3.2.4.tar.gz

2. Compiling the installation

CD Redis-3.2.4make && make install

3. Copy the REDIS-TRIB.RB to the/usr/local/bin directory

CD SRCCP redis-trib.rb/usr/local/bin/

4. Create a Redis node

First, create the Redis_cluster directory under the/usr/local/redis-3.2.4 directory on the 192.168.241.132 machine;

mkdir Redis_cluster

  

Under the Redis_cluster directory, create a directory named 7000, 7001, 7002, 7003, 7004, 7005, 7006, and copy the redis.conf to these 6 directories

[[email protected] redis_cluster] #mkdir 7000 7001 7002 7003 7004 7005[[email protected] redis-3.2.4] #cp redis.conf Redis_c Luster/7000[[email protected] redis-3.2.4] #cp redis.conf redis_cluster/7001[[email protected] redis-3.2.4] #cp redis.conf redis_cluster/7002 [[email protected] redis-3.2.4] #cp redis.conf redis_cluster/7003[[email protected] redis-3.2.4] #cp redis.conf redis_cluster/7004[[email protected] redis-3.2.4] #cp redis.conf redis_cluster/7005

Modify these 6 profiles separately, modify the following:

Port  7000                                        //Ports 7000,7002,7003        bind  192.168.241.132 (native IP)                //default IP for 127.0.0.1 need to change to other node machine accessible IP Otherwise, the corresponding port cannot be accessed when the cluster is created and the cluster cannot be created
Daemonize Yes //redis background run pidfile /var/run/redis_7000.pid //pidfile file corresponds to 7000, 7001,7002cluster-enabled Yes //Turn on cluster Note # remove Cluster-config-file nodes_7000.conf //cluster configuration configuration file First start auto generate 7000,7001,7002,7003,7004,7005,7006,cluster-node-timeout 15000 //Request time -out default 15 seconds, Self-setting appendonly Yes //aof log on if necessary, it will log each write operation

5. Start each node

Redis-server Redis_cluster/7000/redis.confredis-server Redis_cluster/7001/redis.confredis-server redis_cluster/ 7002/redis.confredis-server Redis_cluster/7003/redis.confredis-server Redis_cluster/7004/redis.confredis-server Redis_cluster/7005/redis.conf

6. Check Redis boot status

[[email protected] redis-3.2.4]# ps-ef |grep redisroot       3179      1  0 00:05?        00:00:11 redis-server 192.168.241.132:7000 [cluster]root       3183      1  0 00:05?        00:00:10 redis-server 192.168.241.132:7001 [cluster]root       3187      1  0 00:05?        00:00:10 redis-server 192.168.241.132:7002 [cluster]root       3947      1  0 00:24?        00:00:08 redis-server 192.168.241.132:7003 [cluster]root       3951      1  0 00:24?        00:00:08 redis-server 192.168.241.132:7004 [cluster]root       3955      1  0 00:24?        00:00:08 redis-server 192.168.241.132:7005 [cluster]root       4973   3090  0 01:18 pts/1    00:00:00 grep-- Color=auto Redis

7. Port Usage

[[email protected] redis-3.2.4]# NETSTAT-TLNP |       grep redistcp 0 0 192.168.241.132:17000 0.0.0.0:* LISTEN 3179/redis-server 1 TCP 0 0 192.168.241.132:17001 0.0.0.0:* LISTEN 3183/redis-server 1 TCP 0 0 192.168.241.13               2:17002 0.0.0.0:* LISTEN 3187/redis-server 1 TCP 0 0 192.168.241.132:17003 0.0.0.0:*      LISTEN 3947/redis-server 1 TCP 0 0 192.168.241.132:17004 0.0.0.0:* LISTEN 3951/redis-server 1 TCP 0 0 192.168.241.132:17005 0.0.0.0:* LISTEN 3955/redis-server 1 TCP 0 0 192.168.241.132:7000 0.0.0.0:* LISTEN 3179/redis-server 1 TCP 0 0 19    2.168.241.132:7001 0.0.0.0:* LISTEN 3183/redis-server 1 TCP 0 0 192.168.241.132:7002 0.0.0.0:* LISTEN 3187/redis-server 1 TCP 0 0 192.168.241.132:7003 0.0.0.0:* LISTEN 3947/redis-server 1 TCP 0 0 192.168.241.132:7004 0.0.0.0:*      LISTEN 3951/redis-server 1 TCP 0 0 192.168.241.132:7005 0.0.0.0:* LISTEN  3955/redis-server 1

8. Create a cluster

Redis Official provides redis-trib.rb this tool, in the extracted directory src directory, the third step has copied it into the/usr/local/bin directory, can be used directly on the command line. Use the following command to complete the installation.

REDIS-TRIB.RB  Create  --replicas  1  192.168.241.132:7000 192.168.241.132:7001  192.168.241.132:7002 192.168.31.210:7003  192.168.241.132:7004  192.168.241.132:7005

  

This tool is implemented in Ruby, so you need to install Ruby. The installation command is as follows: Yum-y install ruby ruby-devel rubygems Rpm-buildgem install Redis before running the REDIS-TRIB.RB command

 

9.java jedis2.8 Operation Cluster test

public static void Main (string[] args) throws Exception {set

  

Redis 3.2 Linux Environment cluster construction and Java operations

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.