redis stand-alone multi-instance deployment

[TOC]

A, redis installation

Redis Introduction

Redis is an advanced key-value database. It is similar with memcached, but data can be persistent, and supported data types is very rich. There are strings, linked lists, hash, set and ordered set of five kinds. Calculating a set of support and on the server side, and cross-complement (-difference), etc., but also supports a variety of sorting. Therefore Redis may be viewed as a data structure of a server. All Redis data are stored in memory, and then from time to time by asynchronously save to disk (this is known as "semi-persistent mode"); can also change each time data is written to a append only file ( aof) inside (this is known as "full-persistent mode").

1. Download redis

      
      
1
2
3
4
      
      
cd /opt/work/local
wget -c http://download.redis.io/releases/redis-3.0.3.tar.gz
takes -zxvf Redis-3.0.3.tar.gz

After extracting file directory as follows:
After extracting the directory structure Redis

2. Compile redis

      
      
1
2
      
      
cd /opt/work/local/redis-3.0.3
make

3. Copy the generated executable commands

      
      
1
2
3
      
      
mkdir -p /opt/work/local/redis/bin
cd /opt/work/local/redis-3.0.3/src
cp -p redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server mkreleasehdr.sh /opt/work/local/redis/bin

4. redis service starts

(1) modify the environment variables (vim ~ / .bash_profile) as follows:

      
      
1
2
3
      
      
REDIS_HOME=/opt/work/local/redis
PATH=$PATH:$HOME/bin:$REDIS_HOME/bin

(2) 修改完成后,记得使用source ~/.bash_profile生效。

(3) 查看redis-server使用文档

      
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      
      
[@zw_25_105 local]# redis-server --help
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes>
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --slaveof 127.0.0.1 8888
./redis-server /etc/myredis.conf --loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel

(4) Starting a Single redis
using the default parameters start redis: redis-server
Specifies the port to start redis:redis-server --port 6380

(5) to allow the remote connection port redis
modify firewall configuration file as follows:

      
      
1
2
3
4
5
6
7
      
      
vim /etc/sysconfig/iptables
# Add a line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6380 -j ACCEPT
Rule # reload
service iptables restart

At this point you can use the client redis-cli connected:redis-cli -h 127.0.0.1 -p 6380

Two, redis master-slave configuration

Three, redis sentinel configuration

Fourth, the reference documentation:

Installation Redis master-slave configuration and
installation redis CentOS (a machine may be mounted a plurality redis)
building a plurality redis instances on one machine

Original: Big Box  redis stand-alone multi-instance deployment


Guess you like

Origin www.cnblogs.com/chinatrump/p/11612258.html