泊坞窗 - MySQL的安装/绑定本地机器MySQL数据的/ var / lib中/ MySQL的

时间:2019-02-01 14:02:48

标签: mysql mongodb docker

我已经在本地计算机上安装了mysql,并且已经在我的计算机上安装了docker,正在将项目成功转换为Docker,已经在容器上部署了flask,但是我想在容器上安装mysql,但是mysql容器应该使用我的本地计算机数据因为数据大小接近100 + Gb。

我必须做同样为mongodb的。

我是否想通过dockerize现有的mysql和mongodb丢失一些东西。

操作系统:Ubuntu和默认的mysql路径:/ var / lib / mysql

我不想导入/导出。

下面是我的docker-compose.yml

  version: "3"
services:
  app:
    build:
      context: ./app
      dockerfile: ./dockerfile      
    container_name: flaskPython
    links:
      - mysqldb
      - mongodb
    ports:
      - "5000:5000"
  myadmin:
        image: phpmyadmin/phpmyadmin
        container_name: phpmyadmin
        ports:
            - "8282:80"
        environment:
            - PMA_ARBITRARY=1
            - PMA_HOST=${MYSQL_HOST}
        restart: always
        depends_on:
            - mysqldb
            - mongodb  
  mysqldb:
        image: mysql:${MYSQL_VERSION}
        container_name: ${MYSQL_HOST}
        restart: 'always'
        expose:
            - '3306'
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        ports:
            - "8989:3306"
        volumes:
            #- ./data/db/mysql:/var/lib/mysql
            - /var/lib/mysql:/var/lib/mysql
  mongodb:
        image: mongo
        container_name: mongodb
        restart: always
        environment:

          - MONGO_INITDB_ROOT_USERNAME=root
          - MONGO_INITDB_ROOT_PASSWORD=root
        # if you wish to setup additional user accounts specific per DB or with different roles you can use following entry point
        #no --auth is needed here as presence of username and password add this option automatically
        command: mongod
        ports:
            - "27017:27017"
        volumes:
          #- ./data/db/mongo/001_users.js:/docker-entrypoint-initdb.d/001_users.js:ro
          - ./mongo-entrypoint/:/docker-entrypoint-initdb.d/
          - ./data/db/mongo:/usr/data/db

日志:

2019-02-01T16:08:20.100825Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-02-01T16:08:20.101919Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 1 ...
2019-02-01T16:08:20.104031Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-02-01T16:08:20.104043Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-01T16:08:20.104046Z 0 [Note] InnoDB: Uses event mutexes
2019-02-01T16:08:20.104048Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-02-01T16:08:20.104050Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-02-01T16:08:20.104052Z 0 [Note] InnoDB: Using Linux native AIO
2019-02-01T16:08:20.104214Z 0 [Note] InnoDB: Number of pools: 1
2019-02-01T16:08:20.104285Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-02-01T16:08:20.105476Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-02-01T16:08:20.110790Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-02-01T16:08:20.112288Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-02-01T16:08:20.123892Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-01T16:08:20.139921Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-02-01T16:08:20.139996Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-02-01T16:08:20.170786Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-02-01T16:08:20.173104Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-02-01T16:08:20.173143Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-02-01T16:08:20.174483Z 0 [Note] InnoDB: Waiting for purge to start
2019-02-01T16:08:20.224878Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 1529088986
2019-02-01T16:08:20.225403Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-02-01T16:08:20.225887Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-02-01T16:08:20.231185Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190201 16:08:20
2019-02-01T16:08:20.233231Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2019-02-01T16:08:20.233502Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-02-01T16:08:20.233535Z 0 [Note] IPv6 is available.
2019-02-01T16:08:20.233544Z 0 [Note]   - '::' resolves to '::';
2019-02-01T16:08:20.233556Z 0 [Note] Server socket created on IP: '::'.
2019-02-01T16:08:20.236451Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-02-01T16:08:20.248740Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248832Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248857Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248875Z 0 [Warning] 'user' entry 'debian-sys-maint@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248921Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.248935Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.249216Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.256300Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.256349Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-02-01T16:08:20.301149Z 0 [Note] Event Scheduler: Loaded 0 events
2019-02-01T16:08:20.301811Z 0 [Note] mysqld: ready for connections.
Version: '5.7.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

我想在mysql容器中使用机器mysql数据,这样我就不必将100+ gb数据迁移到mysql容器,这样我的mysql容器将使用本地机器mysql数据进行读写。

PS:我只希望我不将机器mysql数据迁移到mysql容器,以便我的mysql容器以某种方式链接到我的机器,并使用本地计算机上安装的mysql数据文件夹。

0 个答案:

没有答案