Yes, it is possible.
In my last post see this following step:
Connect to the primary and remove the member from the replica-set:
rs.remove(“localhost:27012”)
rs.status() // or rs.isMaster(), and verify both before and after the remove.
From this point you can do the following steps:
Use the configuration for the member “localhost:27012” with the same dbPath
, etc., but without the replication
option. For example, newConfig.cfg
:
storage:
dbPath: C:\mongo\data\replset\rs3\db
net:
bindIp: localhost
port: 27012
systemLog:
destination: file
path: C:\mongo\data\replset\rs3\mongod.log
logAppend: true
# replication:
# replSetName: myrset
If you specifying the parameters at command-line, start the mongod
without the --replSet
parameter, but pointing to the same data directory (the --dbpath
parameter).
1. Restart the member as a standalone:
> mongod -f newConfig.cfg
Connect to it from mongo
shell, and:
use local
show collections
oplog.rs
…
These collections in local
database are related to replication.
2. Drop this local
database and shutdown the server:
use local
db.dropDatabase()
use admin
db.shutdownServer()
3. Restart the server:
Now, specify the --replSet
parameter, but with a new replica set name. Or in the configuration file newConfig.cfg
specify the options with new replica set name. For example:
replication:
replSetName: RS-1
> mongod -f newConfig.cfg
Connect to it from mongo
shell.
3.1. Initiate the new replica-set.
rs.initiate()
This member becomes the primary of the newly created replica-set. Verify:
rs.isMaster()