Mongodb安装:
mongodb版本:mongodb-linux-x86_64-3.6.13.tgz
1.在11.11.50.86的home目录下新建mongodb
Cd /home
Mkdir mongodb
2.上传 mongodb-linux-x86_64-3.6.13.tgz到目录mongodb目录下
解压
tar -zxvf mongodb-linux-x86_64-3.6.13.tgz
3.加入环境变量
vim /etc/profile
MONGODB_HOME=/home/mongodb/mongodb-linux-x86_64-3.6.13
PATH=
P
A
T
H
:
PATH:
PATH:MONGODB_HOME/bin
4.创建数据库目录以及日志目录及文件
mkdir -p /home/mongodb/data
mkdir -p /home/mongodb/logs
touch /home/mongodb/logs/mongo.log
5.在/home/mongodb目录下创建配置文件
vi mongo.conf
#加入以下内容
dbpath=/home/mongodb/data
logpath=/home/mongodb/logs/mongo.log #事先创建该文件
logappend=true
journal=true
quiet=true
port=27017
fork=true #后台运行
bind_ip=0.0.0.0 #允许任何IP进行连接
6.启动服务
#进入根目录
cd /home/mongodb/mongodb-linux-x86_64-3.6.13
#使用配置文件启动服务
bin/mongod -f /home/mongodb/mongo.conf
7.进入shell 测试
mongo
查看到如下内容:
MongoDB shell version v3.6.13
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“a1325865-a246-4b6e-91b6-92a6c72b099c”) }
MongoDB server version: 3.6.13
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-07-21T17:16:51.189+0800 I CONTROL [initandlisten]
2021-07-21T17:16:51.189+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-07-21T17:16:51.189+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2021-07-21T17:16:51.189+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2021-07-21T17:16:51.189+0800 I CONTROL [initandlisten]
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten]
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten]
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2021-07-21T17:16:51.190+0800 I CONTROL [initandlisten]
执行show dbs命令,结果如下:
admin 0.000GB
config 0.000GB
local 0.000GB