首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用只读数据目录启动mysqld?

问如何使用只读数据目录启动mysqld?
EN

Database Administration用户
提问于 2014-08-07 19:24:19
回答 1查看 12.7K关注 0票数 3

我正在尝试使用主机挂载只读的数据目录在码头容器中启动MariaDB。MySQLd当然会关闭主机。不幸的是,即使将read_only标志添加到my.conf中,也会出现以下错误:

代码语言:javascript
复制
root@2380610236d1:/# mysqld --innodb-read-only
140807 19:19:38 [Warning] Can't create test file /var/lib/mysql/2380610236d1.lower-test
140807 19:19:38 [ERROR] mysqld: Can't create/write to file '/var/lib/mysql/aria_log_control' (Errcode: 13 "Permission denied")
140807 19:19:38 [ERROR] mysqld: Got error 'Can't create file' when trying to use aria control file '/var/lib/mysql/aria_log_control'
140807 19:19:38 [ERROR] Plugin 'Aria' init function returned error.
140807 19:19:38 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
140807 19:19:38 [Note] InnoDB: Started in read only mode
140807 19:19:38 [Note] InnoDB: Using mutexes to ref count buffer pool pages
140807 19:19:38 [Note] InnoDB: The InnoDB memory heap is disabled
140807 19:19:38 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
140807 19:19:38 [Note] InnoDB: Compressed tables use zlib 1.2.8
140807 19:19:38 [Note] InnoDB: Using Linux native AIO
140807 19:19:38 [Note] InnoDB: Using CPU crc32 instructions
140807 19:19:38 [Note] InnoDB: Disabling background IO write threads.
140807 19:19:38 [Warning] InnoDB: Unable to open "./ib_logfile0" to check native AIO read support.
140807 19:19:38 [Warning] InnoDB: Linux Native AIO disabled.
140807 19:19:38 [Note] InnoDB: Initializing buffer pool, size = 256.0M
140807 19:19:38 [Note] InnoDB: Completed initialization of buffer pool
2014-08-07 19:19:38 7f2bc5a247c0  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
140807 19:19:38 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
140807 19:19:38 [ERROR] InnoDB: The system tablespace must be writable!
140807 19:19:38 [ERROR] Plugin 'InnoDB' init function returned error.
140807 19:19:38 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140807 19:19:38 [Note] Plugin 'FEEDBACK' is disabled.
140807 19:19:38 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
Couldn't start tokudb because some other tokudb process is using the same directory [/var/lib/mysql/] for [environment]
140807 19:19:38 [ERROR] Plugin 'TokuDB' init function returned error.
140807 19:19:38 [ERROR] Plugin 'TokuDB' registration as a STORAGE ENGINE failed.
140807 19:19:38 [ERROR] Unknown/unsupported storage engine: InnoDB
140807 19:19:38 [ERROR] Aborting

140807 19:19:38 [Note] mysqld: Shutdown complete

如何使用只读数据目录启动数据库服务器?

EN

回答 1

Database Administration用户

发布于 2014-08-07 20:11:28

请注意InnoDB体系结构(由Percona CTO Vadim Tkachenko表示)

系统表空间文件ibdata1有需要写入的移动部件。

  • 数据字典
  • 双写缓冲器
    • 防止资料贪污的安全网
    • 帮助Bypass OS缓存

  • 插入缓冲区(流线更改为辅助索引)
  • 回滚段
  • 撤消日志

-无害-只读设置为InnoDB处理只读情况是件好事。

您还需要确保诺姆b_变化_缓冲为0。

你还需要确保崩溃的恢复永远不会发生。这里是如何设置它。

首先,使用可写媒体上的数据库,登录到MySQL并运行如下:

代码语言:javascript
复制
mysql> set global innodb_fast_shutdown = 0;

然后,转到操作系统并运行

代码语言:javascript
复制
service mysql stop

启用诺姆b后,这将导致mysqld在关闭InnoDB管道时将所有设备及其祖母从InnoDB管道中清除出来。

接下来,将datadir移动到只读媒体。

然后,将其添加到my.conf中

代码语言:javascript
复制
[mysqld]
innodb_change_buffering = 0
innodb_read_only = 1

最后,使用service mysql start和InnoDB启动mysql应该非常快,因为没有必要执行崩溃恢复,因为所有东西都是事先从InnoDB管道中清除出来的。

票数 4
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/73438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档