(7)docker安装MongoDB

1、可视化客户端

下载地址(修改版本号即可下载对应版本):
https://download.studio3t.com/studio-3t/windows/2018.4.6/studio-3t-x64.zip
https://download.studio3t.com/studio-3t/windows/2019.2.1/studio-3t-x64.zip

破解:新建studio3t.bat到以下路径,开机启动延迟试用期:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

studio3t.bat

@echo off
ECHO 重置Studio 3T的使用日期......
FOR /f "tokens=1,2,* " %%i IN ('reg query "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\3t\mongochef\enterprise" ^| find /V "installation" ^| find /V "HKEY"') DO ECHO yes | reg add "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\3t\mongochef\enterprise" /v %%i /t REG_SZ /d ""
ECHO 重置完成, 按任意键退出......
exit
拉取镜像
[root@starseaing9228 ~]# docker pull mongo:4.1.10
4.1.10: Pulling from library/mongo
f476d66f5408: Pull complete 
8882c27f669e: Pull complete 
d9af21273955: Pull complete 
f5029279ec12: Pull complete 
8b628ec1f218: Pull complete 
9991ac3ac9ee: Pull complete 
9e923c0d9faf: Pull complete 
fd0e810710b3: Pull complete 
aaa04b0e6a0a: Pull complete 
c9ec0e635618: Pull complete 
5ed9ca457979: Pull complete 
e1f157db9860: Pull complete 
01523e6e2cfc: Pull complete 
Digest: sha256:22affc506f6d05d51b79ae7aad9908da366839124049de027c98e561dc780106
Status: Downloaded newer image for mongo:4.1.10
[root@starseaing9228 ~]# 
[root@starseaing9228 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mongo               4.1.10              4da37c5bf774        7 days ago          391MB

查看镜像的说明

镜像下载完成,下面就要开始启动容器了。启动容器前,建议大家仔细阅读前面寻找镜像时Docker Hub上关于mongo镜像的详细说明。

数据目录:/my/own/datadir:/data/db
配置文件:/my/custom:/etc/mongo,需要指定–config

原文如下:

For example, /my/custom/mongod.conf is the path to the custom configuration file. Then start the MongoDB container like the following:

$ docker run --name some-mongo -v /my/custom:/etc/mongo -d mongo --config /etc/mongo/mongod.conf

只挂载数据目录的启动命令:

docker run -p 27017:27017 -v /usr/local/mongodb4.1.10/db:/data/db -d mongo:4.1.10

所以,最终的挂载数据目录和自定义配置文件目录的启动命令:

docker run -p 27017:27017 -v /usr/local/mongodb4.1.10/db:/data/db -v /usr/local/mongodb4.1.10/conf:/etc/mongo -d mongo:4.1.10 --config /etc/mongo/mongod.conf

启动情况如下:

[root@starseaing9228 ~]# docker run -p 27017:27017 -v /usr/local/mongodb4.1.10/db:/data/db -d mongo:4.1.10
62da11435b1e40fb0843c0eca388bca6c18199d6b5e5c2cadf65fd5ec80a2787
[root@starseaing9228 ~]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
62da11435b1e        mongo:4.1.10          "docker-entrypoint.s…"   21 seconds ago      Up 18 seconds       0.0.0.0:27017->27017/tcp                         determined_rosalind


[root@starseaing9228 ~]# docker logs 62da11435b1e
2019-05-04T16:06:38.469+0000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=62da11435b1e
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] db version v4.1.10
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] git version: 8cdc51e7810f7fd8898a4c60b935e389f04659ee
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] allocator: tcmalloc
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] modules: none
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] build environment:
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten]     distmod: ubuntu1804
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten]     distarch: x86_64
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten]     target_arch: x86_64
2019-05-04T16:06:38.471+0000 I  CONTROL  [initandlisten] options: { net: { bindIp: "*" } }
2019-05-04T16:06:38.472+0000 I  STORAGE  [initandlisten] 
2019-05-04T16:06:38.472+0000 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-05-04T16:06:38.472+0000 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-05-04T16:06:38.472+0000 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=407M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-05-04T16:06:39.328+0000 I  STORAGE  [initandlisten] WiredTiger message [1556985999:328440][1:0x7f5e5af5aac0], txn-recover: Set global recovery timestamp: (0,0)
2019-05-04T16:06:39.375+0000 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-05-04T16:06:39.451+0000 I  STORAGE  [initandlisten] Timestamp monitor starting
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] ** NOTE: This is a development version (4.1.10) of MongoDB.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] **       Not recommended for production.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-05-04T16:06:39.495+0000 I  CONTROL  [initandlisten] 
2019-05-04T16:06:39.496+0000 I  STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 0a34345a-4287-4a2a-9e86-649488f9d7a9
2019-05-04T16:06:39.547+0000 I  STORAGE  [initandlisten] Registering catalog entry admin.system.version with UUID 0a34345a-4287-4a2a-9e86-649488f9d7a9
2019-05-04T16:06:39.547+0000 I  STORAGE  [initandlisten] Registering collection object admin.system.version with UUID 0a34345a-4287-4a2a-9e86-649488f9d7a9
2019-05-04T16:06:39.578+0000 I  INDEX    [initandlisten] index build: done building index _id_ on ns admin.system.version
2019-05-04T16:06:39.578+0000 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2019-05-04T16:06:39.578+0000 I  COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.2
2019-05-04T16:06:39.582+0000 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-05-04T16:06:39.582+0000 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2019-05-04T16:06:39.582+0000 I  STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 033a51b7-5e25-42d0-81aa-590f0e30b375
2019-05-04T16:06:39.615+0000 I  STORAGE  [initandlisten] Registering catalog entry local.startup_log with UUID 033a51b7-5e25-42d0-81aa-590f0e30b375
2019-05-04T16:06:39.615+0000 I  STORAGE  [initandlisten] Registering collection object local.startup_log with UUID 033a51b7-5e25-42d0-81aa-590f0e30b375
2019-05-04T16:06:39.644+0000 I  INDEX    [initandlisten] index build: done building index _id_ on ns local.startup_log
2019-05-04T16:06:39.645+0000 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2019-05-04T16:06:39.645+0000 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-05-04T16:06:39.646+0000 I  NETWORK  [initandlisten] Listening on /tmp/mongodb-27017.sock
2019-05-04T16:06:39.646+0000 I  NETWORK  [initandlisten] Listening on 0.0.0.0
2019-05-04T16:06:39.646+0000 I  NETWORK  [initandlisten] waiting for connections on port 27017
2019-05-04T16:06:39.647+0000 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2019-05-04T16:06:39.647+0000 I  STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: 05bc5a18-1cb9-4d5d-abed-f20afd0887b9
2019-05-04T16:06:39.696+0000 I  STORAGE  [LogicalSessionCacheRefresh] Registering catalog entry config.system.sessions with UUID 05bc5a18-1cb9-4d5d-abed-f20afd0887b9
2019-05-04T16:06:39.696+0000 I  STORAGE  [LogicalSessionCacheRefresh] Registering collection object config.system.sessions with UUID 05bc5a18-1cb9-4d5d-abed-f20afd0887b9
2019-05-04T16:06:39.718+0000 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index _id_ on ns config.system.sessions
2019-05-04T16:06:39.762+0000 I  INDEX    [LogicalSessionCacheRefresh] index build: starting on config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 } using method: Hybrid
2019-05-04T16:06:39.762+0000 I  INDEX    [LogicalSessionCacheRefresh] build may temporarily use up to 500 megabytes of RAM
2019-05-04T16:06:39.762+0000 I  INDEX    [LogicalSessionCacheRefresh] index build: collection scan done. scanned 0 total records in 0 seconds
2019-05-04T16:06:39.763+0000 I  INDEX    [LogicalSessionCacheRefresh] index build: inserted 0 keys from external sorter into index in 0 seconds
2019-05-04T16:06:39.764+0000 I  INDEX    [LogicalSessionCacheRefresh] index build: done building index lsidTTLIndex on ns config.system.sessions
2019-05-04T16:06:39.777+0000 I  COMMAND  [LogicalSessionCacheRefresh] command config.system.sessions command: createIndexes { createIndexes: "system.sessions", indexes: [ { key: { lastUse: 1 }, name: "lsidTTLIndex", expireAfterSeconds: 1800 } ], $db: "config" } numYields:0 reslen:114 locks:{ Global: { acquireCount: { r: 3, w: 5 } }, Database: { acquireCount: { r: 1, w: 3, W: 2 } }, Collection: { acquireCount: { r: 1, w: 2, R: 1 } }, Mutex: { acquireCount: { r: 3 } } } storage:{} protocol:op_msg 129ms

准备项目:

https://github.com/chentiancai/simple-java-maven-app
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值