Tag Archives: Redis startup error

[Solved] Redis Startup Error: FATAL CONFIG FILE ERROR

1.Redis Startup Error: Reading the configuration file, at line 194>>> ‘always-show-logo yes’Bad directive or wrong number of arguments
Error Messages:

[root@xxx-0001 src]# redis-server /etc/redis-cluster/redis-7001.conf
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 194
>>> 'always-show-logo yes'
Bad directive or wrong number of arguments

Cause analysis:

Error means that the specified configuration file directory is wrong or the number of parameters in the configuration file is wrong
the reason is that redis-4.0 is installed for the first time At 8:00, the environment variable is written. When redis server is executed, it will first query whether this instruction is configured in the environment variable,
it is found that there is (or the old 4.0.8) However, the configuration file used is 5.0 To sum up, the redis server in the environment variable is imported from my previous version. If I change the version of redis, I can’t use the previously imported environment variable to execute

Solution:

From this point of view, the solution is clear:
method 1: re import the redis server of the new version of redis to the environment variable
method 2: directly use the redis server in the new version of redis to execute the startup command

Finally, let’s see the situation after the solution

[root@xxx-0001 src]# ./redis-server /etc/redis-cluster/redis-7001.conf
27895:C 06 Dec 2021 13:09:29.818 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27895:C 06 Dec 2021 13:09:29.818 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=27895, just started
27895:C 06 Dec 2021 13:09:29.818 # Configuration loaded
[root@apm-0003 src]# ./redis-server /etc/redis-cluster/redis-7002.conf
27952:C 06 Dec 2021 13:09:37.218 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27952:C 06 Dec 2021 13:09:37.218 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=27952, just started
27952:C 06 Dec 2021 13:09:37.218 # Configuration loaded
[root@apm-0003 src]# ./redis-server /etc/redis-cluster/redis-7003.conf
27996:C 06 Dec 2021 13:09:40.829 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27996:C 06 Dec 2021 13:09:40.829 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=27996, just started
27996:C 06 Dec 2021 13:09:40.829 # Configuration loaded
[root@apm-0003 src]# ./redis-server /etc/redis-cluster/redis-7004.conf
28021:C 06 Dec 2021 13:09:43.651 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
28021:C 06 Dec 2021 13:09:43.651 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=28021, just started
28021:C 06 Dec 2021 13:09:43.651 # Configuration loaded
[root@apm-0003 src]# ./redis-server /etc/redis-cluster/redis-7005.conf
28065:C 06 Dec 2021 13:09:46.736 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
28065:C 06 Dec 2021 13:09:46.737 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=28065, just started
28065:C 06 Dec 2021 13:09:46.737 # Configuration loaded
[root@apm-0003 src]# ./redis-server /etc/redis-cluster/redis-7006.conf
28124:C 06 Dec 2021 13:09:50.963 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
28124:C 06 Dec 2021 13:09:50.963 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=28124, just started
28124:C 06 Dec 2021 13:09:50.963 # Configuration loaded
[root@xxx-0001 src]# ps -ef|grep redis
root      6227     1  0 12:35 ?       00:00:04 redis-server 0.0.0.0:6379
root     27896     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7001 [cluster]
root     27953     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7002 [cluster]
root     27998     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7003 [cluster]
root     28022     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7004 [cluster]
root     28066     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7005 [cluster]
root     28125     1  0 13:09 ?       00:00:00 ./redis-server 0.0.0.0:7006 [cluster]
root     28276  4581  0 13:10 pts/4    00:00:00 grep --color=auto redis

[Solved] redis Startup Error: Creating Server TCP listening socket 127.0. 0.1:6379: bind: no error redis

Error: [52904] 08 Dec 15:09:41.278 # creating server TCP listening socket 127.0 0.1:6379: bind: No error

Solution:

You can connect successfully by entering the following commands in sequence

D:\zip\redis\Redis-x64-3.2.100>redis-server.exe redis.windows.conf
[52904] 08 Dec 15:09:41.278 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error

