docker-compose 持久化的奇怪问题

2017-06-26 11:42:56 +08:00
 SlipStupig

我使用 mongodb 服务,持久化到测试环境上,一切正常,我把相关持久化数据放到其它机器上,mongodb 居然不加载文件,每次都是初始化一次.

docker-compose:

   mongodb:
      restart: on-failure
      image:  mongo:3.4
      volumes:
        - /home/mongod:/data/db:rw

      ports:
        - "28017:27017"

      command: --maxConns 4096

      sysctls:
        net.core.somaxconn: 16240

怎么样才能让 mongodb 的数据库文件不用每次导入直接挂载呢?

2725 次点击
所在节点    云计算
6 条回复
momocraft
2017-06-26 11:45:59 +08:00
检查文件权限和错误信息
SlipStupig
2017-06-26 11:58:34 +08:00
@momocraft 目录给了 755,没有报错,只是数据没加载进去
path:
drwxr-xr-x 5 root root 4096 Jun 26 03:52 db/

mongodb:
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=912e28a9d550
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] db version v3.4.5
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] git version: 520b8f3092c48d934f0cd78ab5f40fe594f96863
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] modules: none
mongodb_1 | 2017-06-26T03:57:08.579+0000 I CONTROL [initandlisten] build environment:
mongodb_1 | 2017-06-26T03:57:08.580+0000 I CONTROL [initandlisten] distmod: debian81
mongodb_1 | 2017-06-26T03:57:08.580+0000 I CONTROL [initandlisten] distarch: x86_64
mongodb_1 | 2017-06-26T03:57:08.580+0000 I CONTROL [initandlisten] target_arch: x86_64
mongodb_1 | 2017-06-26T03:57:08.580+0000 I CONTROL [initandlisten] options: { net: { maxIncomingConnections: 4096 } }
mongodb_1 | 2017-06-26T03:57:08.580+0000 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
mongodb_1 | 2017-06-26T03:57:08.581+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongodb_1 | 2017-06-26T03:57:08.581+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
mongodb_1 | 2017-06-26T03:57:08.581+0000 I STORAGE [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.581+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongodb_1 | 2017-06-26T03:57:08.581+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
mongodb_1 | 2017-06-26T03:57:08.581+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1463M,session_max=20000,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
mongodb_1 | 2017-06-26T03:57:08.918+0000 I CONTROL [initandlisten]
mongodb_1 | 2017-06-26T03:57:08.922+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongodb_1 | 2017-06-26T03:57:08.923+0000 I NETWORK [thread1] waiting for connections on port 27017
mongodb_1 | 2017-06-26T03:57:09.015+0000 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
oyyd
2017-06-26 12:54:09 +08:00
每次都持久化一次具体指的是?
SlipStupig
2017-06-26 13:03:43 +08:00
@oyyd 并没有读取到之前的数据,而是重新初始化新的集合出来
HuangLibo
2017-06-26 23:09:35 +08:00
之前用 docker 部署 gitlab 遇到过这个问题, 每次重启服务 gitlab 里面的数据就全没了, 最后就没用 docker, 直接在操作系统里安装了 gitlab
SlipStupig
2017-06-27 09:22:01 +08:00
@HuangLibo 你这种一般都是 volume 配置问题, 我的情况是加载了卷却没有数据

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/371100

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX