MongoDB Index Setup Issues

Source: Internet
Author: User
Tags mongodb mongodb version terminates
MongoDB Index Setup Issues


1. The master-Slave library index is not set up synchronously:



MONGODB version 2.6.6, indexing is not synchronized, but is then indexed from the library after the main library is established.
I do not know whether the 3.0 version is the same, the previous use of version 3.0 did not monitor the master and subordinate log. The hole is too big.
5:00 set up to complete the main library is OK.

Official Description:
Background Index Build (page 491) allowed on secondaries. If you initiate a background index builds on a
Primary, the secondaries would replicate the index build in the background.

Automatic rebuild of interrupted index builds after a restart.
–if a standalone or a primary instance terminates during a index build without a clean shutdown, mongod
Now restarts the "index build" when the instance restarts. If the instance shuts down cleanly or if a user kills
The index build, the interrupted index builds does not automatically restart upon the restart of the server.
–if a secondary instance terminates during a index build, the Mongod instance would now restart the interrupted index Bui LD when the instance restarts.
To disable this behavior and use the--noindexbuildretry command-line option.


Indexing from a library is too long, and if the interrupt is indexed from the library, you can restart using the--noindexbuildretry parameter.
I didn't know this parameter at the beginning, so I deleted the previously established index directly in the main library.


It feels good to see people on the internet like this:

1. Stop the secondary server first, restart MongoDB after canceling the--replset parameter and changing the MongoDB port, at which point MongoDB will enter the standalone mode;

2. In standalone mode to run the command Ensureindex index, it is recommended to use the foreground mode of operation;

3. After indexing, shut down secondary server and start in normal way;




Here is the log

Primary

2015-12-17t07:46:53.074+0800 [conn5530345] Index Build (background): 27309700/27314911 99%
。。。

Slave

2015-12-17t07:46:54.985+0800 [REPL Index Builder] Building index in background
2015-12-17t07:46:55.529+0800 [conn2154798] killcursors keyupdates:0 numyields:0 locks (micros) r:73 167ms
2015-12-17t07:46:58.226+0800 [REPL Index Builder] Index build (background): 4700/27314911 0%





2.TTL index deletes data, not a one-time deletion of data beyond the date, but a little bit,

is also the same, always thought that after the index was established, the TTL delete data is a one-time operation, where know a few hours also did not delete the completion, resulting in the database
The pressure is always high.

Later had to change the name, and then set up a new table after the data inserted.
Db. Weblog.renamecollection ("Weblog_bak");
Db. Weblog.ensureindex ({mallid:1,mac:1});
Db. Weblog.ensureindex ({createtime:-1},{expireafterseconds:3600*24*3*30});

var cursor=db. Weblog_bak.find ({_id:{$gte: 24600000}});
while (Cursor.hasnext ()) {
Nc=cursor.next ();
Db. Weblog.insert (NC);
};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.