Databases Reference
In-Depth Information
--oplogSize
. To change the oplog size to
size
, we shut down the master and run the
following:
$ rm /data/db/local.*
$ ./mongod --master --oplogSize
size
size
is specified in megabytes.
Preallocating space for a large oplog can be time-consuming and might
cause too much downtime for the master node. It is possible to manually
preallocate data files for MongoDB if that is the case; see the
MongoDB
documentation on halted replication
for more detailed information.
After restarting the master, any slaves should either be restarted with the
--autoresync
or have a manual resync performed.
Replication with Authentication
If you are using replication in tandem with MongoDB's support for authentication (see
“Authentication Basics” on page 118
), there is some additional configuration that needs
to be performed to allow the slave to access the data on the master. On both the master
and the slave, a user needs to be added to the
local
database, with the same username
and password on each node. Users on the
local
database are similar to users on
ad-
min
; they have full read and write permissions on the server.
When the slave attempts to connect to the master, it will authenticate using a user
stored in
local.system.users
. The first username it will try is “repl,” but if no such user
is found, it will just use the first available user in
local.system.users
. So, to set up
replication with authentication, run the following code on both the master
and
any
slaves, replacing
password
with a secure password:
> use local
switched to db local
> db.add User("repl",
password
);
{
"user" : "repl",
"readOnly" : false,
"pwd" : "..."
}
The slave will then be able to replicate from the master.