Connecting to the MongoDB server

When AxoSyslog connects the MongoDB server during startup, it completes the following steps.

  1. The AxoSyslog application connects the first address listed in the servers() option.

    • If the server is accessible and it is a master MongoDB server, AxoSyslog authenticates on the server (if needed), then starts sending the log messages to the server.

    • If the server is not accessible, or it is not a master server in a MongoDB replicaset and it does not send the address of the master server, AxoSyslog connects the next address listed in the servers() option.

    • If the server is not a master server in a MongoDB replicaset, but it sends the address of the master server, AxoSyslog connects the received address.

  2. When AxoSyslog connects the master MongoDB server, it retrieves the list of replicas (from the replSet option of the server), and appends this list to the servers() option.

  3. The AxoSyslog application attempts to connect another server if the servers() list contains at least two addresses, and one of the following events happens:

    • The safe-mode() option is set to no, and the MongoDB server becomes unreachable.

    • The safe-mode() option is set to yes, and AxoSyslog cannot insert a log message into the database because of an error.

    In this case, AxoSyslog starts to connect the addresses in from the servers() list (starting from the first address) to find the new master server, authenticates on the new server (if needed), then continues to send the log messages to the new master server.

    During this failover step, one message can be lost if the safe-mode() option is disabled.

  4. If the original master becomes accessible again, AxoSyslog will automatically connect to the original master.