从redis配置:redis6386.conf
include /data/redis/redis6380.conf #主redis配置文件路径(这里是引用主配置文件里的配置在修改从配置)
daemonize yes #在后台启动
protected-mode no #加密保护关闭
bind 192.168.3.***
requirepass d***2018 #连接密码
dir /data/redis/redis6381Data #数据存储目录port 6386 #端口
dbfilename dump_6386.rdb #数据存储名称
pidfile /var/run/redis_6386.pid #进程pid
logfile /data/redis/logs/redis6386.log #日志#用来指定主机:slaveof 主机ip 端口
slaveof 192.168.3.*** 6380
#主机的密码
masterauth d***2018
主配置文件:redis6380.conf
#绑定IP
bind 0.0.0.0
#加密保护开启
protected-mode yes
#端口
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 300
#在后台启动
daemonize yes
supervised no
#进程pid
pidfile /var/run/redis_6381.pid
#记录日记的级别
loglevel notice
#日志存放路径
logfile "/data/redis/logs/redis6381.log"
databases 16save 900 1
save 300 10
save 60 10000stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
##数据存储文件名
dbfilename dump6381.rdb
#数据存储目录
dir /data/redis/redis6381Dataslave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100#连接密码
requirepass d***2018
#最大连接客户端数量
maxclients 35000
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 10000slowlog-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 64hll-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
/etc/rc.d/init.d目录下配置开机启动redis6381配置文件
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value databaseREDISPORT=6381
#EXEC=/usr/local/bin/redis-server
EXEC=/usr/local/redis-3.2.9-6381/src/redis-server#CLIEXEC=/usr/local/bin/redis-cli
CLIEXEC=/usr/local/redis-3.2.9-6381/src/redis-cli#PIDFILE=/var/run/redis_${REDISPORT}.pid
PIDFILE=/var/run/redis_${REDISPORT}.pid
#CONF="/etc/redis/${REDISPORT}.conf"
CONF="/data/redis/redis${REDISPORT}.conf"#从redis最好休眠下,让主redis启动完成再启动
#sleep 60case "$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, process is already running or crashed"elseecho "Starting Redis server..."$EXEC $CONFfi;;stop)if [ ! -f $PIDFILE ]thenecho "$PIDFILE does not exist, process is not running"elsePID=$(cat $PIDFILE)echo "Stopping ..."$CLIEXEC -p $REDISPORT shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown ..."sleep 1doneecho "Redis stopped"fi;;*)echo "Please use start or stop as first argument";;
esac
#设置为开机自启动服务器
chkconfig redisd on#设置为开机关闭自启动服务器
chkconfig redis off#打开服务
service redisd start#关闭服务
service redisd stop
查询开机启动列表
chkconfig --list
如果看到redisd的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 redisd on