CONFIG REWRITE: don't throw some options on config rewrite
Those options will be thrown without this patch: include, rename-command, min-slaves-to-write, min-slaves-max-lag, appendfilename.
This commit is contained in:
parent
3b9cf3ed3a
commit
7da423f79f
27
redis.conf
27
redis.conf
@ -12,6 +12,22 @@
|
|||||||
#
|
#
|
||||||
# units are case insensitive so 1GB 1Gb 1gB are all the same.
|
# units are case insensitive so 1GB 1Gb 1gB are all the same.
|
||||||
|
|
||||||
|
################################## INCLUDES ###################################
|
||||||
|
|
||||||
|
# Include one or more other config files here. This is useful if you
|
||||||
|
# have a standard template that goes to all Redis server but also need
|
||||||
|
# to customize a few per-server settings. Include files can include
|
||||||
|
# other files, so use this wisely.
|
||||||
|
#
|
||||||
|
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
|
||||||
|
# from admin or Redis sentinel, you'd better put this option at the
|
||||||
|
# beginning of this file to avoid overwriting config change at runtime.
|
||||||
|
#
|
||||||
|
# include /path/to/local.conf
|
||||||
|
# include /path/to/other.conf
|
||||||
|
|
||||||
|
################################ GENERAL #####################################
|
||||||
|
|
||||||
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
||||||
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
||||||
daemonize no
|
daemonize no
|
||||||
@ -88,7 +104,7 @@ logfile ""
|
|||||||
# dbid is a number between 0 and 'databases'-1
|
# dbid is a number between 0 and 'databases'-1
|
||||||
databases 16
|
databases 16
|
||||||
|
|
||||||
################################ SNAPSHOTTING #################################
|
################################ SNAPSHOTTING ################################
|
||||||
#
|
#
|
||||||
# Save the DB on disk:
|
# Save the DB on disk:
|
||||||
#
|
#
|
||||||
@ -711,12 +727,3 @@ hz 10
|
|||||||
# big latency spikes.
|
# big latency spikes.
|
||||||
aof-rewrite-incremental-fsync yes
|
aof-rewrite-incremental-fsync yes
|
||||||
|
|
||||||
################################## INCLUDES ###################################
|
|
||||||
|
|
||||||
# Include one or more other config files here. This is useful if you
|
|
||||||
# have a standard template that goes to all Redis server but also need
|
|
||||||
# to customize a few per-server settings. Include files can include
|
|
||||||
# other files, so use this wisely.
|
|
||||||
#
|
|
||||||
# include /path/to/local.conf
|
|
||||||
# include /path/to/other.conf
|
|
||||||
|
29
src/config.c
29
src/config.c
@ -1469,17 +1469,6 @@ void rewriteConfigSlaveofOption(struct rewriteConfigState *state) {
|
|||||||
rewriteConfigRewriteLine(state,option,line,1);
|
rewriteConfigRewriteLine(state,option,line,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rewrite the appendonly option. */
|
|
||||||
void rewriteConfigAppendonlyOption(struct rewriteConfigState *state) {
|
|
||||||
int force = server.aof_state != REDIS_AOF_OFF;
|
|
||||||
char *option = "appendonly";
|
|
||||||
sds line;
|
|
||||||
|
|
||||||
line = sdscatprintf(sdsempty(),"%s %s", option,
|
|
||||||
(server.aof_state == REDIS_AOF_OFF) ? "no" : "yes");
|
|
||||||
rewriteConfigRewriteLine(state,option,line,force);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Rewrite the notify-keyspace-events option. */
|
/* Rewrite the notify-keyspace-events option. */
|
||||||
void rewriteConfigNotifykeyspaceeventsOption(struct rewriteConfigState *state) {
|
void rewriteConfigNotifykeyspaceeventsOption(struct rewriteConfigState *state) {
|
||||||
int force = server.notify_keyspace_events != 0;
|
int force = server.notify_keyspace_events != 0;
|
||||||
@ -1578,12 +1567,23 @@ void rewriteConfigReleaseState(struct rewriteConfigState *state) {
|
|||||||
* should be replaced by empty lines.
|
* should be replaced by empty lines.
|
||||||
*
|
*
|
||||||
* This function does just this, iterating all the option names and
|
* This function does just this, iterating all the option names and
|
||||||
* blanking all the lines still associated. */
|
* blanking all the lines still associated.
|
||||||
|
*
|
||||||
|
* Two options "include" and "rename-command" are special, they are
|
||||||
|
* just kept because struct RedisServer doesn't record them. Notice
|
||||||
|
* this also means the included config file isn't rewritten, you'd
|
||||||
|
* better put "include" at the beginning of Redis main config file
|
||||||
|
* so that runtime config change won't be canceled by conflicted
|
||||||
|
* options in the included config file. */
|
||||||
void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
|
void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
|
||||||
dictIterator *di = dictGetIterator(state->option_to_line);
|
dictIterator *di = dictGetIterator(state->option_to_line);
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
|
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
|
sds option = dictGetKey(de);
|
||||||
|
if (!strcmp(option, "include") || !strcmp(option, "rename-command"))
|
||||||
|
continue;
|
||||||
|
|
||||||
list *l = dictGetVal(de);
|
list *l = dictGetVal(de);
|
||||||
sds option = dictGetKey(de);
|
sds option = dictGetKey(de);
|
||||||
|
|
||||||
@ -1717,6 +1717,8 @@ int rewriteConfig(char *path) {
|
|||||||
rewriteConfigBytesOption(state,"repl-backlog-ttl",server.repl_backlog_time_limit,REDIS_DEFAULT_REPL_BACKLOG_TIME_LIMIT);
|
rewriteConfigBytesOption(state,"repl-backlog-ttl",server.repl_backlog_time_limit,REDIS_DEFAULT_REPL_BACKLOG_TIME_LIMIT);
|
||||||
rewriteConfigYesNoOption(state,"repl-disable-tcp-nodelay",server.repl_disable_tcp_nodelay,REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY);
|
rewriteConfigYesNoOption(state,"repl-disable-tcp-nodelay",server.repl_disable_tcp_nodelay,REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY);
|
||||||
rewriteConfigNumericalOption(state,"slave-priority",server.slave_priority,REDIS_DEFAULT_SLAVE_PRIORITY);
|
rewriteConfigNumericalOption(state,"slave-priority",server.slave_priority,REDIS_DEFAULT_SLAVE_PRIORITY);
|
||||||
|
rewriteConfigNumericalOption(state,"min-slaves-to-write",server.repl_min_slaves_to_write,REDIS_DEFAULT_MIN_SLAVES_TO_WRITE);
|
||||||
|
rewriteConfigNumericalOption(state,"min-slaves-max-lag",server.repl_min_slaves_max_lag,REDIS_DEFAULT_MIN_SLAVES_MAX_LAG);
|
||||||
rewriteConfigStringOption(state,"requirepass",server.requirepass,NULL);
|
rewriteConfigStringOption(state,"requirepass",server.requirepass,NULL);
|
||||||
rewriteConfigNumericalOption(state,"maxclients",server.maxclients,REDIS_MAX_CLIENTS);
|
rewriteConfigNumericalOption(state,"maxclients",server.maxclients,REDIS_MAX_CLIENTS);
|
||||||
rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,REDIS_DEFAULT_MAXMEMORY);
|
rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,REDIS_DEFAULT_MAXMEMORY);
|
||||||
@ -1729,7 +1731,8 @@ int rewriteConfig(char *path) {
|
|||||||
"noeviction", REDIS_MAXMEMORY_NO_EVICTION,
|
"noeviction", REDIS_MAXMEMORY_NO_EVICTION,
|
||||||
NULL, REDIS_DEFAULT_MAXMEMORY_POLICY);
|
NULL, REDIS_DEFAULT_MAXMEMORY_POLICY);
|
||||||
rewriteConfigNumericalOption(state,"maxmemory-samples",server.maxmemory_samples,REDIS_DEFAULT_MAXMEMORY_SAMPLES);
|
rewriteConfigNumericalOption(state,"maxmemory-samples",server.maxmemory_samples,REDIS_DEFAULT_MAXMEMORY_SAMPLES);
|
||||||
rewriteConfigAppendonlyOption(state);
|
rewriteConfigYesNoOption(state,"appendonly",server.aof_state != REDIS_AOF_OFF,0);
|
||||||
|
rewriteConfigStringOption(state,"appendfilename",server.aof_filename,REDIS_DEFAULT_AOF_FILENAME);
|
||||||
rewriteConfigEnumOption(state,"appendfsync",server.aof_fsync,
|
rewriteConfigEnumOption(state,"appendfsync",server.aof_fsync,
|
||||||
"everysec", AOF_FSYNC_EVERYSEC,
|
"everysec", AOF_FSYNC_EVERYSEC,
|
||||||
"always", AOF_FSYNC_ALWAYS,
|
"always", AOF_FSYNC_ALWAYS,
|
||||||
|
@ -1366,7 +1366,7 @@ void initServerConfig() {
|
|||||||
server.aof_rewrite_incremental_fsync = REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC;
|
server.aof_rewrite_incremental_fsync = REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC;
|
||||||
server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE);
|
server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE);
|
||||||
server.rdb_filename = zstrdup(REDIS_DEFAULT_RDB_FILENAME);
|
server.rdb_filename = zstrdup(REDIS_DEFAULT_RDB_FILENAME);
|
||||||
server.aof_filename = zstrdup("appendonly.aof");
|
server.aof_filename = zstrdup(REDIS_DEFAULT_AOF_FILENAME);
|
||||||
server.requirepass = NULL;
|
server.requirepass = NULL;
|
||||||
server.rdb_compression = REDIS_DEFAULT_RDB_COMPRESSION;
|
server.rdb_compression = REDIS_DEFAULT_RDB_COMPRESSION;
|
||||||
server.rdb_checksum = REDIS_DEFAULT_RDB_CHECKSUM;
|
server.rdb_checksum = REDIS_DEFAULT_RDB_CHECKSUM;
|
||||||
|
@ -113,6 +113,7 @@
|
|||||||
#define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0
|
#define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0
|
||||||
#define REDIS_DEFAULT_MAXMEMORY 0
|
#define REDIS_DEFAULT_MAXMEMORY 0
|
||||||
#define REDIS_DEFAULT_MAXMEMORY_SAMPLES 3
|
#define REDIS_DEFAULT_MAXMEMORY_SAMPLES 3
|
||||||
|
#define REDIS_DEFAULT_AOF_FILENAME "appendonly.aof"
|
||||||
#define REDIS_DEFAULT_AOF_NO_FSYNC_ON_REWRITE 0
|
#define REDIS_DEFAULT_AOF_NO_FSYNC_ON_REWRITE 0
|
||||||
#define REDIS_DEFAULT_ACTIVE_REHASHING 1
|
#define REDIS_DEFAULT_ACTIVE_REHASHING 1
|
||||||
#define REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC 1
|
#define REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC 1
|
||||||
|
Loading…
Reference in New Issue
Block a user