张山疯呀 發表於 2020-8-2 15:53:00

MongoDB单机部署

<h2 id="mongodb单机部署">MongoDB单机部署</h2>
<h3 id="一环境">一、环境</h3>
<pre><code>系统:centos7.6

DB版本:mongodb-linux-x86_64-rhel62-4.2.1.tgz

官网地址:https://www.mongodb.com

wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.0-1.el7.x86_64.rpm
</code></pre>
<h3 id="二安装">二、安装</h3>
<pre><code class="language-shell"># tar -zxvf mongodb-linux-x86_64-rhel62-4.2.1.tgz-C /app/
# cd /app &amp;&amp; mv mongodb-linux-x86_64-rhel62-4.2.1/ mongodb &amp;&amp; cd mongodb
#创建日志、数据、配置文件、pid目录
# mkdir{logs,data,config,pid}
#创建启动配置文件
# vim mongodb.conf&nbsp;
#端口号
port = 27017
#数据目录
dbpath = /app/mongodb/data
#日志目录
logpath = /app/mongodb/logs/mongodb.log
#pid目录
pidfilepath = /app/mongodb/pid/mongodb.pid
#设置后台运行
fork = true
#日志输出方式
logappend = true
#开启认证
#auth = true
#本地ip
bind_ip=0.0.0.0
</code></pre>
<h3 id="三启动">三、启动</h3>
<pre><code class="language-shell"># ./mongod --config ../config/mongodb.conf&nbsp;
about to fork child process, waiting until server is ready for connections.
forked process: 10134
child process started successfully, parent exiting
#检查是否启动成功
# ps -ef|grep mongodb
root      10134      11 15:42 ?      00:00:01 ./mongod --config ../config/mongodb.conf&nbsp;
# ss -ntlp|grep 27017
LISTEN   0      128    *:27017    *:*   users:(("mongod",pid=10134,fd=11))
</code></pre>
<h3 id="四进入数据库">四、进入数据库</h3>
<pre><code class="language-shell"># ./mongo
MongoDB shell version v4.2.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&amp;gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("0357cfa5-c9d8-4eca-a04e-f49fc137d420") }
MongoDB server version: 4.2.1
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
      http://docs.mongodb.org/
Questions? Try the support group
      http://groups.google.com/group/mongodb-user
Server has startup warnings:
2020-08-02T15:42:38.431+0800 ICONTROL
2020-08-02T15:42:38.431+0800 ICONTROL ** WARNING: Access control is not enabled for the database.
2020-08-02T15:42:38.431+0800 ICONTROL **          Read and write access to data and configuration is unrestricted.
2020-08-02T15:42:38.431+0800 ICONTROL ** WARNING: You are running this process as the root user, which is not recommended.
2020-08-02T15:42:38.431+0800 ICONTROL
2020-08-02T15:42:38.431+0800 ICONTROL
2020-08-02T15:42:38.431+0800 ICONTROL ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-08-02T15:42:38.431+0800 ICONTROL **      We suggest setting it to 'never'
2020-08-02T15:42:38.431+0800 ICONTROL
2020-08-02T15:42:38.431+0800 ICONTROL ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-08-02T15:42:38.431+0800 ICONTROL **      We suggest setting it to 'never'
2020-08-02T15:42:38.431+0800 ICONTROL
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

&gt;
</code></pre><br><br>
来源:https://www.cnblogs.com/hsyw/p/13418985.html
頁: [1]
查看完整版本: MongoDB单机部署