[Warning] Can't create test file .lower-test
问题描述:今天mysql自己关闭了,且重启依然失败,查看错误日志,信息如下
2022-04-21T06:22:56.142556Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2022-04-21T06:22:56.142599Z 0 [Warning] Changed limits: max_connections: 214 (requested 500)
2022-04-21T06:22:56.142601Z 0 [Warning] Changed limits: table_open_cache: 400 (requested 2000)
2022-04-21T06:22:56.306769Z 0 [Warning] Can't create test file /mnt/newsqldatadir/mysql/iZ8vb6ptmkjv5sahud27xwZ.lower-test
2022-04-21T06:22:56.306829Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.33-0ubuntu0.16.04.1-log) starting as process 10703 ...
2022-04-21T06:22:56.309947Z 0 [Warning] Can't create test file /mnt/newsqldatadir/mysql/iZ8vb6ptmkjv5sahud27xwZ.lower-test
2022-04-21T06:22:56.309983Z 0 [Warning] Can't create test file /mnt/newsqldatadir/mysql/iZ8vb6ptmkjv5sahud27xwZ.lower-test
2022-04-21T06:22:56.313151Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-04-21T06:22:56.313187Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-04-21T06:22:56.313193Z 0 [Note] InnoDB: Uses event mutexes
2022-04-21T06:22:56.313197Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-04-21T06:22:56.313202Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2022-04-21T06:22:56.313208Z 0 [Note] InnoDB: Using Linux native AIO
2022-04-21T06:22:56.313506Z 0 [Note] InnoDB: Number of pools: 1
2022-04-21T06:22:56.313664Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-04-21T06:22:56.315384Z 0 [Note] InnoDB: Initializing buffer pool, total size = 3G, instances = 8, chunk size = 128M
2022-04-21T06:22:56.509359Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-04-21T06:22:56.551516Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-04-21T06:22:56.561660Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2022-04-21T06:22:56.561685Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2022-04-21T06:22:56.561692Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2022-04-21T06:22:57.162151Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-04-21T06:22:57.162185Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-04-21T06:22:57.162194Z 0 [ERROR] Failed to initialize builtin plugins.
2022-04-21T06:22:57.162200Z 0 [ERROR] Aborting
2022-04-21T06:22:57.162207Z 0 [Note] Binlog end
2022-04-21T06:22:57.162657Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
开始查询[ERROR] InnoDB: The innodb_system data file ‘ibdata1’ must be writable,结果授权了也没用,于是查询[Warning] Can’t create test file /mnt/newsqldatadir/mysql/iZ8vb6ptmkjv5sahud27xwZ.lower-test,找到了解决办法
解决:编辑/etc/apparmor.d/usr.sbin.mysqld 文件,将ibdata1的目录贴到里面并重启apparmor
find / -name ibdata1
locate ibdata1
vi /etc/apparmor.d/usr.sbin.mysqld
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/mnt/newsqldatadir/mysql/ r,
/mnt/newsqldatadir/mysql/** rwk,
sudo service apparmor restart
|