{"id":168691,"date":"2013-02-07T23:24:03","date_gmt":"2013-02-07T19:24:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=168691"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=168691","title":{"rendered":"<span class=\"post_title\">\u0420\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f MongoDb \u043d\u0430 Amazon EC2<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>system.indexes<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Amazon EC2<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 MongoDb<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/li>\n<li>\u0427\u0442\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  <\/p>\n<h4>local.abstract<\/h4>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e MongoDb \u043d\u0430 \u0431\u0430\u0437\u0435 Amazon EC2. \u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a\u0430\u043a \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Amazon EC2, \u0442\u0430\u043a \u0438 \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 MongoDb \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u041d\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0434\u044c\u044f\u0432\u043e\u043b \u0436\u0438\u0432\u0451\u0442 \u0432 \u043c\u0435\u043b\u043e\u0447\u0430\u0445. \u0418 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0432\u044b\u0434\u0435\u043b\u044e \u0442\u0435 \u201c\u043c\u0435\u043b\u043e\u0447\u0438\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043d\u0438\u043c\u0430\u043b\u0438 \u043c\u0435\u043d\u044f. <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>{step: 1, title: \u00abAmazon EC2 configure\u00bb, devilCount: 2}<\/h4>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u2013 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u0438: \u0434\u043b\u044f web-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0438 \u0434\u043b\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. <br \/>  \u0414\u043b\u044f web-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043b\u044f SSH, HTTP \u0438 HTTPS:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b43\/5cd\/18e\/b435cd18edba2c10eea9f1b46925ae4d.png\"\/><\/p>\n<p>  \u0414\u043b\u044f db-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u043e\u0442\u043a\u0440\u043e\u0451\u043c \u0432\u0441\u0451 \u0442\u043e\u0442 \u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e SSH, \u043f\u043b\u044e\u0441 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u043f\u043e\u0440\u0442 27017 \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u0438 web \u0438 db:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/6ca\/698\/e75\/6ca698e75dfde3f1d2f4cf8cdc1c6583.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0430\u043c\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b: \u043e\u0434\u0438\u043d small-\u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0434\u043b\u044f web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u0432\u0430 large- \u0438 \u043e\u0434\u0438\u043d micro- \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 Amazon Machine Image (AMI) \u044f \u0432\u044b\u0431\u0440\u0430\u043b Ubuntu Server 12. \u0412\u0430\u0436\u043d\u043e: \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f MongoDb \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432. \u0421 \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 3\u0439 \u2013 \u043c\u0438\u043a\u0440\u043e-\u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u2013 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0431\u0438\u0442\u0440\u0430. \u041e \u0442\u043e\u043c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0430\u0440\u0431\u0438\u0442\u0440, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043d\u0438\u0436\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u0431\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 5, 7 \u0438\u043b\u0438 2n + 1 large-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432. \u041d\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 Amazon EC2, \u0438 \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432 \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u0441\u043e\u043c\u044b\u0439 \u043d\u044c\u044e\u0430\u043d\u0441 \u2013 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u043e\u0441\u0442\u044c IP-\u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u0432. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2013 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u043b\u0438\u0430\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 \/etc\/hosts. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u0444\u0430\u0439\u043b hosts \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:  <\/p>\n<pre><code class=\"bash\">127.0.0.1 db1 localhost 10.40.120.30 db1 10.40.120.31 db2 10.40.120.32 db3 <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b.<\/p>\n<h4>{step: 2, title: \u00abMongoDb install\u00bb, devilCount: 1}<\/h4>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 MongoDb. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0430\u043d\u0443\u0430\u043b\u0435 MongoDb, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0447\u0451\u0442\u043a\u043e \u0435\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b mongo_install.bash \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442:  <\/p>\n<pre><code class=\"bash\">apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo &quot;deb http:\/\/downloads-distro.mongodb.org\/repo\/ubuntu-upstart dist 10gen&quot; | tee -a \/etc\/apt\/sources.list.d\/10gen.list apt-get -y update apt-get -y install mongodb-10gen <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442: <\/p>\n<pre><code class=\"bash\">sudo bash .\/mongo_install.bash <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c PID \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0433\u043e MongoDb: <\/p>\n<pre><code class=\"bash\">mongodb start\/running, process 2368 <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 mongod: <\/p>\n<pre><code class=\"bash\">sudo service mongodb start <\/code><\/pre>\n<p>  \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a: \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c \u043c\u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u043e\u0444\u0442\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0435, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e Amazon EC2 Images. <\/p>\n<h4>{step: 3, title: \u00abReplication\u00bb, devilCount: 2}<\/h4>\n<p>  \u0412\u043e\u0442 \u043c\u044b \u0438 \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u043f\u0443\u043d\u043a\u0442\u0443 \u2013 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0421\u043f\u0435\u0440\u0432\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 (\/etc\/mongodb.conf) \u043d\u0430 \u0432\u0441\u0435\u0445 db-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 replSet. \u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043c\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438: <\/p>\n<pre><code class=\"bash\">replSet = myproject <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441: <\/p>\n<pre><code class=\"bash\">sudo service mongodb restart <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u041c\u043e\u043d\u0433\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <\/p>\n<pre><code class=\"bash\">mongo <\/code><\/pre>\n<p>  \u0418\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0443: <\/p>\n<pre><code class=\"bash\">rs.initiate() <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0432 \u043d\u0430\u0448\u0443 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e: <\/p>\n<pre><code class=\"bash\">rs.add(&quot;db2:27017&quot;) <\/code><\/pre>\n<p>  \u0422\u0440\u0435\u0442\u0438\u0439 \u0436\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441, \u0438 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0430\u043a \u0430\u0440\u0431\u0438\u0442\u0440: <\/p>\n<pre><code class=\"bash\">rs.addArb(&quot;db3:27017&quot;) <\/code><\/pre>\n<p>  \u0410\u0440\u0431\u0438\u0442\u0440 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0432\u043e\u044e \u043a\u043e\u043f\u0438\u044e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0438 \u0432 \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u0438 \u0432 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430 Primary. \u042d\u0442\u0438\u043c \u0438 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0430\u0440\u0431\u0438\u0442\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0436\u0435\u043b\u0435\u0437\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0438:   <\/p>\n<pre><code class=\"bash\">mydb:PRIMARY&gt; rs.status() {         &quot;set&quot; : &quot;myproject&quot;,         &quot;date&quot; : ISODate(&quot;2013-02-04T12:17:42Z&quot;),         &quot;myState&quot; : 1,         &quot;members&quot; : [                 {                         &quot;_id&quot; : 0,                         &quot;name&quot; : &quot;db1:27017&quot;,                         &quot;health&quot; : 1,                         &quot;state&quot; : 1,                         &quot;stateStr&quot; : &quot;PRIMARY&quot;,                         &quot;uptime&quot; : 1139012,                         &quot;optime&quot; : Timestamp(1359738450000, 12),                         &quot;optimeDate&quot; : ISODate(&quot;2013-02-01T17:07:30Z&quot;),                         &quot;self&quot; : true                 },                 {                         &quot;_id&quot; : 1,                         &quot;name&quot; : &quot;db2:27017&quot;,                         &quot;health&quot; : 1,                         &quot;state&quot; : 2,                         &quot;stateStr&quot; : &quot;SECONDARY&quot;,                         &quot;uptime&quot; : 1138953,                         &quot;optime&quot; : Timestamp(1359738450000, 12),                         &quot;optimeDate&quot; : ISODate(&quot;2013-02-01T17:07:30Z&quot;),                         &quot;lastHeartbeat&quot; : ISODate(&quot;2013-02-04T12:17:42Z&quot;),                         &quot;pingMs&quot; : 0                 },                 {                         &quot;_id&quot; : 2,                         &quot;name&quot; : &quot;db3:27017&quot;,                         &quot;health&quot; : 1,                         &quot;state&quot; : 2,                         &quot;stateStr&quot; : &quot;SECONDARY&quot;,                         &quot;uptime&quot; : 442498,                         &quot;optime&quot; : Timestamp(1359738450000, 12),                         &quot;optimeDate&quot; : ISODate(&quot;2013-02-01T17:07:30Z&quot;),                         &quot;lastHeartbeat&quot; : ISODate(&quot;2013-02-04T12:17:40Z&quot;),                         &quot;pingMs&quot; : 0                 }         ],         &quot;ok&quot; : 1 } <\/code><\/pre>\n<p>  \u0423\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/docs.mongodb.org\/manual\/reference\/replica-status\/#fields\">docs.mongodb.org\/manual\/reference\/replica-status\/#fields<\/a> <\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433:  <\/p>\n<pre><code class=\"bash\">mydb:PRIMARY&gt; rs.config() {         &quot;_id&quot; : &quot;myproject&quot;,         &quot;version&quot; : 12,         &quot;members&quot; : [                 {                         &quot;_id&quot; : 0,                         &quot;host&quot; : &quot;db1:27017&quot;                 },                 {                         &quot;_id&quot; : 1,                         &quot;host&quot; : &quot;db2:27017&quot;                 },                 {                         &quot;_id&quot; : 2,                         &quot;host&quot; : &quot;db3:27017&quot;,                         &quot;arbiterOnly&quot; : true                 }         ] } <\/code><\/pre>\n<p>  \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0438. \u0423\u0440\u0430!<\/p>\n<p>  \u0418 \u043d\u0430 \u0434\u0435\u0441\u0435\u0440\u0442 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442. \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0440\u0435\u043f\u043b\u0438\u043a\u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430 \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e priority. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u043e \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f 1 \u0438, \u043a\u0430\u043a \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0440\u0430\u043d Primary. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b db1 \u0431\u044b\u043b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e Primary (\u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438):  <\/p>\n<pre><code class=\"bash\">config = rs.config() config.members[0].priority = 2 rs.reconfig(config) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0444\u0438\u0433 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"bash\">mydb:PRIMARY&gt; rs.config() {         &quot;_id&quot; : &quot;myproject&quot;,         &quot;version&quot; : 12,         &quot;members&quot; : [                 {                         &quot;_id&quot; : 0,                         &quot;host&quot; : &quot;db1:27017&quot;, \t\t&quot;priority&quot; : 2                 },                 {                         &quot;_id&quot; : 1,                         &quot;host&quot; : &quot;db2:27017&quot;                 },                 {                         &quot;_id&quot; : 2,                         &quot;host&quot; : &quot;db3:27017&quot;,                         &quot;arbiterOnly&quot; : true                 }         ] }  <\/code><\/pre>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u041c\u043e\u043d\u0433\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 Amazon EC2. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0432 \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e.<\/p>\n<h4>local.links<\/h4>\n<p>  <\/p>\n<ol>\n<li>Amazon EC2 <a href=\"http:\/\/aws.amazon.com\/documentation\/ec2\">aws.amazon.com\/documentation\/ec2<\/a><\/li>\n<li>MongoDb Installation <a href=\"http:\/\/docs.mongodb.org\/manual\/tutorial\/install-mongodb-on-ubuntu\/\">docs.mongodb.org\/manual\/tutorial\/install-mongodb-on-ubuntu\/<\/a><\/li>\n<li>MongoDB <a href=\"http:\/\/docs.mongodb.org\/manual\/tutorial\/getting-started\">docs.mongodb.org\/manual\/tutorial\/getting-started<\/a><\/li>\n<li>MongoDb Replication <a href=\"http:\/\/docs.mongodb.org\/manual\/replication\">docs.mongodb.org\/manual\/replication<\/a><\/li>\n<li>MongoDb Replica Set Arbiters <a href=\"http:\/\/docs.mongodb.org\/manual\/administration\/replica-sets\/#replica-set-arbiters\">docs.mongodb.org\/manual\/administration\/replica-sets\/#replica-set-arbiters<\/a><\/li>\n<li>MongoDb Replica Set Configuration <a href=\"http:\/\/docs.mongodb.org\/manual\/reference\/replica-configuration\/\">docs.mongodb.org\/manual\/reference\/replica-configuration\/<\/a><\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/168691\/\"> http:\/\/habrahabr.ru\/post\/168691\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>system.indexes<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Amazon EC2<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 MongoDb<\/li>\n<li>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/li>\n<li>\u0427\u0442\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  <\/p>\n<h4>local.abstract<\/h4>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e MongoDb \u043d\u0430 \u0431\u0430\u0437\u0435 Amazon EC2. \u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a\u0430\u043a \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Amazon EC2, \u0442\u0430\u043a \u0438 \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 MongoDb \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u041d\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0434\u044c\u044f\u0432\u043e\u043b \u0436\u0438\u0432\u0451\u0442 \u0432 \u043c\u0435\u043b\u043e\u0447\u0430\u0445. \u0418 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0432\u044b\u0434\u0435\u043b\u044e \u0442\u0435 \u201c\u043c\u0435\u043b\u043e\u0447\u0438\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043d\u0438\u043c\u0430\u043b\u0438 \u043c\u0435\u043d\u044f.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-168691","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168691"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168691\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}