CentOS 7手动安装mongodb 4.0

本文详细介绍了如何在Linux环境下安装和配置MongoDB数据库。包括下载社区版、解压缩、目录配置、环境变量设置及运行步骤等内容。

一.下载社区版

官网地址https://www.mongodb.com/download-center?jmp=tutorials#community

二.解压

tar -zxvf mongodb-linux-x86_64-rhel70-4.0.1.tgz

移动到  /usr/local/mongodb

mv mongodb-linux-x86_64-rhel70-4.0.1 /usr/local/mongodb/

三.配置

1.新建data/db 目录

cd /usr/local/mongodb/
mkdir data/db

2.新建logs目录

mkdir logs

3.在bin目录下新建mongodb.conf

#mongodb config file
port=27017  #端口
rt=27017  #端口
bind_ip=0.0.0.0 #默认是127.0.0.1
dbpath=/usr/local/mongodb/data/db  #数据库存放
logpath=/usr/local/mongodb/logs/mongodb.log #日志文件
fork=true #设置后台运行
#auth=true #开启认证

四.运行

1.SElinux 允许27017端口

semanage port -a -t mongod_port_t -p tcp 27017

2.设置环境变量,在/etc/profile最底下添加

export MONGODB_HOME=/usr/local/mongodb
export PATH=$PATH:${MONGODB_HOME}/bin

使之生效 

source /etc/profile

3.运行mongd

mongod --config mongodb.conf

4.运行mongo

[root@localhost mongodb]# mongo
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.1
Server has startup warnings: 
2018-08-22T11:44:02.369-0400 I CONTROL  [initandlisten] 
2018-08-22T11:44:02.369-0400 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-08-22T11:44:02.369-0400 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-08-22T11:44:02.369-0400 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-08-22T11:44:02.369-0400 I CONTROL  [initandlisten] 
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] 
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] 
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-08-22T11:44:02.370-0400 I CONTROL  [initandlisten] 
---
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()
---

> 

 

转载于:https://my.oschina.net/u/3939059/blog/1932461

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值