diff --git a/redis.conf b/redis.conf index 86ff1dac..4c18120e 100644 --- a/redis.conf +++ b/redis.conf @@ -12,6 +12,22 @@ # # 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. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize no @@ -88,7 +104,7 @@ logfile "" # dbid is a number between 0 and 'databases'-1 databases 16 -################################ SNAPSHOTTING ################################# +################################ SNAPSHOTTING ################################ # # Save the DB on disk: # @@ -711,12 +727,3 @@ hz 10 # big latency spikes. 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 diff --git a/src/config.c b/src/config.c index e7d2b78c..c5baab6a 100644 --- a/src/config.c +++ b/src/config.c @@ -1469,17 +1469,6 @@ void rewriteConfigSlaveofOption(struct rewriteConfigState *state) { 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. */ void rewriteConfigNotifykeyspaceeventsOption(struct rewriteConfigState *state) { int force = server.notify_keyspace_events != 0; @@ -1578,12 +1567,23 @@ void rewriteConfigReleaseState(struct rewriteConfigState *state) { * should be replaced by empty lines. * * 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) { dictIterator *di = dictGetIterator(state->option_to_line); dictEntry *de; while((de = dictNext(di)) != NULL) { + sds option = dictGetKey(de); + if (!strcmp(option, "include") || !strcmp(option, "rename-command")) + continue; + list *l = dictGetVal(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); 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,"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); rewriteConfigNumericalOption(state,"maxclients",server.maxclients,REDIS_MAX_CLIENTS); rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,REDIS_DEFAULT_MAXMEMORY); @@ -1729,7 +1731,8 @@ int rewriteConfig(char *path) { "noeviction", REDIS_MAXMEMORY_NO_EVICTION, NULL, REDIS_DEFAULT_MAXMEMORY_POLICY); 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, "everysec", AOF_FSYNC_EVERYSEC, "always", AOF_FSYNC_ALWAYS, diff --git a/src/redis.c b/src/redis.c index 0a1cdd0b..98a6f67a 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1366,7 +1366,7 @@ void initServerConfig() { server.aof_rewrite_incremental_fsync = REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC; server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE); 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.rdb_compression = REDIS_DEFAULT_RDB_COMPRESSION; server.rdb_checksum = REDIS_DEFAULT_RDB_CHECKSUM; diff --git a/src/redis.h b/src/redis.h index d9f8cc08..2db1eb3e 100644 --- a/src/redis.h +++ b/src/redis.h @@ -113,6 +113,7 @@ #define REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY 0 #define REDIS_DEFAULT_MAXMEMORY 0 #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_ACTIVE_REHASHING 1 #define REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC 1