Redis主从配置详细过程.docx
- 文档编号:27351083
- 上传时间:2023-06-29
- 格式:DOCX
- 页数:8
- 大小:16.28KB
Redis主从配置详细过程.docx
《Redis主从配置详细过程.docx》由会员分享,可在线阅读,更多相关《Redis主从配置详细过程.docx(8页珍藏版)》请在冰豆网上搜索。
Redis主从配置详细过程
Redis主从配置详细过程
创建相关目录
#mkdir-p/apps/redis/{etc,bin,var}
#mkdir-p/apps/redis/logs/apps/redis/dbcache
编译安装
#tar-xvzfredis-2.4.13.tar.gz
#cdredis-2.4.13
#make
#cdsrc&&cpredis-serverredis-cliredis-benchmark/usr/local/redis/bin
#echo"vm.overcommit_memory=1">>/etc/sysctl.conf
#/sbin/sysctl-p
主服务器设置【192.168.1.100】
cpredis-2.4.13/redis.conf/apps/redis/etc/
#vim/apps/redis/etc/redis.conf
daemonizeyes
pidfile/usr/local/redis/var/redis.pid
port6379
bind192.168.1.100
unixsocket/usr/local/redis/var/redis.sock
unixsocketperm755
timeout300
loglevelverbose
logfile/data/logs/redis/redis.log
#syslog-enabledno
#syslog-identredis
#syslog-facilitylocal0
databases16
save9001
save30010
save6010000
rdbcompressionyes
dbfilenamedump.rdb
dir/apps/redis/dbcache
#slaveof
#masterauth
#repl-ping-slave-period10
#repl-timeout60
requirepassredis123
#rename-commandCONFIG""
maxclients10000
#maxmemory
#maxmemory-policyvolatile-lru
#maxmemory-samples3
appendonlyno
appendfilenameappendonly.aof
appendfsyncalways
no-appendfsync-on-rewriteno
auto-aof-rewrite-percentage100
auto-aof-rewrite-min-size64mb
slowlog-log-slower-than10000
slowlog-max-len128
vm-enabledno
vm-swap-file/data/dbcache/redis.swap
vm-max-memory0
vm-page-size32
vm-pages134217728
vm-max-threads4
glueoutputbufyes
hash-max-zipmap-entries512
hash-max-zipmap-value64
list-max-ziplist-entries512
list-max-ziplist-value64
set-max-intset-entries512
zset-max-ziplist-entries128
zset-max-ziplist-value64
activerehashingyes
从服务器设置【192.168.1.200】
daemonizeyes
pidfile/usr/local/redis/var/redis.pid
port6379
bind192.168.1.200
unixsocket/usr/local/redis/var/redis.sock
unixsocketperm755
timeout300
loglevelverbose
logfile/data/logs/redis/redis.log
#syslog-enabledno
#syslog-identredis
#syslog-facilitylocal0
databases16
save9001
save30010
save6010000
rdbcompressionyes
dbfilenamedump.rdb
dir/data/dbcache
#slaveof
#masterauth
#repl-ping-slave-period10
#repl-timeout60
#rename-commandCONFIG""
maxclients10000
#maxmemory
#maxmemory-policyvolatile-lru
#maxmemory-samples3
appendonlyno
appendfilenameappendonly.aof
appendfsyncalways
no-appendfsync-on-rewriteno
auto-aof-rewrite-percentage100
auto-aof-rewrite-min-size64mb
slowlog-log-slower-than10000
slowlog-max-len128
vm-enabledno
vm-swap-file/data/dbcache/redis.swap
vm-max-memory0
vm-page-size32
vm-pages134217728
vm-max-threads4
glueoutputbufyes
hash-max-zipmap-entries512
hash-max-zipmap-value64
list-max-ziplist-entries512
list-max-ziplist-value64
set-max-intset-entries512
zset-max-ziplist-entries128
zset-max-ziplist-value64
activerehashingyes
slave-serve-stale-datayes
slaveof192.168.1.1006379
masterauthredis123
启动服务:
#/apps/redis/bin/redis-server/apps/redis/etc/redis.conf
主服务器上执行:
#/apps/redis/bin/redis-cli-h192.168.1.100-aredis123settest123456
从服务器上执行:
#/apps/redis/bin/redis-cli-h192.168.1.200gettest
-----------------------------------------------------------------------------------------------------------------------------------------------
启动脚本
#vim/etc/init.d/redis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!
/bin/sh
#
#redis-thisscriptstartsandstopstheredis-serverdaemon
#
#chkconfig:
-8515
#description:
Redisisapersistentkey-valuedatabase
#processname:
redis-server
#config:
/usr/local/redis/etc/redis.conf
#pidfile:
/usr/local/redis/var/redis.pid
#Checkthatnetworkingisup.
["$NETWORKING"="no"]&&exit0
redis="/usr/local/redis/bin/redis-server"
prog=$(basename$redis)
REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf"
lockfile="/var/lock/subsys/redis"
start(){
[-x$redis]||exit5
[-f$REDIS_CONF_FILE]||exit6
echo-n$"Starting$prog:
"
$redis$REDIS_CONF_FILE
retval=$?
echo
[$retval-eq0]&&touch$lockfile
return$retval
}
stop(){
echo-n$"Stopping$prog:
"
/sbin/killproc$prog-QUIT
retval=$?
echo
[$retval-eq0]&&rm-f$lockfile
return$retval
}
restart(){
stop
sleep1
start
}
reload(){
echo-n$"Reloading$prog:
"
/sbin/killproc$redis-HUP
RETVAL=$?
echo
return$retval
}
case"$1"in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
reload)
$1
;;
*)
echo$"Usage:
$0{start|stop|restart|reload}"
exit2
esac
-----------------------------------------------------------------------------------------------------------------------------------------------
启动服务
#chmod700/etc/init.d/redis
#chkconfig--addredis
#serviceredisstart
测试是否已启动
#/usr/local/redis/bin/redis-cliping
性能测试
#/usr/local/redis/bin/redis-benchmark
关闭服务
#/usr/local/redis/bin/redis-cli-p6379shutdown
强制刷新数据到磁盘【Redis默认是异步写入磁盘的】
#/usr/local/redis/bin/redis-cli-p6379save
-----------------------------------------------------------------------------------------------------------------------------------------------
phpredis扩展安装
#svncheckout
#/usr/local/php/bin/phpize
#./configure--with-php-config=/usr/local/php/bin/php-config
#make&&makeinstall
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Redis 主从 配置 详细 过程
![提示](https://static.bdocx.com/images/bang_tan.gif)