Mongo笔记1-安装

安装的是mongo的docker

命令如下:

1.下载mongo的image,。

docker pull mongo

2.运行容器。

docker run --name mongodb0 -v /data/mongodb0:/data/db -p 27017:27017 -d mongo

自己本机上练习,没有启动权限验证;如果需要启动,需要加 --auth

3.连接数据库

docker exec -it mongodb0 mongo admin

登上后,使用命令show dbs,可查看已经存在的数据库。

安装日志如下:

[root@xt1 system]# docker pull mongo

Using default tag: latest

Trying to pull repository registry.access.redhat.com/mongo ...

Trying to pull repository docker.io/library/mongo ...

sha256:002fda672a0d196325a30736d4c80d04adf6f39dd28db41e6799f42844cab7b8: Pulling from docker.io/library/mongo

7b722c1070cd: Pull complete

5fbf74db61f1: Pull complete

ed41cb72e5c9: Pull complete

7ea47a67709e: Pull complete

778aebe6fb26: Pull complete

3b4b1e0b80ed: Pull complete

844ccc42fe76: Pull complete

eab01fe8ebf8: Pull complete

e5758d5381b1: Pull complete

dc553720c5c3: Pull complete

67750c781aa2: Pull complete

b00b8942c827: Pull complete

32201bb8ca69: Pull complete

Digest: sha256:002fda672a0d196325a30736d4c80d04adf6f39dd28db41e6799f42844cab7b8

Status: Downloaded newer image for docker.io/mongo:latest

[root@xt1 system]#

[root@xt1 system]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

docker.io/mongo latest 0da05d84b1fe 2 weeks ago 394 MB

[root@xt1 ~]# docker run --name mongodb0 -v /data/mongodb0:/data/db -p 27017:27017 -d mongo

d95ba3e75fb5492ce6499eb2afe557447ebeb30470cf3123698322fe552e0901

[root@xt1 bin]# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

d95ba3e75fb5 mongo "docker-entrypoint.sh" 15 seconds ago Up 6 seconds 0.0.0.0:27017->27017/tcp mongodb0

[root@xt1 ~]# docker exec -it mongodb0 mongo admin

MongoDB shell version v4.0.6

connecting to: mongodb://127.0.0.1:27017/admin?gssapiServiceName=mongodb

Implicit session: session { "id" : UUID("9269db62-5661-4b0c-9bec-e0d638226f46") }

MongoDB server version: 4.0.6

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:

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten]

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten]

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten]

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten]

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.

2019-02-26T07:29:24.086+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'

2019-02-26T07:29:24.086+0000 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 dbs

admin 0.000GB

config 0.000GB

local 0.000GB

>

猜你喜欢

转载自blog.csdn.net/Linzhongyilisha/article/details/88024166