CentOS 安装 Mongodb

1. 安装 mongodb-server

使用EPEP REPO

yum install mongodb-server
systemctl start mongod
1
2

使用Mongo REPO

[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
1
2
3
4
5
6
yum install -y mongodb-org
1
# mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("f339b158-a4de-490f-b978-599f0a57c924") }
MongoDB server version: 4.2.8
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-07-12T18:40:02.078+0800 I  STORAGE  [initandlisten]
2020-07-12T18:40:02.078+0800 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-07-12T18:40:02.078+0800 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-07-12T18:40:03.172+0800 I  CONTROL  [initandlisten]
2020-07-12T18:40:03.172+0800 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-12T18:40:03.172+0800 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-07-12T18:40:03.172+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()
---

> use runoob
switched to db runoob
> db
runoob
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> db.runoob.insert({"name":"xxxx"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
runoob  0.000GB
> use admin
switched to db admin
> quit
function quit() {
    [native code]
}
> quit()

[root@hadoop-46 cloudrea_manager]# systemctl start mongod
[root@hadoop-46 cloudrea_manager]# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2020-07-12 18:40:03 CST; 6 months 20 days ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 29339 (mongod)
    Tasks: 32
   Memory: 83.6M
   CGroup: /system.slice/mongod.service
           └─29339 /usr/bin/mongod -f /etc/mongod.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

reference