Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
8996bf77
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8996bf77
编写于
10月 31, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7c6da732
上级
58732c23
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
6 deletion
+33
-6
redis.conf
redis.conf
+11
-0
src/config.c
src/config.c
+12
-0
src/redis.c
src/redis.c
+2
-0
src/redis.h
src/redis.h
+5
-0
src/replication.c
src/replication.c
+3
-6
未找到文件。
redis.conf
浏览文件 @
8996bf77
...
...
@@ -135,6 +135,17 @@ dir ./
#
slave
-
serve
-
stale
-
data
yes
# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#
# repl_ping_slave_period 10
# The following option sets a timeout for both Bulk transfer I/O timeout and
# master data or ping response timeout. The default value is 60 seconds.
#
# repl_timeout 60
################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
...
...
src/config.c
浏览文件 @
8996bf77
...
...
@@ -194,6 +194,18 @@ void loadServerConfig(char *filename) {
server
.
masterhost
=
sdsnew
(
argv
[
1
]);
server
.
masterport
=
atoi
(
argv
[
2
]);
server
.
replstate
=
REDIS_REPL_CONNECT
;
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"repl-ping-slave-period"
)
&&
argc
==
2
)
{
server
.
repl_ping_slave_period
=
atoi
(
argv
[
1
]);
if
(
server
.
repl_ping_slave_period
<=
0
)
{
err
=
"repl-ping-slave-period must be 1 or greater"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"repl-timeout"
)
&&
argc
==
2
)
{
server
.
repl_timeout
=
atoi
(
argv
[
1
]);
if
(
server
.
repl_timeout
<=
0
)
{
err
=
"repl-timeout must be 1 or greater"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"masterauth"
)
&&
argc
==
2
)
{
server
.
masterauth
=
zstrdup
(
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"slave-serve-stale-data"
)
&&
argc
==
2
)
{
...
...
src/redis.c
浏览文件 @
8996bf77
...
...
@@ -869,6 +869,8 @@ void initServerConfig() {
server
.
zset_max_ziplist_entries
=
REDIS_ZSET_MAX_ZIPLIST_ENTRIES
;
server
.
zset_max_ziplist_value
=
REDIS_ZSET_MAX_ZIPLIST_VALUE
;
server
.
shutdown_asap
=
0
;
server
.
repl_ping_slave_period
=
REDIS_REPL_PING_SLAVE_PERIOD
;
server
.
repl_timeout
=
REDIS_REPL_TIMEOUT
;
server
.
cluster_enabled
=
0
;
server
.
cluster
.
configfile
=
zstrdup
(
"nodes.conf"
);
server
.
lua_time_limit
=
REDIS_LUA_TIME_LIMIT
;
...
...
src/redis.h
浏览文件 @
8996bf77
...
...
@@ -57,6 +57,9 @@
#define REDIS_SLOWLOG_MAX_LEN 64
#define REDIS_MAX_CLIENTS 10000
#define REDIS_REPL_TIMEOUT 60
#define REDIS_REPL_PING_SLAVE_PERIOD 10
/* Hash table parameters */
#define REDIS_HT_MINFILL 10
/* Minimal hash table fill 10% */
...
...
@@ -591,6 +594,8 @@ struct redisServer {
char
*
masterauth
;
char
*
masterhost
;
int
masterport
;
int
repl_ping_slave_period
;
int
repl_timeout
;
redisClient
*
master
;
/* client that is master for this slave */
int
repl_syncio_timeout
;
/* timeout for synchronous I/O calls */
int
replstate
;
/* replication status if the instance is a slave */
...
...
src/replication.c
浏览文件 @
8996bf77
...
...
@@ -504,13 +504,10 @@ void slaveofCommand(redisClient *c) {
/* --------------------------- REPLICATION CRON ---------------------------- */
#define REDIS_REPL_TIMEOUT 60
#define REDIS_REPL_PING_SLAVE_PERIOD 10
void
replicationCron
(
void
)
{
/* Bulk transfer I/O timeout? */
if
(
server
.
masterhost
&&
server
.
replstate
==
REDIS_REPL_TRANSFER
&&
(
time
(
NULL
)
-
server
.
repl_transfer_lastio
)
>
REDIS_REPL_TIMEOUT
)
(
time
(
NULL
)
-
server
.
repl_transfer_lastio
)
>
server
.
repl_timeout
)
{
redisLog
(
REDIS_WARNING
,
"Timeout receiving bulk data from MASTER..."
);
replicationAbortSyncTransfer
();
...
...
@@ -518,7 +515,7 @@ void replicationCron(void) {
/* Timed out master when we are an already connected slave? */
if
(
server
.
masterhost
&&
server
.
replstate
==
REDIS_REPL_CONNECTED
&&
(
time
(
NULL
)
-
server
.
master
->
lastinteraction
)
>
REDIS_REPL_TIMEOUT
)
(
time
(
NULL
)
-
server
.
master
->
lastinteraction
)
>
server
.
repl_timeout
)
{
redisLog
(
REDIS_WARNING
,
"MASTER time out: no data nor PING received..."
);
freeClient
(
server
.
master
);
...
...
@@ -536,7 +533,7 @@ void replicationCron(void) {
* So slaves can implement an explicit timeout to masters, and will
* be able to detect a link disconnection even if the TCP connection
* will not actually go down. */
if
(
!
(
server
.
cronloops
%
(
REDIS_REPL_PING_SLAVE_PERIOD
*
10
)))
{
if
(
!
(
server
.
cronloops
%
(
server
.
repl_ping_slave_period
*
10
)))
{
listIter
li
;
listNode
*
ln
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录