Redis Cluster Deployment--instances

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

1 Installation Environment

jdk1.8.0 Redis 3.0.6

Dual-Machine master-slave, 192.168.1.5 Master 192.168.1.6 from

Do a Redis cache server with Sentinel monitoring redis for HA


2 installation Configuration

Install the JDK environment first (please adjust the environment yourself)

Install Redis-master and Redis-slave separately

Yum Install-y Redis


Configuring Redis-master 192.168.1.5

Vim/etc/redis.conf

Daemonize Yes

Pidfile/var/run/redis/redis.pid

Port 6379

Bind 192.168.1.5

Logfile/var/log/redis/redis.log

MaxMemory 2165625 #内存2G

Maxmemory-policy Volatile-lru #内存紧张时用lru算法清除数据

AppendOnly Yes #开启AOF持久化

Appendfilename appendonly.aof

Appendfsync everysec #每秒钟写一次磁盘

No-appendfsync-on-rewrite Yes #日志重写, do not append command

Auto-aof-rewrite-percentage #AOF超过一定大小, auto start new rewrite

Auto-aof-rewrite-min-size 64MB #启动新重写的最小值


Vim/etc/redis-sentinel.conf

Port 26379

Sentinel Monitor MyMaster 192.168.1.5 6379 1 #指定要监控的机器

Sentinel Down-after-milliseconds MyMaster #判断down机时间5秒

Sentinel Failover-timeout MyMaster 60000 #故障转移时间1分钟

Sentinel Parallel-syncs MyMaster 1 #通过slave确认宕机


Configuring Redis-slave 192.168.1.6

Vim/etc/redis.conf

Daemonize Yes

Pidfile/var/run/redis/redis.pid

Port 6379

Bind 192.168.1.6

Slaveof 192.168.1.5 6379

LogLevel Notice

Logfile/var/log/redis/redis.log

MaxMemory 2165625

Maxmemory-policy VOLATILE-LRU

AppendOnly Yes

Appendfilename appendonly.aof

Appendfsync everysec

No-appendfsync-on-rewrite Yes

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64MB


Vim/etc/redis-sentinel.conf

Port 26379

Sentinel Monitor MyMaster 192.168.1.5 6379 1

Sentinel Down-after-milliseconds MyMaster 5000

Sentinel Failover-timeout MyMaster 60000

Sentinel Parallel-syncs MyMaster 1


Start Redis

/usr/bin/redis-server/etc/redis.conf Guthrie after the

Then launch Sentinel.

/usr/bin/redis-sentinel/etc/redis-sentinel.conf Guthrie after the


Testing a Redis Cluster

Login redis-master192.168.1.5

/usr/bin/redis-cli-h 192.168.1.5-p 6379 into the client command

192.168.1.5:6379 >set Test 123456

Ok

192.168.1.5:6379 >get Test

"123456"

Boarded slave to do the same test


Stop Redis Service (note the sequencing)

Stop Sentinel Service First

Ps-ef |grep Sentinel

Kill-9 PID

Then stop slave.

192.168.1.6:6379 >shutdown

Finally Stop master

192.168.1.5:6379 >shutdown


Complete




This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1891845

Redis Cluster Deployment--instances

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.