D:\zip\redis\Redis-x64-3.2.100>redis-cli.exe
127.0.0.1:6379> shutdown
not connected> exit

D:\zip\redis\Redis-x64-3.2.100>redis-server.exe  redis.windows.conf
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.2.100 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._   /    _.-'    |     PID: 47344
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

[47344] 08 Dec 15:10:36.580 # Server started, Redis version 3.2.100
[47344] 08 Dec 15:10:36.583 * DB loaded from disk: 0.000 seconds
[47344] 08 Dec 15:10:36.584 * The server is now ready to accept connections on port 6379

Redis Startup Error: Creating Server TCP listening socket 127.0.0.1:6379: bind: No error

Today, the redis service started in the window and reported an error:
Creating server TCP listening socket 127.0.0.1:6379: bind no error

The reason is that redis did not shut down normally after it was started;

The solution is as follows: enter the following commands in order to connect successfully

redis-cli.exe
shutdown
exit

Redis closes normally, exits, and then re-enter the command to start
redis-server.exe redis.windows.conf

OK!

[Solved] Redis startup error Creating Server TCP listening socket 127.0.0.1:6379: bind: No error

When installing Redis under windows, an error is reported at the first startup:

[2368] 21 Apr 02:57:05.611 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error

Solution: Run in the command line

redis-cli.exe

127.0.0.1:6379>shutdown

not connected>exit

Then re-run redis-server.exe redis.windows.conf, the startup is successful!

Start Redis

Open the command window directly in the directory above, and run:

  1. redis – server redis windows conf

The results on the tragedy, QForkMasterInit: system error caught. error code=0x000005af, message=VirtualAllocEx failed.: unknown error tips: . The reason is the memory allocation problem (if your computer is powerful enough, it may not be a problem). There are two solutions. First: Use --maxmemory commands to limit Redis memory at startup :

  1. redis – server redis windows conf  – maxmemory  200m

The second method is to modify the configuration file redis.windows.conf :

  1. maxmemory  209715200

Note that the unit is byte, after the change is as follows:

Then run redis-server redis.windows.conf it to start:

But here comes the problem again. Redis will be closed when the cmd window is closed. Is it necessary to keep the server open? This is obviously unscientific, let’s see how to deploy on the server.

Deploy Redis

In fact, Redis can be installed as a windows service. It starts automatically after booting. The command is as follows:

  1. redis – server  – service – install redis windows conf

After the installation is complete, you can see that Redis has been used as a windows service:

But after the installation, Redis did not start, the startup command is as follows:

  1. redis – server  – service – start

Stop command:

  1. redis – server  – service – stop

(2) unrecoverable error: corrupted cluster config file

stay https://blog.csdn.net/zly_ On the basis of this blog post 9117 / article / details / 83349778, we found another error when starting redis. The error content is as follows

➜  7000 ../redis-server redis.conf &
[1] 11045
11045:C 24 Oct 2018 19:26:52.320 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11045:C 24 Oct 2018 19:26:52.320 # Redis version=999.999.999, bits=64, commit=54e8dd11, modified=0, pid=11045, just started
11045:C 24 Oct 2018 19:26:52.320 # Configuration loaded
11045:M 24 Oct 2018 19:26:52.322 * Increased maximum number of open files to 10032 (it was originally set to 7168).
11045:M 24 Oct 2018 19:26:52.323 # Unrecoverable error: corrupted cluster config file.

The literal meaning is a damaged cluster configuration. Similarly, find the corresponding error throw point in the source code and find the following information

1. The output point of the error log is the code below

fmterr:
    serverLog(LL_WARNING,
        "Unrecoverable error: corrupted cluster config file.");
    zfree(line);
    if (fp) fclose(fp);
    exit(1);
}

According to the source code interpretation found that we did not build nodes.conf By default, this method returns a C_ Err, and then the caller clusterinit function creates a new file and a cluster. The overall code of clusterloadconfig function is as follows. But now I found this document and read it to prove it wrong redis.conf There is an error in the configuration file. After searching the configuration file, it is found that the parameter of cluster config file is configured incorrectly, and it is changed to cluster config file nodes.conf Problem solving.

