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. Maven下载私服上的jar包

    1.配置M2_HOME/conf/settions.xml <server> <id>maven-public</id> <username>admin ...

  2. MySQL 5.7 时间显示修改(log_timestamps UTC)

    https://blog.csdn.net/leshami/article/details/78952842 在MySQL 5.7版本中,日志记录时间发生了变化,使用了UTC方式来记录日志时间,也就是 ...

  3. JavaScript进行简单的随即验证码生成(适合和我一样刚入门一本完整的教材书都没看完的弟弟)

    (感谢橙旭园给我打开了前端世界的大门) var checkcode = document.getElementById("code"); var btn = document.ge ...

  4. feign client 的简单使用(1)

    依赖: <properties> <java.version>1.8</java.version> <feign-core.version>10.2.0 ...

  5. Linux kafka 单机安装

    Kafka地址(选择最新地址1.1.1) http://archive.apache.org/dist/kafka/

  6. Spring boot 日志

    修改spring boot 默认日志的配置 #logging.path= # 不指定路径在当前项目下生成springboot.log日志 # 可以指定完整的路径: #logging.file=G:/s ...

  7. iOS开发 2x 3x图

    众所周知,iOS开发中的图片资源一般需要2倍图和3倍图,也就是2x,3x,但是最近思考了一个问题,为什么不能只提供3x的图片,2x的图片让系统从3x压缩就好了,于是上网搜索了下,得到了答案. 当我们在 ...

  8. mui longtap 事件无效

    1.mui  的部分事件默认是关闭的 需要在init中单独配置事件开关 mui.init({ gestureConfig: { longtap: true, //默认为false } })

  9. Spring Cloud限流详解

    转自:https://blog.csdn.net/tracy38/article/details/78685707 在高并发的应用中,限流往往是一个绕不开的话题.本文详细探讨在Spring Cloud ...

  10. DATASNAP远程方法返回TSTREAM正解(转咏南兄)

    DATASNAP远程方法返回TSTREAM正解 DATASNAP远程方法返回TSTREAM,如果数据大小超过32K是会报错的.许多DELPHIER栽在这个上头,甚至开始怀疑TSTREAM返回数据的可行 ...