ʵսMongoDB-Replication֮Replica Set
- Master/Slave£¬Ö÷´Ó¸´ÖÆ£¬½ÇÉ«°üÀ¨masterºÍslave¡£
- Replica Set£¬¸´ÖƼ¯¸´ÖÆ£¬½ÇÉ«°üÀ¨primaryºÍsecondary¡£
- replica set¿ÉÒÔʵÏÖ×Ô¶¯µÄfailoverºÍ×Ô¶¯µÄrecovery¡£
- replica setÓÉÁ½¸ö»òÕ߸ü¶àµÄ½Úµã×é³É£¬ÊµÏֱ˴˵ĸ´ÖÆ¡£
- replica set×Ô¶¯Ñ¡Ôñprimary½Úµã£¬Ã»ÓÐÒ»¸ö½ÚµãÊǹ̶¨µÄprimary¡£
- mongos»á×Ô¶¯·¢ÏÖÒ»¸öreplica setµÄprimary½Úµã·¢Éú±ä»¯£¬²¢½«Ð´²Ù×÷·¢Ë͸øÕâ¸öеÄprimary½Úµã¡£
- Êý¾ÝÈßÓà¡£
- ×Ô¶¯failover£¬Ìṩ¸ß¿ÉÓÃÐԵķþÎñ¡£
- ·ÖÉ¢¶ÁµÄ¸ºÔØ¡£
- ¼ò»¯Î¬»¤(Ïà¶ÔÓÚmaster-slaveÀ´Ëµ£©¡£
- ÔÖÄѻָ´¡£
{ "info" : "Config now saved locally. Should come online in about a minute.", "ok" : 1 }¼ÌÐøÖ´ÐÐÈçÏÂÃüÁî
rs.status()
- myStateµÄÖµ£¬Èç¹ûÊÇ1´ú±íµ±Ç°µÇ¼µÄÊÇprimary£»Èç¹ûÊÇ2´ú±íµ±Ç°µÇ¼µÄÊÇsecondary¡£
- state£º1±íʾ¸ÃhostÊǵ±Ç°¿ÉÒÔ½øÐжÁд£¬2£º²»ÄܶÁд
- health£º1±íʾ¸ÃhostÄ¿Ç°ÊÇÕý³£µÄ£¬0:Òì³£
//¼ÙÉè80001ÊÇprimary£¬¿ÉÒÔͨ¹ý²éѯrs.statusÀ´»ñÈ¡ mongo 192.168.1.100:80001 use infos db.users.insert({'username':'test1'}) db.users.insert({'username':'test2'})
error: { "$err" : "not master and slaveok=false", "code" : 13435 }ûÓйØϵ£¬ÔÚsecondary¶ÁÈ¡Êý¾Ý»¹ÐèÒªÎÒÃÇ×ö×îºóµÄÒ»²½£¬ÔÚÐèÒª¶ÁÈ¡Êý¾ÝµÄsecondaryÉÏÖ´ÐлòÕßÔÚ~/.mongorc.jsÖÐÔö¼Órs.slaveOK()¡£
rs.slaveOK()ÕâʱºòÔÙ´Îdb.users.find()£¬Õý³£ÏÔʾ½á¹ûÁË£¬Ã»ÓÐÎÊÌâÁË¡£
rs.add('192.168.1.100:80003') »òÕß rs.addArb('192.168.1.100:80003') //ÖØÐÂÅäÖÃ rs.reconfig(rs.conf())
È磺rs.add("10.73.24.171:9005") µ±ÎÒÃÇ¿´µ½±äΪsecondaryºó£¬¾ÍÒ»ÇÐÕý³££¬¿ÉÒÔÕý³£ÌṩÏßÉÏ·þÎñÁË
4¡¢Í¨¹ýrs.conf()ÃüÁî²é¿´ÏÖÔڵĽڵãÐÅÏ¢£¨ÐèÒªadmin¿âÃÜÂëȨÏÞ£©
5¡¢rs.remove()ɾ³ý½Úµã
6¡¢Ìí¼Óarbiter½Úµã£ºrs.addArb("10.73.24.171:19003")
7¡¢Ìí¼ÓÑÓʱ±¸·Ý»úÆ÷£ºrs.add({_id:4,host:"10.55.22.176:9004",priority:0,slaveDelay:3600});
8¡¢µ±³öÏÖÕâ¸ö´íÎóʱ£ºreplSet error RS102 too stale to catch up£¬ÎÒÃÇ¿ÉÒÔdb.printReplicationInfo() ²é¿´Ö÷¿â¡¢´Ó¿âµÄoplogÐÅÏ¢£»
ÒÔÉÏΪÇл»¹ý³ÌÖÐÓõ½µÄ´ó²¿·ÖÃüÁÖ÷Òª»¹ÊÇreplica set¹ÜÀí¹¤¾ß£¬Èç¹ûÄÜÕÆÎÕ£¬ÄÇôÉý¼¶¡¢À©ÈÝ¡¢Ö÷¿âÇ뻶¼ÄÜ¿ìËÙ½øÐУ¡
Õâ´ÎÔÚÔËάÖУ¬ÓÉÓÚ»úÆ÷²»¹»£¬È¥µôÁËÑÓʱ±¸·Ý½ÇÉ«£¬Ö»×öÁËÖ÷-->±¸-->2arbiterµÄÒ»¸ö¸ß¿ÉÓü¯Èº£¬µ±Ö÷¿âʧЧʱºò£¬»ù±¾ÄÜÔÚ10ÃëÖÐÇл»µ½±¸ÉÏ£¡
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