【Redis】Redis的基本安裝及使用、Jedis的基本使用、spring-data-redis的集成、主從模式、哨兵模式


在Linux上安裝Redis

Redis的安裝很簡單。基本上是下載、解壓、運行安裝腳本。我用的Redis版本是3.2.1。

[nicchagil@localhost app]$ wget -q http://download.redis.io/releases/redis-3.2.1.tar.gz
[nicchagil@localhost app]$ 
[nicchagil@localhost app]$ ll redis-3.2.1.tar.gz 
-rw-r--r--. 1 nicchagil nicchagilg 1534696 Jun 20 08:13 redis-3.2.1.tar.gz
[nicchagil@localhost app]$ 
[nicchagil@localhost app]$ tar -xzf redis-3.2.1.tar.gz 
[nicchagil@localhost app]$ 
[nicchagil@localhost app]$ cd ./redis-3.2.1
[nicchagil@localhost redis-3.2.1]$ 
[nicchagil@localhost redis-3.2.1]$ make

啟動服務器

運行src目錄下的redis-server即可啟動Redis。

[nicchagil@localhost redis-3.2.1]$ src/redis-server 
11713:C 06 Aug 03:13:09.795 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
11713:M 06 Aug 03:13:09.803 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.1 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 11713
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

11713:M 06 Aug 03:13:09.842 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
11713:M 06 Aug 03:13:09.842 # Server started, Redis version 3.2.1
11713:M 06 Aug 03:13:09.845 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
11713:M 06 Aug 03:13:09.851 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
11713:M 06 Aug 03:13:09.852 * The server is now ready to accept connections on port 6379

從日志上大概上看出Redis已啟動,並監聽6379端口。

指定配置文件啟動

我們也可以指定配置文件啟動,比如使用安裝后自帶的配置:

[nicchagil@localhost redis-3.2.1]$ src/redis-server redis.conf

其配置默認如下,並在后面簡述其作用:

[root@blog ~]# grep -v "^#" /third_package/redis-3.2.1/redis.conf | grep -v "^$"
bind 127.0.0.1 # 允許客戶端連接的IP,任何IP都能連接配置0.0.0.0
protected-mode yes # 保護模式
port 6379 # 監聽端口
tcp-backlog 511 # TCP監聽的最大容納數量,高並發下,Linux有可能調整此值為/proc/sys/net/core/somaxconn一致,請調整此二者的值
timeout 0 # 客戶端空閑多久才關閉連接,設置0則不斷開
tcp-keepalive 300 # TCP心跳,默認建議設為300
daemonize no # 是否以守護進程運行
supervised no
pidfile /var/run/redis_6379.pid # 以守護進程運行時,此文件記錄進程ID
loglevel notice # 日志級別,debug/verbose/notice/warning,生產環境推薦用notice
logfile "" # 日志文件,空字符串表示標准輸出,請注意,當以守護進程模式運行標准輸出至/dev/null
databases 16 # 數據庫數量
save 900 1 # 如果900秒內有1個key變化,則保存快照
save 300 10 # 如果300秒內有10個key變化,則保存快照
save 60 10000 # 如果60秒內有10000個key變化,則保存快照
stop-writes-on-bgsave-error yes # 如果后台保存快照出現錯誤,是否停止接收寫操作
rdbcompression yes # 保存快照是否壓縮,壓縮則寫入操作效率低點但數據文件小點嘛,反之寫入操作塊但文件大嘛
rdbchecksum yes # 是否校驗快照
dbfilename dump.rdb # 快照文件
dir ./ # 快照文件和追加文件所在
slave-serve-stale-data yes # 當slave和master失聯或正在復制時,slave的數據可能過時,是否返回數據
slave-read-only yes # slave是否只讀
repl-diskless-sync no # 
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100 # 當master不能正常工作時,哨兵從slave中選出新的master,優先級越小越優先
appendonly no # 是否開啟追加持久化
appendfilename "appendonly.aof" # 追加文件
appendfsync everysec # 追加同步頻率
no-appendfsync-on-rewrite no # 追加同步時是否壓縮
auto-aof-rewrite-percentage 100 # 多久進行一次壓縮
auto-aof-rewrite-min-size 64mb # 
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

