简体   繁体   中英

How do I make a mongodb replica set node "startup" after the server restarts?

I have 3 servers running a MongoDB replica set. I currently start the node like this after restarting a server:

mongod --replSet "name_of_replicaset" --bind_ip localhost,this_server_hostname_in_host_file --fork --syslog --auth --keyFile "path_to_file"

The problem is that I have to do this every single time I restart a server. I've checked online and the official documentation for MongoDB but I cannot find a way to make the server startup the node by itself.

Is there a way to have the server startup the node after it restarting?

You can do this using systemctl.

Create a service for this and enable the same via systemctl enable command. It will automatically start once you restart the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM