[MongoDB] CentOS7安装MongoDB
CentOS7安装MongoDB
[root@vm ~]# yum install -y mongodb-org
[root@vm ~]# systemctl start mongod
[root@vm ~]# systemctl is-active mongod
[root@vm ~]# netstat -nltp | grep 27017
[root@vm ~]# mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.2
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:
2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten]
2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-14T21:04:02.032+0800 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()
---
> show databases;
admin 0.000GB
config 0.000GB
local 0.000GB
>
使用
> use test
switched to db test
> db
test
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> db.test.insert({"name":"cindy"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
test 0.000GB
> db.test.find()
{ "_id" : ObjectId("5b9bb43e63d77f5bb9465cb2"), "name" : "cindy" }
>
还没有评论,来说两句吧...