默認的redis.conf有幾個默認的配置設置只允許本地客戶端訪問(如果你從其他機器訪問,記得修改下哦):

  • 只允許本機客戶端連接
  • 使用保護模式
bind 127.0.0.1
......
protected-mode yes

如果你想從其他機器訪問,可改成具體IPbind xx.xx.xx.xx,如任何IP都可訪問,則bind 0.0.0.0

使用本地客戶端連接Redis

切換另外一個會話,運行src目錄下的redis-cli即可使用本地客戶端連接Redis,並測試一下基本的get命令。

[nicchagil@localhost redis-3.2.1]$ src/redis-cli 
127.0.0.1:6379> get some-key
(nil)
127.0.0.1:6379> 

使用非本地客戶端連接Redis

在此使用Java的Jeids。
為什么?只是因為公司用這個,我需要熟悉,哈哈。

引入相關包:

<dependency>
    <groupId>redis.clients</groupId>
	<artifactId>jedis</artifactId>
	<version>2.8.2</version>
</dependency>

最簡單的連接程序:

package com.nicchagil.study.jedis;

import redis.clients.jedis.Jedis;


public class HowToTest {

	public static void main(String[] args) {
		Jedis jedis = null;
		try {
			jedis = new Jedis("192.168.1.9", 6379);
			jedis.set("myname", "Nick Huang");
			String rs = jedis.get("myname");
			System.out.println(rs);
		} finally {
			if (jedis != null) {
				jedis.close();
			}
		}
	}

}

關於“非本地客戶端連接Redis”常見問題

Redis運行在保護模式,這是默認的啟動方式,提示里已經教我們如何處理了。

DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

我們可以把保護模式關掉:

[root@localhost ~]# /usr/local/redis-3.2.8/src/redis-cli 
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> config set protected-mode "no"

如果不能連接,記得檢查下是否Linux的防火牆攔截了。測試階段,最簡單的方式就是把防火牆關閉。

[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

Jedis連接池的簡單配置

Jedis自帶有連接池,是在GenericObjectPoolConfig的基礎上實現的。
具體的配置可以參考這篇博文:Jedis2.4.2鏈接池配置注釋

簡單的使用JedisPool:

package com.nicchagil.study.jedis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisPoolUtils {
	
	public static JedisPoolConfig c = new JedisPoolConfig(); // 連接池配置
	public static JedisPool jedisPool = null; // 連接池
	
	static {
		c.setBlockWhenExhausted(true); // 連接耗盡則阻塞
		c.setLifo(true); // 后進先出
		c.setMaxIdle(10); // 最大空閑連接數為10
		c.setMinIdle(0); // 最小空閑連接數為0
		c.setMaxTotal(20); // 最大連接數為20
		c.setMaxWaitMillis(-1); // 設置最大等待毫秒數:無限制
		c.setMinEvictableIdleTimeMillis(1800000); // 逐出連接的最小空閑時間:30分鍾
		c.setTestOnBorrow(true); // 獲取連接時是否檢查連接的有效性:是
		c.setTestWhileIdle(true); // 空閑時是否檢查連接的有效性:是
		
		jedisPool = new JedisPool(c, "192.168.1.9", 6379); // 初始化連接池
	}
	
	/**
	 * 獲取Jedis連接
	 * @return Jedis連接
	 */
	public static Jedis getJedis() {
		return jedisPool.getResource();
	}
	
	public static void main(String[] args) {
		/* 操作Redis */
		Jedis jedis = null;
		try {
			jedis = JedisPoolUtils.getJedis();
			jedis.set("myname", "Nick Huang");
			String rs = jedis.get("myname");
			System.out.println(rs);
		} finally {
			if (jedis != null) {
				jedis.close();
			}
		}
	}

}

用spring-data-redis集成jedis連接redis

引入相關包:

<dependency>
    <groupId>org.springframework.data</groupId>
	<artifactId>spring-data-redis</artifactId>
	<version>1.7.10.RELEASE</version>
</dependency>

<dependency>
	<groupId>redis.clients</groupId>
	<artifactId>jedis</artifactId>
	<version>2.8.2</version>
</dependency>

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>1.7.25</version>
</dependency>

<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>4.11</version>
</dependency>

配置連接池、連接工廠、操作模板:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jms="http://www.springframework.org/schema/jms" xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd   
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   
    http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">

	<!-- Spring掃描組件的路徑 -->
	<context:component-scan base-package="com.nicchagil" />

	<!-- 連接池 -->
	<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<property name="maxTotal" value="20"></property>
		<property name="maxIdle" value="10"></property>
		<property name="minIdle" value="0"></property>
		<property name="maxWaitMillis" value="-1"></property>
		<property name="minEvictableIdleTimeMillis" value="1800000"></property>
		<property name="numTestsPerEvictionRun" value="3"></property>
		<property name="timeBetweenEvictionRunsMillis" value="60000"></property>
		<property name="testOnBorrow" value="true"></property>
		<property name="testOnReturn" value="true"></property>
		<property name="testWhileIdle" value="true"></property>
	</bean>

	<!-- 連接工廠 -->
	<bean id="connectionFactory"
		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
		p:host-name="192.168.1.101" p:port="6379" p:password=""
		p:pool-config-ref="poolConfig" />

	<!-- String模板 -->
	<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
		<property name="connectionFactory" ref="connectionFactory" />
		
		<!-- 默認序列器是如下配置,看StringRedisTemplate源碼可知 -->
		<!-- 
		<property name="KeySerializer" ref="stringRedisSerializer" />
		<property name="ValueSerializer" ref="stringRedisSerializer" />
		 -->
	</bean>

	<!-- 通用模板 -->
	<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
		<property name="connectionFactory" ref="connectionFactory" />
		
		<!-- 默認序列器是如下配置,看RedisTemplate源碼可知 -->
		<!-- 
		<property name="KeySerializer" ref="jdkSerializationRedisSerializer" />
		<property name="ValueSerializer" ref="jdkSerializationRedisSerializer" />
		 -->
		 
	</bean>
	
	<!-- 各種序列器 -->
	<bean id="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer" />
	<bean id="jdkSerializationRedisSerializer" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />

</beans>

實體類:

package com.nicchagil.entity;

import java.io.Serializable;

public class User implements Serializable {
    
	private static final long serialVersionUID = -5490973977018492996L;
	
	private Integer id;
	private String name;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + "]";
	}

	public User() {
		super();
	}
	
}

操作String的Dao:

package com.nicchagil.redis.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class StringDao {
    
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	
	public void put(final String key, final String value) {
		this.stringRedisTemplate.opsForValue().set(key, value);
	}
	
	public String get(final String key) {
		return this.stringRedisTemplate.opsForValue().get(key);
	}
	
	public Long increment(final String key, final Long l) {
		return this.stringRedisTemplate.opsForValue().increment(key, l);
	}

}

操作String的測試類:

package com.nicchagil;

import java.io.IOException;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.nicchagil.redis.dao.StringDao;


public class HowToUseStringDao {

    public static void main(String[] args) throws IOException {
		try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"spring-redis.xml"})) {
			StringDao stringDao = context.getBean("stringRedisService", StringDao.class);
			stringDao.put("chinese", "中文");
		}
	}

}

操作User的Dao:

package com.nicchagil.redis.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import com.nicchagil.entity.User;

@Repository
public class UserRedisDao {
    
	@Autowired
	private RedisTemplate<Object, User> redisTemplate;
	
