代码之家  ›  专栏  ›  技术社区  ›  Abdullah Al Maruf - Tuhin

MySQL:8.0在Docker中进行初始化需要非常长的时间

  •  0
  • Abdullah Al Maruf - Tuhin  · 技术社区  · 6 年前

    公务的 mysql:8.0 (又名 8.0.4 )映像在docker(本地计算机)中初始化数据库需要异常的时间(大约10分钟以上)。

    如果仔细查看日志的时间,最后一行的执行时间为7分钟。

    Initializing database
    2018-04-09T10:00:29.926078Z 0 [Warning] [MY-011070] Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it is deprecated and will be removed in a future release.
    2018-04-09T10:00:29.926165Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc) starting as process 30 ...
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    2018-04-09T10:00:46.842725Z 0 [Warning] [MY-010068] CA certificate ca.pem is self signed.
    2018-04-09T10:00:46.903128Z 5 [Warning] [MY-010453] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
    2018-04-09T10:07:28.643932Z 5 [Warning] [MY-010315] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
    

    供您参考,在同一台机器上, mysql:8.0.3 初始化数据库根本不需要太多时间。

    以下是我的配置:

    操作系统: ubuntu 16.04

    $ docker version
    Client:
     Version:   17.12.1-ce
     API version:   1.35
     Go version:    go1.9.4
     Git commit:    7390fc6
     Built: Tue Feb 27 22:17:40 2018
     OS/Arch:   linux/amd64
    
    Server:
     Engine:
      Version:  17.12.1-ce
      API version:  1.35 (minimum version 1.12)
      Go version:   go1.9.4
      Git commit:   7390fc6
      Built:    Tue Feb 27 22:16:13 2018
      OS/Arch:  linux/amd64
      Experimental: false
    

    重新创建和完整日志的过程:

    $ docker pull mysql:8.0
    8.0: Pulling from library/mysql
    2a72cbf407d6: Pull complete 
    38680a9b47a8: Pull complete 
    4c732aa0eb1b: Pull complete 
    c5317a34eddd: Pull complete 
    f92be680366c: Pull complete 
    e8ecd8bec5ab: Pull complete 
    2a650284a6a8: Pull complete 
    5127cdce4b46: Pull complete 
    e20139ed3159: Pull complete 
    4c9ba8a8a3da: Pull complete 
    16cd0f3afb27: Pull complete 
    0e4872d58e1f: Pull complete 
    Digest: sha256:7004063f8bd0c7bade8d1c526b9b8f5188c8288f411d76ee4ba83131e00c6f02
    Status: Downloaded newer image for mysql:8.0
    
    $ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:8.0
    b9c5d67233743dc085c50244526f5b12bd862cd50cdc0cb889b2dc549c4a396d
    
    $ docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    b9c5d6723374        mysql:8.0           "docker-entrypoint.s…"   5 seconds ago       Up 3 seconds        3306/tcp            some-mysql
    
    $ docker logs -f b9c5d6723374
    Initializing database
    2018-04-09T10:00:29.926078Z 0 [Warning] [MY-011070] Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it is deprecated and will be removed in a future release.
    2018-04-09T10:00:29.926165Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc) starting as process 30 ...
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    2018-04-09T10:00:46.842725Z 0 [Warning] [MY-010068] CA certificate ca.pem is self signed.
    2018-04-09T10:00:46.903128Z 5 [Warning] [MY-010453] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
    2018-04-09T10:07:28.643932Z 5 [Warning] [MY-010315] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644008Z 5 [Warning] [MY-010315] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644033Z 5 [Warning] [MY-010315] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644051Z 5 [Warning] [MY-010315] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644082Z 5 [Warning] [MY-010323] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644094Z 5 [Warning] [MY-010323] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644112Z 5 [Warning] [MY-010311] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644240Z 5 [Warning] [MY-010330] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:28.644257Z 5 [Warning] [MY-010330] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
    Database initialized
    MySQL init process in progress...
    2018-04-09T10:07:44.797619Z 0 [Warning] [MY-011070] Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it is deprecated and will be removed in a future release.
    2018-04-09T10:07:44.797712Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc-log) starting as process 64 ...
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    MySQL init process in progress...
    2018-04-09T10:07:45.990317Z 0 [Warning] [MY-010068] CA certificate ca.pem is self signed.
    2018-04-09T10:07:46.040103Z 0 [Warning] [MY-000000] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
    2018-04-09T10:07:46.046970Z 0 [Warning] [MY-010315] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047013Z 0 [Warning] [MY-010315] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047029Z 0 [Warning] [MY-010315] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047046Z 0 [Warning] [MY-010315] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047078Z 0 [Warning] [MY-010323] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047091Z 0 [Warning] [MY-010323] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.047107Z 0 [Warning] [MY-010311] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.050079Z 0 [Warning] [MY-010330] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.050115Z 0 [Warning] [MY-010330] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:46.058044Z 0 [System] [MY-010931] /usr/sbin/mysqld: ready for connections. Version: '8.0.4-rc-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL).
    Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
    2018-04-09T10:07:50.304129Z 9 [Warning] [MY-010315] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304156Z 9 [Warning] [MY-010315] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304166Z 9 [Warning] [MY-010315] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304175Z 9 [Warning] [MY-010315] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304197Z 9 [Warning] [MY-010323] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304207Z 9 [Warning] [MY-010323] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304218Z 9 [Warning] [MY-010311] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304321Z 9 [Warning] [MY-010330] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:50.304332Z 9 [Warning] [MY-010330] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
    
    2018-04-09T10:07:53.074527Z 0 [System] [MY-010910] /usr/sbin/mysqld: Shutdown complete.
    
    MySQL init process done. Ready for start up.
    
    2018-04-09T10:07:53.336773Z 0 [Warning] [MY-011070] Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it is deprecated and will be removed in a future release.
    2018-04-09T10:07:53.336883Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc-log) starting as process 1 ...
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    mbind: Operation not permitted
    2018-04-09T10:07:54.704270Z 0 [Warning] [MY-010068] CA certificate ca.pem is self signed.
    2018-04-09T10:07:54.833645Z 0 [Warning] [MY-000000] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
    2018-04-09T10:07:54.841847Z 0 [Warning] [MY-010315] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841879Z 0 [Warning] [MY-010315] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841894Z 0 [Warning] [MY-010315] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841908Z 0 [Warning] [MY-010315] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841931Z 0 [Warning] [MY-010323] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841940Z 0 [Warning] [MY-010323] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.841953Z 0 [Warning] [MY-010311] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.844864Z 0 [Warning] [MY-010330] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.844947Z 0 [Warning] [MY-010330] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
    2018-04-09T10:07:54.850382Z 0 [System] [MY-010931] /usr/sbin/mysqld: ready for connections. Version: '8.0.4-rc-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL).
    

    此外,在minikube中初始化数据库需要25分钟以上的时间。

    Minikube的配置:

    环境 :

    • Minikube版本 :v0。25.2
    • 操作系统 :Ubuntu 16.04.4 LTS
    • VM驱动程序 :virtualbox
    • ISO版本 :minikube-v0。25.1。iso

    我使用的yaml文件:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: demo
    spec:
      finalizers:
      - kubernetes
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: mysql-gvr
      namespace: demo
    spec:
      clusterIP: None
      sessionAffinity: None
      type: ClusterIP
    
    ---
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      labels:
        app: mysql
      name: mysql-8
      namespace: demo
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      serviceName: mysql-gvr
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
          - env:
            - name: MYSQL_ROOT_PASSWORD
              value : "test"
            image: mysql:8.0
            name: mysql
            ports:
            - containerPort: 3306
              name: db
              protocol: TCP
            volumeMounts:
            - mountPath: /var/lib/mysql
              name: data
      volumeClaimTemplates:
      - metadata:
          annotations:
            volume.beta.kubernetes.io/storage-class: standard
          name: data
        spec:
          accessModes:
          - ReadWriteOnce
          resources:
            requests:
              storage: 1Gi
          storageClassName: standard
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: mysql
      namespace: demo
      labels:
        name: mysql
    spec:
      ports:
        - port: 3306
      selector:
        name: mysql
    

    这是因为 mysql:8.0.4 正在使用新的基础映像 debian:stretch ?如有任何指导意见,将不胜感激。

    我还在github中创建了一个问题 docker-library/mysql 存储库以跟踪问题。这是 issue link

    1 回复  |  直到 6 年前
        1
  •  0
  •   Abdullah Al Maruf - Tuhin    6 年前

    看起来,这是一个存储速度慢的问题。将磁盘升级到SSD后,等待时间大大缩短。

    在以前和当前的设置中,我的minikube内存都是4GB。但是,SSD正在发挥巨大的作用。