Db1 startup Item:
./Mongod -- dbpath/data/dbdata -- logpath/data/dblog/mongodb1.log -- fork
Then set the user name and password:
Use Admin
DB. adduser ("admin", "admin ");
Use local
DB. adduser ("repl", "repl ");
Then start again as verified
./Mongod -- replset ABC -- dbpath/data/dbdata -- logpath/data/dblog/mongodb1.log -- auth -- fork
DB2 is also started in the preceding method.
----------------------------------------------------
Go to db1:
Use Admin
DB. Auth ("XXXX ");
Rs. Initiate ();
It takes 10 minutes to create a file.
Then execute Rs. Add ("db2serfer: 27017 ");
If db1 contains data, DB2 synchronizes the data.
----------------------------------------------------------
Add an arbiter
Start a server like db1.
Execute Rs. addarb ("xxxxxx: 27017") on the primary database (XXXX: Primary> ");
In this way, the arbiter is successfully added.
Execute Rs. Status (); To View, "health": 1, OK.
------------------------------------------------------------------------
Note that when adding arbiter, it must start like others, including authentication, user name and password.
When adding configuration, you need to enter the local database for verification.
-------------------------------------------------------------------------
If the new server cannot synchronize data, you can only copy the file to the new server by importing the file, and add -- fastsync.
./Mongod -- replset ABC -- dbpath/data/dbdata -- logpath/data/dblog/mongodb1.log -- auth -- fork -- fastsync