	public void put(final Object key, final User value) {
		this.redisTemplate.opsForValue().set(key, value);
	}
	
	public User get(final Object key) {
		return this.redisTemplate.opsForValue().get(key);
	}
	
}

操作User的測試類:

package com.nicchagil;

import java.io.IOException;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.nicchagil.entity.User;
import com.nicchagil.redis.dao.UserRedisDao;


public class HowToUseUserDao {

    public static void main(String[] args) throws IOException {
		
	}
	
	@Test
	public void put() {
		try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"spring-redis.xml"})) {
			UserRedisDao userRedisDao = context.getBean("userRedisDao", UserRedisDao.class);
			
			User user = new User();
			user.setId(5);
			user.setName("Nick Huang");
			
			userRedisDao.put("user_" + user.getId(), user);
		}
	}
	
	@Test
	public void get() {
		try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"spring-redis.xml"})) {
			UserRedisDao userRedisDao = context.getBean("userRedisDao", UserRedisDao.class);
			User user = userRedisDao.get("user_5");
			System.out.println(user);
		}
	}

}

RedisTemplate的調用邏輯

下圖為RedisTemplateopsForValue().set(key, value)的調用邏輯:

序列器的接口與實現:

配置簡單的主從模式

准備好3個redis,現在我需要配置/opt/redis/redis-3.2.1-Amaster/opt/redis/redis-3.2.1-B/opt/redis/redis-3.2.1-Cslave

修改如下配置文件分別監聽63791637926379,然后兩個slave都配置slaveof xx.xx.xx.xx 6379,其中 xx.xx.xx.xxmaster的IP(聲明:我測試的環境為3個redis均在本機,即偽集群,真集群我還沒有測試)

vi /opt/redis/redis-3.2.1-A/redis.conf
vi /opt/redis/redis-3.2.1-B/redis.conf
vi /opt/redis/redis-3.2.1-C/redis.conf

然后啟動:

/opt/redis/redis-3.2.1-A/src/redis-server /opt/redis/redis-3.2.1-A/redis.conf &
/opt/redis/redis-3.2.1-B/src/redis-server /opt/redis/redis-3.2.1-B/redis.conf &
/opt/redis/redis-3.2.1-C/src/redis-server /opt/redis/redis-3.2.1-C/redis.conf &

然后客戶連接測試,可以嘗試用info查看各redis的信息,以及在master操作/讀取數據、在slave讀取數據。:

/opt/redis/redis-3.2.1-A/src/redis-cli -p 6379
/opt/redis/redis-3.2.1-B/src/redis-cli -p 16379
/opt/redis/redis-3.2.1-C/src/redis-cli -p 26379

配置簡單的哨兵模式

默認的sentinel.conf是這樣的,另外自己加了簡述:

[root@blog redis-3.2.1-A]# grep -v "^#" /opt/redis/redis-3.2.1-A/sentinel.conf | grep -v "^$"
port 26379 # 監聽端口
dir /tmp
sentinel monitor mymaster 127.0.0.1 6379 2 # 監視127.0.0.1:6379,判斷此服務器為失效至少需要2個哨兵同意
sentinel down-after-milliseconds mymaster 30000 # 哨兵認為此服務器斷線的時間
sentinel parallel-syncs mymaster 1 # 故障轉移時,最多可以有多少slave從新master同步
sentinel failover-timeout mymaster 180000 # 故障轉移超時時間