/* Load the cluster config from 'filename'.
 *
 * If the file does not exist or is zero-length (this may happen because
 * when we lock the nodes.conf file, we create a zero-length one for the
 * sake of locking if it does not already exist), C_ERR is returned.
 * If the configuration was loaded from the file, C_OK is returned. */
int clusterLoadConfig(char *filename) {
    FILE *fp = fopen(filename,"r");
    struct stat sb;
    char *line;
    int maxline, j;

    if (fp == NULL) {
        if (errno == ENOENT) {
            return C_ERR;
        } else {
            serverLog(LL_WARNING,
                "Loading the cluster node config from %s: %s",
                filename, strerror(errno));
            exit(1);
        }
    }

    /* Check if the file is zero-length: if so return C_ERR to signal
     * we have to write the config. */
    if (fstat(fileno(fp),&sb) != -1 && sb.st_size == 0) {
        fclose(fp);
        return C_ERR;
    }

    /* Parse the file. Note that single lines of the cluster config file can
     * be really long as they include all the hash slots of the node.
     * This means in the worst possible case, half of the Redis slots will be
     * present in a single line, possibly in importing or migrating state, so
     * together with the node ID of the sender/receiver.
     *
     * To simplify we allocate 1024+CLUSTER_SLOTS*128 bytes per line. */
    maxline = 1024+CLUSTER_SLOTS*128;
    line = zmalloc(maxline);
    while(fgets(line,maxline,fp) != NULL) {
        int argc;
        sds *argv;
        clusterNode *n, *master;
        char *p, *s;

        /* Skip blank lines, they can be created either by users manually
         * editing nodes.conf or by the config writing process if stopped
         * before the truncate() call. */
        if (line[0] == '\n' || line[0] == '\0') continue;

        /* Split the line into arguments for processing. */
        argv = sdssplitargs(line,&argc);
        if (argv == NULL) goto fmterr;

        /* Handle the special "vars" line. Don't pretend it is the last
         * line even if it actually is when generated by Redis. */
        if (strcasecmp(argv[0],"vars") == 0) {
            for (j = 1; j < argc; j += 2) {
                if (strcasecmp(argv[j],"currentEpoch") == 0) {
                    server.cluster->currentEpoch =
                            strtoull(argv[j+1],NULL,10);
                } else if (strcasecmp(argv[j],"lastVoteEpoch") == 0) {
                    server.cluster->lastVoteEpoch =
                            strtoull(argv[j+1],NULL,10);
                } else {
                    serverLog(LL_WARNING,
                        "Skipping unknown cluster config variable '%s'",
                        argv[j]);
                }
            }
            sdsfreesplitres(argv,argc);
            continue;
        }

        /* Regular config lines have at least eight fields */
        if (argc < 8) goto fmterr;

        /* Create this node if it does not exist */
        n = clusterLookupNode(argv[0]);
        if (!n) {
            n = createClusterNode(argv[0],0);
            clusterAddNode(n);
        }
        /* Address and port */
        if ((p = strrchr(argv[1],':')) == NULL) goto fmterr;
        *p = '\0';
        memcpy(n->ip,argv[1],strlen(argv[1])+1);
        char *port = p+1;
        char *busp = strchr(port,'@');
        if (busp) {
            *busp = '\0';
            busp++;
        }
        n->port = atoi(port);
        /* In older versions of nodes.conf the "@busport" part is missing.
         * In this case we set it to the default offset of 10000 from the
         * base port. */
        n->cport = busp ? atoi(busp) : n->port + CLUSTER_PORT_INCR;

        /* Parse flags */
        p = s = argv[2];
        while(p) {
            p = strchr(s,',');
            if (p) *p = '\0';
            if (!strcasecmp(s,"myself")) {
                serverAssert(server.cluster->myself == NULL);
                myself = server.cluster->myself = n;
                n->flags |= CLUSTER_NODE_MYSELF;
            } else if (!strcasecmp(s,"master")) {
                n->flags |= CLUSTER_NODE_MASTER;
            } else if (!strcasecmp(s,"slave")) {
                n->flags |= CLUSTER_NODE_SLAVE;
            } else if (!strcasecmp(s,"fail?")) {
                n->flags |= CLUSTER_NODE_PFAIL;
            } else if (!strcasecmp(s,"fail")) {
                n->flags |= CLUSTER_NODE_FAIL;
                n->fail_time = mstime();
            } else if (!strcasecmp(s,"handshake")) {
                n->flags |= CLUSTER_NODE_HANDSHAKE;
            } else if (!strcasecmp(s,"noaddr")) {
                n->flags |= CLUSTER_NODE_NOADDR;
            } else if (!strcasecmp(s,"nofailover")) {
                n->flags |= CLUSTER_NODE_NOFAILOVER;
            } else if (!strcasecmp(s,"noflags")) {
                /* nothing to do */
            } else {
                serverPanic("Unknown flag in redis cluster config file");
            }
            if (p) s = p+1;
        }

        /* Get master if any. Set the master and populate master's
         * slave list. */
        if (argv[3][0] != '-') {
            master = clusterLookupNode(argv[3]);
            if (!master) {
                master = createClusterNode(argv[3],0);
                clusterAddNode(master);
            }
            n->slaveof = master;
            clusterNodeAddSlave(master,n);
        }

        /* Set ping sent / pong received timestamps */
        if (atoi(argv[4])) n->ping_sent = mstime();
        if (atoi(argv[5])) n->pong_received = mstime();

        /* Set configEpoch for this node. */
        n->configEpoch = strtoull(argv[6],NULL,10);

        /* Populate hash slots served by this instance. */
        for (j = 8; j < argc; j++) {
            int start, stop;

            if (argv[j][0] == '[') {
                /* Here we handle migrating / importing slots */
                int slot;
                char direction;
                clusterNode *cn;

                p = strchr(argv[j],'-');
                serverAssert(p != NULL);
                *p = '\0';
                direction = p[1]; /* Either '>' or '<' */
                slot = atoi(argv[j]+1);
                if (slot < 0 || slot >= CLUSTER_SLOTS) goto fmterr;
                p += 3;
                cn = clusterLookupNode(p);
                if (!cn) {
                    cn = createClusterNode(p,0);
                    clusterAddNode(cn);
                }
                if (direction == '>') {
                    server.cluster->migrating_slots_to[slot] = cn;
                } else {
                    server.cluster->importing_slots_from[slot] = cn;
                }
                continue;
            } else if ((p = strchr(argv[j],'-')) != NULL) {
                *p = '\0';
                start = atoi(argv[j]);
                stop = atoi(p+1);
            } else {
                start = stop = atoi(argv[j]);
            }
            if (start < 0 || start >= CLUSTER_SLOTS) goto fmterr;
            if (stop < 0 || stop >= CLUSTER_SLOTS) goto fmterr;
            while(start <= stop) clusterAddSlot(n, start++);
        }

        sdsfreesplitres(argv,argc);
    }
    /* Config sanity check */
    if (server.cluster->myself == NULL) goto fmterr;

    zfree(line);
    fclose(fp);

    serverLog(LL_NOTICE,"Node configuration loaded, I'm %.40s", myself->name);

    /* Something that should never happen: currentEpoch smaller than
     * the max epoch found in the nodes configuration. However we handle this
     * as some form of protection against manual editing of critical files. */
    if (clusterGetMaxEpoch() > server.cluster->currentEpoch) {
        server.cluster->currentEpoch = clusterGetMaxEpoch();
    }
    return C_OK;

fmterr:
    serverLog(LL_WARNING,
        "Unrecoverable error: corrupted cluster config file.");
    zfree(line);
    if (fp) fclose(fp);
    exit(1);
}