V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
SlipStupig
V2EX  ›  云计算

docker-compose 持久化的奇怪问题

  •  
  •   SlipStupig · 2017-06-26 11:42:56 +08:00 · 2742 次点击
    这是一个创建于 2713 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我使用 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 的数据库文件不用每次导入直接挂载呢?

    6 条回复    2017-06-27 09:22:01 +08:00
    momocraft
        1
    momocraft  
       2017-06-26 11:45:59 +08:00
    检查文件权限和错误信息
    SlipStupig
        2
    SlipStupig  
    OP
       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
        3
    oyyd  
       2017-06-26 12:54:09 +08:00 via iPhone
    每次都持久化一次具体指的是?
    SlipStupig
        4
    SlipStupig  
    OP
       2017-06-26 13:03:43 +08:00
    @oyyd 并没有读取到之前的数据,而是重新初始化新的集合出来
    HuangLibo
        5
    HuangLibo  
       2017-06-26 23:09:35 +08:00
    之前用 docker 部署 gitlab 遇到过这个问题, 每次重启服务 gitlab 里面的数据就全没了, 最后就没用 docker, 直接在操作系统里安装了 gitlab
    SlipStupig
        6
    SlipStupig  
    OP
       2017-06-27 09:22:01 +08:00
    @HuangLibo 你这种一般都是 volume 配置问题, 我的情况是加载了卷却没有数据
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5545 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:41 · PVG 16:41 · LAX 00:41 · JFK 03:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.