我配置了3個哨兵,只修改哨兵的端口和監視的master的IP、端口。(本人在阿里雲上測試,啟動時報端口已被使用,我加配了bind xx.xx.xx.xx,具體資料見[環境配置]阿里雲ecs不支持redis-sentinel么?[基礎常識]在CentOS 6 運行 redis-sentinel 程序
然后就啟動了:

vi /opt/redis/redis-3.2.1-A/sentinel.conf
vi /opt/redis/redis-3.2.1-B/sentinel.conf
vi /opt/redis/redis-3.2.1-C/sentinel.conf

/opt/redis/redis-3.2.1-A/src/redis-sentinel /opt/redis/redis-3.2.1-A/sentinel.conf &
/opt/redis/redis-3.2.1-B/src/redis-sentinel /opt/redis/redis-3.2.1-B/sentinel.conf &
/opt/redis/redis-3.2.1-C/src/redis-sentinel /opt/redis/redis-3.2.1-C/sentinel.conf &

進程如下:

[root@blog ~]# ps -ef | grep redis
root     14788 13445  0 10:40 pts/1    00:00:00 /opt/redis/redis-3.2.1-A/src/redis-server xx.xx.xx.xx:6379                  
root     14793 13445  0 10:40 pts/1    00:00:00 /opt/redis/redis-3.2.1-B/src/redis-server xx.xx.xx.xx:16379                 
root     14799 13445  0 10:40 pts/1    00:00:00 /opt/redis/redis-3.2.1-C/src/redis-server xx.xx.xx.xx:26379                 
root     14916 14219  0 10:49 pts/4    00:00:00 /opt/redis/redis-3.2.1-A/src/redis-sentinel xx.xx.xx.xx:6380 [sentinel]          
root     14966 14943  0 10:50 pts/3    00:00:00 /opt/redis/redis-3.2.1-C/src/redis-sentinel xx.xx.xx.xx:26380 [sentinel]         
root     14971 14921  0 10:50 pts/2    00:00:00 /opt/redis/redis-3.2.1-B/src/redis-sentinel xx.xx.xx.xx:16380 [sentinel]

然后關閉master,會自動選其中一個slavemaster,原master再次啟動則為slave
請注意,上述的redis.conf和sentinel.conf,Redis在運行中會生成、變更部分配置,比如,故障切換master后,/redis-3.2.1-A/redis.conf的最后有如下記錄:

# Generated by CONFIG REWRITE
slaveof xx.xx.xx.xx 16379

以下命令僅為本人備份使用,無參考意義:

vi /third_package/redis-3.2.1/redis_A.conf
vi /third_package/redis-3.2.1/redis_B.conf
vi /third_package/redis-3.2.1/redis_C.conf

cp redis_A.conf /opt/redis/redis-3.2.1-A/redis.conf
cp redis_B.conf /opt/redis/redis-3.2.1-B/redis.conf
cp redis_C.conf /opt/redis/redis-3.2.1-C/redis.conf

/opt/redis/redis-3.2.1-A/src/redis-server /opt/redis/redis-3.2.1-A/redis.conf &
/opt/redis/redis-3.2.1-B/src/redis-server /opt/redis/redis-3.2.1-B/redis.conf &
/opt/redis/redis-3.2.1-C/src/redis-server /opt/redis/redis-3.2.1-C/redis.conf &

/opt/redis/redis-3.2.1-A/src/redis-cli -p 6379
/opt/redis/redis-3.2.1-B/src/redis-cli -p 16379
/opt/redis/redis-3.2.1-C/src/redis-cli -p 26379

vi /third_package/redis-3.2.1/sentinel_A.conf
vi /third_package/redis-3.2.1/sentinel_B.conf
vi /third_package/redis-3.2.1/sentinel_C.conf

cp sentinel_A.conf /opt/redis/redis-3.2.1-A/sentinel.conf
cp sentinel_B.conf /opt/redis/redis-3.2.1-B/sentinel.conf
cp sentinel_C.conf /opt/redis/redis-3.2.1-C/sentinel.conf

/opt/redis/redis-3.2.1-A/src/redis-sentinel /opt/redis/redis-3.2.1-A/sentinel.conf &
/opt/redis/redis-3.2.1-B/src/redis-sentinel /opt/redis/redis-3.2.1-B/sentinel.conf &
/opt/redis/redis-3.2.1-C/src/redis-sentinel /opt/redis/redis-3.2.1-C/sentinel.conf &

ps -ef | grep redis


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM