《实战录》导语

云端卫士《实战录》栏目定期会向粉丝朋友们分享一些在开发运维中的经验和技巧,希望对于关注我们的朋友有所裨益。本期分享人为云端卫士安全平台工程师田全磊,将带来Redis的主从服务器搭建。

Redis是一个简单快捷的key-value存储系统。它提供了丰富的数据存储结构,包括 lists, sets, ordered sets 以及 hashes ,当然还有和Memcached一样的 strings结构。同时Redis提供还对这些数据结构的丰富操作。

Redis哨兵模式介绍

Redis 的 Sentinel 功能用于管理多个 Redis 服务器,它主要提供了监控,提醒和自动故障迁移的功能。

1.监控(Monitoring): Sentinel 会不断地检查你的主服务器和从服务器是否运作正常。

2.提醒(Notification): 当被监控的某个 Redis 服务器出现问题时, Sentinel 可以通过 API 向管理员或者其他应用程序发送通知。

3.自动故障迁移(Automatic failover): 当一个主服务器不能正常工作时, Sentinel 会开始一次自动故障迁移操作, 它会将失效主服务器的其中一个从服务器升级为新的主服务器, 并让失效主服务器的其他从服务器改为复制新的主服务器; 当客户端试图连接失效的主服务器时, 集群也会向客户端返回新主服务器的地址, 使得集群可以使用新主服务器代替失效服务器。

安装

下载redis-2.8.19.tar.gz

解压tar zxf redis-2.8.19.tar.gz

安装cd redis-2.8.19

make && make install

每台机器上都同样安装redis

Redis主从环境搭建

一主:192.168.24.147

两从:192.168.24.148,192.168.24.149

(1)主192.168.24.147配置

目录:conf/redis_6379.conf

启动命令 src/redis-server conf/redis_6379.conf

daemonize yes

pidfile /export/Data/redis_pid/redis_6379.pid

port 6379

# tcp-backlog 511

timeout 300

tcp-keepalive 0

loglevel notice

logfile /export/Logs/redis/redis_6379.log

databases 16

stop-writes-on-bgsave-error yes

rdbcompression yes

dbfilename 6379.rdb

dir /export/Data/redis_data/6379

slave-serve-stale-data yes

slave-read-only yes

repl-disable-tcp-nodelay no

repl-backlog-size 128mb

maxmemory 2g

appendonly no

appendfilename 6379.aof

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

lua-time-limit 5000

slowlog-log-slower-than 10000

slowlog-max-len 1024

# notify-keyspace-events ""

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-entries 512

list-max-ziplist-value 64

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 512mb 256mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

rename-command keys jkeys

(2)从192.168.24.148配置

目录:conf/redis_6379.conf

启动命令 src/redis-server conf/redis_6379.conf

daemonize yes

slaveof 192.168.24.147 6379

pidfile /export/Data/redis_pid/redis_6379.pid

port 6379

# tcp-backlog 511

timeout 300

tcp-keepalive 0

loglevel notice

logfile /export/Logs/redis/redis_6379.log

databases 16

stop-writes-on-bgsave-error yes

rdbcompression yes

dbfilename 6379.rdb

dir /export/Data/redis_data/6379

slave-serve-stale-data yes

slave-read-only yes

repl-disable-tcp-nodelay no

repl-backlog-size 128mb

maxmemory 2g

appendonly no

appendfilename 6379.aof

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

lua-time-limit 5000

slowlog-log-slower-than 10000

slowlog-max-len 1024

# notify-keyspace-events ""

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-entries 512

list-max-ziplist-value 64

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 512mb 256mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

rename-command keys jkeys

(3)从192.168.24.149配置

目录:conf/redis_6379.conf

启动命令 src/redis-server conf/redis_6379.conf

daemonize yes

slaveof 192.168.24.147 6379

pidfile /export/Data/redis_pid/redis_6379.pid

port 6379

# tcp-backlog 511

timeout 300

tcp-keepalive 0

loglevel notice

logfile /export/Logs/redis/redis_6379.log

databases 16

stop-writes-on-bgsave-error yes

rdbcompression yes

dbfilename 6379.rdb

dir /export/Data/redis_data/6379

slave-serve-stale-data yes

slave-read-only yes

repl-disable-tcp-nodelay no

repl-backlog-size 128mb

maxmemory 2g

appendonly no

appendfilename 6379.aof

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

lua-time-limit 5000

slowlog-log-slower-than 10000

slowlog-max-len 1024

# notify-keyspace-events ""

hash-max-ziplist-entries 512

hash-max-ziplist-value 64

list-max-ziplist-entries 512

list-max-ziplist-value 64

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 512mb 256mb 60

client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

rename-command keys jkeys

实战录 | Redis的主从服务器搭建的更多相关文章

  1. 关于mysql集群主从服务器搭建

    在高并发流量下,数据库往往是服务端的瓶颈,由于数据库数据需要确保落地,同时保证数据同步,数据即时性,有效性的问题,导致数据库不能像平常后端程序一样负载均衡. 那么在大并发下,该如何缓解数据库的压力呢? ...

  2. redis的主从模式搭建及注意事项

    前言:本文先分享下如何搭建redis的主从模式配置,以及主从模式配置的注意事项.后续会继续分享如何实现一个高可用的redis服务,redis的Sentinel 哨兵模式及集群搭建. 安装: 1,yum ...

  3. sql server 分布式查询 和 主从服务器搭建

    1. 8K 对应的SQL语句限制  select  *  from openquery (recei    连接服务器名称 执行的sql 语句放在   SELECT @@SERVERNAME  在本地 ...

  4. windows下用一台机器配置分布式redis(主从服务器)

    目录1.Replication的工作原理2.如何配置Redis主从复制 1.Replication的工作原理在Slave启动并连接到Master之后,它将主动发送一条SYNC命令.此后Master将启 ...

  5. redis源码搭建以及配置主从服务器

    2018-10-25 关闭防火墙: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service # ...

  6. Redis服务器搭建/配置/及Jedis客户端的使用方法

    摘要 Redis服务器搭建.常用参数含意说明.主从配置.以及使用Jedis客户端来操作Redis Redis服务器搭建 安装 在命令行执行下面的命令: $ wget http://download.r ...

  7. redis之单机和主从环境搭建

    单机环境搭建 官网http://redis.io/download下载xxx.tar.gz二进制压缩包,注意下载2.8+版本,2.8之前的版本之前从服务器不支持部分重复制,2.6之前的版本不支持set ...

  8. 【Redis】Redis 主从模式搭建

    主从模式介绍 Redis虽然读取写入的速度都特别快,但是也会产生读压力特别大的情况.为了分担读压力,Redis支持主从复制,Redis的主从结构可以采用一主多从或者级联结构,Redis主从复制可以根据 ...

  9. 高级运维(六):源码安装Redis缓存服务、常用Redis数据库操作指令、配置Redis主从服务器

    一.源码安装Redis缓存服务 目标: 本案例要求先快速搭建好一台Redis服务器,并测试该缓存服务器: 1> 设置变量test,值为123 2> 查看变量test的值 3> 设置计 ...

随机推荐

  1. android html 图片处理类--加载富文本工具类

    在android开发中,一些资讯类页面,里面有html标签和图片,html 标签一般通过Html.fromHtml方法,即可以解决,但是如果html 有图片标签,那么,Html.fromHtml 好像 ...

  2. PHP For Windows/php-5.6.11-Win32-VC11-x64启动脚本

    启动php-cgi.bat @echo off E: cd E:\php-5.6.11-Win32-VC11-x64 php-cgi.exe -b 127.0.0.1:9000 -c php.ini- ...

  3. nginx/Windows-1.9.3启动脚本

    启动nginx.bat @echo off D: cd D:\Program Files\nginx-1.9.3 tasklist | findstr /i "nginx.exe" ...

  4. android C++环境搭建

    http://jingyan.baidu.com/article/3ea51489e7a9bd52e61bbac7.html

  5. 关于Excel导入导出的用例设计

    目前,为方便操作,很多系统都会增加批量导入导出的功能.文件导入导出一般格式都是excel.由于用户直接在excel在填写内容,无法控制填写的格 式,加上excel解析比较困难,所以一般涉及到excel ...

  6. 洛谷P3366 【模板】最小生成树

    P3366 [模板]最小生成树 319通过 791提交 题目提供者HansBug 标签 难度普及- 提交  讨论  题解 最新讨论 里面没有要输出orz的测试点 如果你用Prim写了半天都是W- 题目 ...

  7. ASP.NET中调用存储过程方法

    两种不同的存储过程调用方法 为了突出新方法的优点,首先介绍一下在.NET中调用存储过程的“官方”方法.另外,本文的所有示例程序均工作于SqlServer数据库上,其它情况类似,以后不再一一说明.本文所 ...

  8. Egret 压缩与解压(jszip)

    一 jszip是什么 二 为什么要用jszip 三 如果使用zip 一 jszip是什么 jszip 是一个 JavaScript 库,可直接在浏览器上创建 zip 压缩档. 二 为什么要用jszip ...

  9. delphi模拟按键精灵自动控制PDF页面自动扩边的源代码

    需要的环境:Adobe Acrobat 7.0 Professional  和   Quite Imposing Plus 1.5d Acrobat plugin  (qi160.exe) 程序界面: ...

  10. WebForm---增删改(内置对象)

    一.添加 前台代码: <body> <form id="form1" runat="server"> <h1>用户添加< ...