redis-master:192.168.199.223

redis-slave: 192.168.199.224

cd /opt
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar zxvf redis-4.0..tar.gz
mv redis-4.0. redis
cd redis
make&&make install
redis-master配置文件
[root@test ~]# cat /opt/redis/redis.conf |grep -Ev '^$|^#'
bind 192.168.199.223
protected-mode yes
port
tcp-backlog
timeout
tcp-keepalive
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/usr/local/log/redis-6379.log"
databases
always-show-logo yes
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
requirepass jason_zhang
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes
redis-slave配置文件
[root@jason opt]# cat /opt/redis/redis.conf|grep -Ev '^$|^#'
bind 127.0.0.1
protected-mode yes
port
tcp-backlog
timeout
tcp-keepalive
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/usr/local/log/redis-6379.log"
databases
always-show-logo yes
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slaveof 192.168.199.223
masterauth jason_zhang
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
requirepass jason_zhang
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes

启动master和slave的redis服务(如果不能同步请重启redis服务或者重启主机)

cd /usr/local/bin
./redis-server /opt/redis/redis.conf

master

添加两个键值jason 、monday 键值为jason_test    monday_test

语法  set jason   jason_test

命令 INFO 查看redis信息

redis-slave

连上redis

测试写入

测试删除

配置启动脚本

vim redis

#!/bin/bash
#chkconfig:
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem. PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis.pid
CONF="/opt/redis/redis.conf" case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${} stop
${} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&
exit
esac
# 复制脚本文件到init.d目录下
cp redis /etc/init.d/ # 给脚本增加运行权限
chmod +x /etc/init.d/redis # 添加服务
chkconfig --add redis # 配置启动级别
chkconfig --level redis on

重启redis,kill掉进程,重新启动

或者连上客户端之后,执行shutdown命令,再启动服务

设置最大内存

CONFIG SET maxmemory 100MB
CONFIG GET maxmemory

参考:http://happyqing.iteye.com/blog/2348255

https://www.cnblogs.com/stulzq/p/9288401.html

  https://www.ilanni.com/?p=11838#%E4%B8%80%E3%80%81redis%E6%BA%90%E7%A0%81%E5%AE%89%E8%A3%85

centos 7 redis-4.0.11 主从的更多相关文章

  1. redis-4.0.11主从配置初步探究

    redis-4.0.11相较于以前版本,新增了几个安全措施,稍稍研究了6379.conf配置文件,在这里记录一下. 实验环境: centos7.4 redis:redis-4.0.11 1. redi ...

  2. 配置redis 4.0.11 集群

    配置redis 4.0.11 集群 准备redis 软件和redis配置文件 启动Redis服务 /data/soft/redis/src/redis-check-aof --fix /log/red ...

  3. redis(4.0.11)编译安装

    一: redis数据库安装 系统环境:linux系统(centos/redhat):Red Hat Enterprise Linux Server release 6.8 (Santiago) red ...

  4. 在阿里云centOS7上部署Redis 5.0.5主从 + 哨兵模式

    一.在两台服务器上分别安装.配置Redis 5.0.5 ,为一主一从 安装Redis关键命令: 将安装包上传至:/home 目录下解 压:.tar.gz 安装依赖:yum install gcc 安装 ...

  5. centos安装redis 5.0版本的集群

    我在本地VM-Centos里安装5.0.5时安装遇到了些问题,参考了Blog:https://www.cnblogs.com/shawhe/p/9548620.html 顺利安装完成. 安装redis ...

  6. Redis-4.0.11集群配置

    版本:redis-3.0.5 redis-3.2.0  redis-3.2.9  redis-4.0.11 参考:http://redis.io/topics/cluster-tutorial. 集群 ...

  7. centos7用docker安装单节点redis4.0.11

    [root@localhost conf]# docker search redisINDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATEDdocker.io d ...

  8. CENTOS7下安装REDIS4.0.11

    拷贝收藏私用,别无他意,原博客地址: https://www.cnblogs.com/zuidongfeng/p/8032505.html 1.安装redis 第一步:下载redis安装包 wget ...

  9. centos / Linux 服务环境下安装 Redis 5.0.3

    原文:centos / Linux 服务环境下安装 Redis 5.0.3 1.首先进入你要安装的目录 cd /usr/local 2.下载目前最新稳定版本 Redis 5.0.3 wget http ...

随机推荐

  1. add_featurelayer_to_map

    var jsonFS = { "geometryType": "esriGeometryPolygon", "features": [ { ...

  2. PHP微信公共号授权,获取openid、unionid。

    /** * 获取code * @return code code作为换取access_token的票据,每次用户授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期 */ publ ...

  3. Android自定义View学习(四)

    硬件加速 参考:HenCoder Android 自定义 View 1-8 硬件加速 硬件加速能够让绘制变快,主要有三个原因: 本来由 CPU 自己来做的事,分摊给了 GPU 一部分,自然可以提高效率 ...

  4. Windows关闭开机自启项

    https://zhidao.baidu.com/question/562559980.html

  5. win8换win7的操作方法

    详细参考UEFI与 Legacy BIOS两种启动模式详解  BIOS的两种引导模式 win8更换win7的方法的两个步骤:    (1).设置BIOS支持Legacy启动,具体目标就是设置secur ...

  6. 网站优化--减少HTTP请求

    发送HTTP请求需要经过几个过程 域名解析--TCP连接--发送请求--等待--下载资源--解析时间 这其中需要花费一定时间,因此,尽可能的需要减少网站的HTTP请求,方法有以下几种: 1 . css ...

  7. js页面停留时间

    //在线阅读时间 function onlineRead(minutes){ var o= new Object(); o.courseId=courseId; o.userId=userId; o. ...

  8. 解决linux中ssh登录Warning:Permanently added (RSA) to the list of known hosts

    原因: 在执行scp id_rsa.pub root@hostname:/root/.ssh这一步时,没在本机的/root/.ssh下生成known_hosts文件. 解决方案: vi /etc/ss ...

  9. Zabbix使用Omsa来监控Dell服务器的硬件状态

    OMSA(Open Manage Server Administrator)是Dell主机的硬件检测和维护软件 OpenManage系统管理方案是戴尔公司基于自主研发力量开发的IT系统管理解决方案,通 ...

  10. .NET 基础知识

    .net程序基本编写.执行流程(c#)       1>编写c#代码,保存为.cs文件.       2>通过csc.exe程序来将.cs文件编译为.net程序集(.exe或.dll).此 ...