{"id":226005,"date":"2021-09-23T09:59:10","date_gmt":"2021-09-23T01:59:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=226005"},"modified":"2021-09-14T09:00:00","modified_gmt":"2021-09-14T01:00:00","slug":"centos-mongodb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos-mongodb.html","title":{"rendered":"CentOS 7\u5feb\u901f\u5b89\u88c5Mongodb\u8be6\u89e3"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nMongoDB \u662f\u7531C++\u8bed\u8a00\u7f16\u5199\u7684\uff0c\u662f\u4e00\u4e2a\u57fa\u4e8e\u5206\u5e03\u5f0f\u6587\u4ef6\u5b58\u50a8\u7684\u5f00\u6e90\u6570\u636e\u5e93\u7cfb\u7edf\u3002Mongodb\u76ee\u524d\u5e94\u7528\u4e5f\u6bd4\u8f83\u591a\uff0c\u7ef4\u62a4\u4e5f\u76f8\u5bf9\u7b80\u5355\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u73af\u5883\u4ecb\u7ecd<\/strong><\/div>\n

\u64cd\u4f5c\u7cfb\u7edf\uff1aCentOS 7<\/p>\n

\"\"<\/p>\n

\u4e0b\u8f7d\u3001\u5b89\u88c5<\/strong><\/div>\n

\u5728mongodb\u7684\u5b98\u7f51\u53ef\u4ee5\u76f4\u63a5\u4e0b\u8f7d\u5230\u5bf9\u5e94\u7684rpm\u5305\uff0c\u7136\u540e\u4f7f\u7528yum\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n

\"\"<\/p>\n

yum\u00a0-y\u00a0localinstall\u00a0mongodb-org-mongos-4.4.8-1.el7.x86_64.rpm\u00a0\u00a0mongodb-org-server-4.4.8-1.el7.x86_64.rpm\u00a0\u00a0mongodb-org-shell-4.4.8-1.el7.x86_64.rpm<\/pre>\n
\u542f\u52a8<\/strong><\/div>\n
systemctl\u00a0enable\u00a0mongod\r\nsystemctl\u00a0start\u00a0mongod<\/pre>\n

\u67e5\u770b\u542f\u52a8\u6587\u4ef6<\/p>\n

systemctl\u00a0cat\u00a0mongod\r\n[Unit]\r\nDescription=MongoDB\u00a0Database\u00a0Server\r\nDocumentation=https:\/\/docs.mongodb.org\/manual\r\nAfter=network-online.target\r\nWants=network-online.target\r\n\u00a0\r\n[Service]\r\nUser=mongod\r\nGroup=mongod\r\nEnvironment=\"OPTIONS=-f\u00a0\/etc\/mongod.conf\"\r\nEnvironmentFile=-\/etc\/sysconfig\/mongod\r\nExecStart=\/usr\/bin\/mongod\u00a0$OPTIONS\r\nExecStartPre=\/usr\/bin\/mkdir\u00a0-p\u00a0\/var\/run\/mongodb\r\nExecStartPre=\/usr\/bin\/chown\u00a0mongod:mongod\u00a0\/var\/run\/mongodb\r\nExecStartPre=\/usr\/bin\/chmod\u00a00755\u00a0\/var\/run\/mongodb\r\nPermissionsStartOnly=true\r\nPIDFile=\/var\/run\/mongodb\/mongod.pid\r\nType=forking\r\n#\u00a0file\u00a0size\r\nLimitFSIZE=infinity\r\n#\u00a0cpu\u00a0time\r\nLimitCPU=infinity\r\n#\u00a0virtual\u00a0memory\u00a0size\r\nLimitAS=infinity\r\n#\u00a0open\u00a0files\r\nLimitNOFILE=64000\r\n#\u00a0processes\/threads\r\nLimitNPROC=64000\r\n#\u00a0locked\u00a0memory\r\nLimitMEMLOCK=infinity\r\n#\u00a0total\u00a0threads\u00a0(user+kernel)\r\nTasksMax=infinity\r\nTasksAccounting=false\r\n#\u00a0Recommended\u00a0limits\u00a0for\u00a0mongod\u00a0as\u00a0specified\u00a0in\r\n#\u00a0https:\/\/docs.mongodb.com\/manual\/reference\/ulimit\/#recommended-ulimit-settings\r\n\u00a0\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n

\u53ef\u4ee5\u770b\u51fa\u6570\u636e\u76ee\u5f55\u6587\u4ef6\/var\/run\/mongodb\uff0c\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/mongod.conf<\/p>\n

\u8bbe\u7f6e\u5bc6\u7801\u9a8c\u8bc1<\/strong><\/div>\n

\u9ed8\u8ba4\u662f\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165mongo\u547d\u4ee4\u5c31\u53ef\u4ee5\u76f4\u63a5\u767b\u9646shell\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n

mongo<\/pre>\n

\u521b\u5efa\u7ba1\u7406\u7528\u6237<\/p>\n

use\u00a0admin\r\ndb.createUser({user:\"root\",pwd:\"opcai.TOP\",roles:[\"root\"]})<\/pre>\n

\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n

vim\u00a0\/etc\/mongod.conf<\/pre>\n

\u914d\u7f6esecurity\u542f\u7528\u9a8c\u8bc1\u3002<\/p>\n

...\r\nsecurity:\r\n\u00a0\u00a0authorization:\u00a0enabled\r\n...<\/pre>\n

\u91cd\u542f\u670d\u52a1\u751f\u6548<\/p>\n

systemctl\u00a0restart\u00a0mongod<\/pre>\n
\u603b\u7ed3<\/strong><\/div>\n

Mongodb\u76ee\u524d\u5e94\u7528\u4e5f\u6bd4\u8f83\u591a\uff0c\u7ef4\u62a4\u4e5f\u76f8\u5bf9\u7b80\u5355\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u64cd\u4f5c\u7cfb\u7edf\uff1aCentOS 7 \u5728mongodb\u7684\u5b98\u7f51\u53ef\u4ee5\u76f4\u63a5\u4e0b\u8f7d\u5230\u5bf9\u5e94\u7684rpm\u5305\uff0c\u7136\u540e\u4f7f\u7528yum\u8fdb\u884c\u5b89\u88c5\u3002 yu […]<\/p>\n","protected":false},"author":323,"featured_media":176397,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-226005","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/226005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=226005"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/226005\/revisions"}],"predecessor-version":[{"id":226362,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/226005\/revisions\/226362"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/176397"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=226005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=226005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=226005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}