[h2title]问题发现[/h2title]
docker运行了mysql后过段时间,mysql自停止或者启动该容器后正常,但是看状态就是不up。
[h2title]问题分析[/h2title]
核查log有如下2问题:
2021-01-30 03:54:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.50-1debian9 started. 2021-01-30 03:54:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2021-01-30 03:54:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.50-1debian9 started. 2021-01-30 03:54:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2021-01-30 03:54:06 0 [Note] mysqld (mysqld 5.6.50) starting as process 1 ... 2021-01-30 03:54:06 1 [Note] Plugin 'FEDERATED' is disabled. 2021-01-30 03:54:06 1 [Note] InnoDB: Using atomics to ref count buffer pool pages 2021-01-30 03:54:06 1 [Note] InnoDB: The InnoDB memory heap is disabled 2021-01-30 03:54:06 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2021-01-30 03:54:06 1 [Note] InnoDB: Memory barrier is not used 2021-01-30 03:54:06 1 [Note] InnoDB: Compressed tables use zlib 1.2.11 2021-01-30 03:54:06 1 [Note] InnoDB: Using Linux native AIO 2021-01-30 03:54:06 1 [Note] InnoDB: Using CPU crc32 instructions 2021-01-30 03:54:06 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 2021-01-30 03:54:06 1 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 2021-01-30 03:54:06 1 [ERROR] Plugin 'InnoDB' init function returned error. 2021-01-30 03:54:06 1 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2021-01-30 03:54:06 1 [ERROR] Unknown/unsupported storage engine: InnoDB 2021-01-30 03:54:06 1 [ERROR] Aborting
网上查了下需要配置个plugin federated进mysql配置文件解决问题1
配置默认引擎MyISAM解决问题2
https://www.landui.com/help/show-1388.html
[h2title]问题解决[/h2title]
编辑下mysql容器内配置文件
docker cp wordpress-mysql:/etc/mysql/mysql.conf.d/mysqld.cnf ./
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0
编辑好文件后 拷贝进容器
docker cp mysqld.cnf wordpress-mysql:/etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #20210130 add 2 error info federated #loose-skip-innodb default-storage-engine = MyISAM
复位mysql容器
docker restart wordpress-mysql
查看运行日志如下:
2021-01-30 16:29:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.50-1debian9 started. 2021-01-30 16:29:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2021-01-30 16:29:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.50-1debian9 started. 2021-01-30 16:29:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2021-01-30 16:29:22 0 [Note] mysqld (mysqld 5.6.50) starting as process 1 ... 2021-01-30 16:29:22 1 [Note] InnoDB: Using atomics to ref count buffer pool pages 2021-01-30 16:29:22 1 [Note] InnoDB: The InnoDB memory heap is disabled 2021-01-30 16:29:22 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2021-01-30 16:29:22 1 [Note] InnoDB: Memory barrier is not used 2021-01-30 16:29:22 1 [Note] InnoDB: Compressed tables use zlib 1.2.11 2021-01-30 16:29:22 1 [Note] InnoDB: Using Linux native AIO 2021-01-30 16:29:22 1 [Note] InnoDB: Using CPU crc32 instructions 2021-01-30 16:29:22 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2021-01-30 16:29:22 1 [Note] InnoDB: Completed initialization of buffer pool 2021-01-30 16:29:22 1 [Note] InnoDB: Highest supported file format is Barracuda. 2021-01-30 16:29:22 1 [Note] InnoDB: The log sequence numbers 1663510 and 1663510 in ibdata files do not match the log sequence number 1663560 in the ib_logfiles! 2021-01-30 16:29:22 1 [Note] InnoDB: Database was not shutdown normally! 2021-01-30 16:29:22 1 [Note] InnoDB: Starting crash recovery. 2021-01-30 16:29:22 1 [Note] InnoDB: Reading tablespace information from the .ibd files... 2021-01-30 16:29:22 1 [Note] InnoDB: Restoring possible half-written data pages 2021-01-30 16:29:22 1 [Note] InnoDB: from the doublewrite buffer... 2021-01-30 16:29:22 1 [Note] InnoDB: 128 rollback segment(s) are active. 2021-01-30 16:29:22 1 [Note] InnoDB: Waiting for purge to start 2021-01-30 16:29:22 1 [Note] InnoDB: 5.6.50 started; log sequence number 1663560 2021-01-30 16:29:22 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work. 2021-01-30 16:29:22 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 2021-01-30 16:29:22 1 [Note] Server hostname (bind-address): '*'; port: 3306 2021-01-30 16:29:22 1 [Note] IPv6 is available. 2021-01-30 16:29:22 1 [Note] - '::' resolves to '::'; 2021-01-30 16:29:22 1 [Note] Server socket created on IP: '::'. 2021-01-30 16:29:22 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2021-01-30 16:29:22 1 [Warning] 'proxies_priv' entry '@ root@fa74473e4a19' ignored in --skip-name-resolve mode. 2021-01-30 16:29:22 1 [Note] Event Scheduler: Loaded 0 events 2021-01-30 16:29:22 1 [Note] mysqld: ready for connections. Version: '5.6.50' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
[h2title]问题后续[/h2title]
近期发现主机内存mysql消耗过大,不久就自行崩溃,docker都提示超出mem,正好今天看到可以免费升级2G内存轻量云服务器,后面几天再观察下是否运行稳定。