{"id":43166,"date":"2024-10-04T19:37:07","date_gmt":"2024-10-04T11:37:07","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43166\/"},"modified":"2024-10-04T19:37:07","modified_gmt":"2024-10-04T11:37:07","slug":"centos-7-%e4%b8%8a-mongodb-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ae%89%e8%a3%9d%e5%92%8c%e5%8d%b8%e8%bc%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43166\/","title":{"rendered":"CentOS 7 \u4e0a MongoDB \u6578\u64da\u5eab\u5b89\u88dd\u548c\u5378\u8f09"},"content":{"rendered":"<h1 id=\"centos-7-%e4%b8%8a-mongodb-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ae%89%e8%a3%9d%e5%92%8c%e5%8d%b8%e8%bc%89-lShgxdWDcf\">CentOS 7 \u4e0a MongoDB \u6578\u64da\u5eab\u5b89\u88dd\u548c\u5378\u8f09<\/h1>\n<p>MongoDB \u662f\u4e00\u7a2e\u6d41\u884c\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u56e0\u5176\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\u548c\u9ad8\u6027\u80fd\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u5728\u672c\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u5378\u8f09 MongoDB \u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mongodb-lShgxdWDcf\">\u5b89\u88dd MongoDB<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1%ef%bc%9a%e6%b7%bb%e5%8a%a0-mongodb-%e5%ad%98%e5%84%b2%e5%ba%ab-lShgxdWDcf\">\u6b65\u9a5f 1\uff1a\u6dfb\u52a0 MongoDB \u5b58\u5132\u5eab<\/h3>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u6dfb\u52a0 MongoDB \u7684\u5b98\u65b9\u5b58\u5132\u5eab\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5275\u5efa\u4e00\u500b\u65b0\u7684 `.repo` \u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/yum.repos.d\/mongodb-org-4.4.repo<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[mongodb-org-4.4]\nname=MongoDB Repository\nbaseurl=https:\/\/repo.mongodb.org\/yum\/redhat\/7\/mongodb-org\/4.4\/x86_64\/\ngpgcheck=1\nenabled=1\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-4.4.asc<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2%ef%bc%9a%e5%ae%89%e8%a3%9d-mongodb-lShgxdWDcf\">\u6b65\u9a5f 2\uff1a\u5b89\u88dd MongoDB<\/h3>\n<p>\u6dfb\u52a0\u5b8c\u5b58\u5132\u5eab\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MongoDB\uff1a<\/p>\n<pre><code>sudo yum install -y mongodb-org<\/code><\/pre>\n<p>\u9019\u5c07\u5b89\u88dd MongoDB \u7684\u6700\u65b0\u7248\u672c\u53ca\u5176\u6240\u6709\u4f9d\u8cf4\u9805\u3002<\/p>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-3%ef%bc%9a%e5%95%9f%e5%8b%95-mongodb-%e6%9c%8d%e5%8b%99-lShgxdWDcf\">\u6b65\u9a5f 3\uff1a\u555f\u52d5 MongoDB \u670d\u52d9<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 MongoDB \u670d\u52d9\u4e26\u8a2d\u7f6e\u5176\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start mongod\nsudo systemctl enable mongod<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-4%ef%bc%9a%e6%aa%a2%e6%9f%a5-mongodb-%e7%8b%80%e6%85%8b-lShgxdWDcf\">\u6b65\u9a5f 4\uff1a\u6aa2\u67e5 MongoDB \u72c0\u614b<\/h3>\n<p>\u8981\u78ba\u8a8d MongoDB \u662f\u5426\u6b63\u5728\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u5176\u72c0\u614b\uff1a<\/p>\n<pre><code>sudo systemctl status mongod<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u670d\u52d9\u6b63\u5728\u904b\u884c\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e5%8d%b8%e8%bc%89-mongodb-lShgxdWDcf\">\u5378\u8f09 MongoDB<\/h2>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-1%ef%bc%9a%e5%81%9c%e6%ad%a2-mongodb-%e6%9c%8d%e5%8b%99-lShgxdWDcf\">\u6b65\u9a5f 1\uff1a\u505c\u6b62 MongoDB \u670d\u52d9<\/h3>\n<p>\u5728\u5378\u8f09 MongoDB \u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5148\u505c\u6b62\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl stop mongod<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-2%ef%bc%9a%e5%8d%b8%e8%bc%89-mongodb-lShgxdWDcf\">\u6b65\u9a5f 2\uff1a\u5378\u8f09 MongoDB<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5378\u8f09 MongoDB\uff1a<\/p>\n<pre><code>sudo yum remove -y mongodb-org*<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f-3%ef%bc%9a%e5%88%aa%e9%99%a4-mongodb-%e6%95%b8%e6%93%9a%e5%92%8c%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-lShgxdWDcf\">\u6b65\u9a5f 3\uff1a\u522a\u9664 MongoDB \u6578\u64da\u548c\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u5b8c\u5168\u522a\u9664 MongoDB \u7684\u6578\u64da\u548c\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u624b\u52d5\u522a\u9664\u4ee5\u4e0b\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo rm -r \/var\/lib\/mongo\nsudo rm -r \/etc\/mongod.conf<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-lShgxdWDcf\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u5378\u8f09 MongoDB \u6578\u64da\u5eab\u3002\u9019\u4e9b\u6b65\u9a5f\u7c21\u55ae\u660e\u77ad\uff0c\u9069\u5408\u5404\u7a2e\u6280\u8853\u6c34\u5e73\u7684\u7528\u6236\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u4f86\u904b\u884c\u60a8\u7684 MongoDB \u6578\u64da\u5eab\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\u3002\u6211\u5011\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684 <a href=\"https:\/\/server.hk\">\u4e91\u4f3a\u670d\u5668<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd\u548c\u5378\u8f09 MongoDB \u6578\u64da\u5eab\uff0c\u7c21\u55ae\u6b65\u9a5f\u52a9\u60a8\u8f15\u9b06\u7ba1\u7406\u6578\u64da\u5eab\u74b0\u5883\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43166","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43166"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43166\/revisions"}],"predecessor-version":[{"id":43167,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43166\/revisions\/43167"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}