5分钟教程centos 7快速安装 mongodb 4.0+
Posted 聊聊Java
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了5分钟教程centos 7快速安装 mongodb 4.0+相关的知识,希望对你有一定的参考价值。
1、下载
2、配置2.1 配置mongo.conf2.2 创建dbpath和logpath2.3 配置环境2.4 启动命令配置start.sh2.5 停止命令配置stop.sh3 启动|停止3.1 启动3.2 停止3.3 连接本机命令连接客户端工具
1、下载
# 下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.24.tgz
# 新建目录
mkdir -p /usr/local/mongodb/
# 解压
tar -zxvf mongodb-linux-x86_64-4.0.24.tgz -C /usr/local/mongodb/
2、配置
2.1 配置mongo.conf
vim /etc/mongo.conf
# mongo.conf文件内容
dbpath = /var/lib/mongo/
port = 27017
fork = true
#auth = true
logpath = /var/log/mongo/mongo.log
logappend = true
bind_ip = 0.0.0.0
2.2 创建dbpath和logpath
mkdir -p /var/lib/mongo/
mkdir -p /var/log/mongo/
2.3 配置环境
将下述内容写入到/etc/profile
vim /etc/profile
export PATH=/usr/local/mongodb/mongodb-linux-x86_64-4.0.24/bin:$PATH
source /etc/profile
2.4 启动命令配置start.sh
#!/bin/bash
mongod -f /etc/mongo.conf
2.5 停止命令配置stop.sh
#!/bin/bash
mongod -f /etc/mongo.conf --shutdown
chmod 777 start.sh
chmod 777 stop.sh
3 启动|停止
3.1 启动
./start.sh
tail -f /var/log/mongo/mongo.log
3.2 停止
./stop.sh
3.3 连接
本机命令连接
[root]# mongo
MongoDB shell version v4.0.24
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("689ba2b6-2165-4c1c-a12d-6635f13d36fb") }
MongoDB server version: 4.0.24
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:
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten]
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten]
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten]
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten]
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2021-06-02T04:12:17.903-0400 I CONTROL [initandlisten]
> version()
4.0.24
>
客户端工具
也可以用mongodb客户端工具进行连接,常见的工具有:Dbeaver Enterprise、Navicat Premium、Studio 3T、Robo 3T (以前叫robomongo)。
以上是关于5分钟教程centos 7快速安装 mongodb 4.0+的主要内容,如果未能解决你的问题,请参考以下文章