当前位置: 首页 > 编程笔记 >

MySQL修改innodb_data_file_path参数的一些注意事项

程皓轩
2023-03-14
本文向大家介绍MySQL修改innodb_data_file_path参数的一些注意事项,包括了MySQL修改innodb_data_file_path参数的一些注意事项的使用技巧和注意事项,需要的朋友参考一下

前言

innodb_data_file_path用来指定innodb tablespace文件,如果我们不在My.cnf文件中指定innodb_data_home_dir和innodb_data_file_path那么默认会在datadir目录下创建ibdata1 作为innodb tablespace。

说明

在测试环境下没有设置过多的详细参数就初始化并启动了服务,后期优化的过程中发现innodb_data_file_path设置过小:

root@node1 14:59: [(none)]> show variables like '%innodb_data_file_path%';
+-----------------------+------------------------+
| Variable_name | Value  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
+-----------------------+------------------------+
1 row in set (0.00 sec)

root@node1 14:59: [(none)]>

当没有配置innodb_data_file_path时,默认innodb_data_file_path = ibdata1:12M:autoextend

[mysqld]
innodb_data_file_path = ibdata1:12M:autoextend

当需要改为1G时,不能直接在配置文件把 ibdata1 改为 1G ,

[mysqld]
innodb_data_file_path = ibdata1:1G:autoextend

否则启动服务之后,从错误日志看到如下报错:

2019-03-29T06:47:32.044316Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!

大致意思就是ibdata1的大小不是 65536page*16KB/1024KB=1G ,而是 786page*16KB/1024KB=12M
(未使用压缩页)

方法一:推荐

而应该再添加一个 ibdata2:1G ,如下:

[mysqld]
innodb_data_file_path = ibdata1:12M;ibdata2:1G:autoextend

重启数据库

方法二:不推荐

直接改为如下的话

[mysqld]
innodb_data_file_path = ibdata1:1G:autoextend

可以删除$mysql_datadir目录下 ibdata1、ib_logfile0、ib_logfile1 文件:

rm -f ibdata* ib_logfile*

也可以启动MySQL,但是mysql错误日志里会报如下错误:

2019-03-29T07:10:47.844560Z 0 [Warning] Could not increase number of max_open_files to more than 5000 (request: 65535)
2019-03-29T07:10:47.844686Z 0 [Warning] Changed limits: table_open_cache: 1983 (requested 2000)
2019-03-29T07:10:48.028262Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-03-29T07:10:48.147653Z 0 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.plugin' doesn't exist
2019-03-29T07:10:48.147775Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2019-03-29T07:10:48.163444Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.gtid_executed' doesn't exist
2019-03-29T07:10:48.163502Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-29T07:10:48.163658Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
mysqld: Table 'mysql.gtid_executed' doesn't exist
2019-03-29T07:10:48.163711Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-29T07:10:48.164619Z 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-03-29T07:10:48.166805Z 0 [Warning] InnoDB: Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.166891Z 0 [Warning] Failed to open optimizer cost constant tables

2019-03-29T07:10:48.168072Z 0 [Warning] InnoDB: Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.168165Z 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
2019-03-29T07:10:48.169454Z 0 [Warning] InnoDB: Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.169527Z 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2019-03-29T07:10:48.170042Z 0 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.170617Z 0 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.170946Z 0 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.171046Z 0 [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.
2019-03-29T07:10:48.171272Z 0 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.171626Z 0 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue.
2019-03-29T07:10:48.171688Z 0 [Warning] Info table is not ready to be used. Table 'mysql.slave_relay_log_info' cannot be opened.

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对小牛知识库的支持。

 类似资料:
  • 本文向大家介绍MySQL中修改表结构时需要注意的一些地方,包括了MySQL中修改表结构时需要注意的一些地方的使用技巧和注意事项,需要的朋友参考一下 MySql 在修改表结构的时候可能会中断产品的正常运行影响用户体验,甚至更坏的结果,丢失数据。不是所有的数据库管理员、程序员、系统管理员都非常了解Mysql能避免这种情况。DBA会经常碰到这种生产中断的情况,当升级脚本修改了应用层和数据库层,或者缺乏经

  • 本文向大家介绍MySQL修改tmpdir参数,包括了MySQL修改tmpdir参数的使用技巧和注意事项,需要的朋友参考一下 今天突然收到报警短信,说是/磁盘空间使用超过阀值。经查看,发现是有很多异常的SQL,执行不了,导致一直在处理,产生了临时占用了/tmp磁盘空间。 由于操作系统的/tmp空间有限,需要进行参数修改,将tmpdir的值路径进行修改。 只能通过配置文件进行修改了。 重启mysql

  • 主要内容:本节引言:,1.多线程,2.线程阻塞,3.evaluateJavascript() 方法,4.处理WebView中url的跳转,5.UserAgent变化,6.使用addJavascriptInterface()的注意事项,7.Remote Debugging,上一节中N5读取联系人的问题解决:,本节小结:本节引言: 本节参考原文:Android 4.4 中 WebView 使用注意事项.md 从Android 4.4开始,Android中的WebView不再是基于WebKit的,而是

  • 在完成较复杂的数据查询时,经常会使用到子查询,编写子查询语句时,要注意如下事项。 1) 子查询语句可以嵌套在 SQL 语句中任何表达式出现的位置 在 SELECT 语句中,子查询可以被嵌套在 SELECT 语句的列、表和查询条件中,即 SELECT 子句,FROM 子句、WHERE 子句、GROUP BY 子句和 HAVING 子句。 前面已经介绍了 WHERE 子句中嵌套子查询的使用方法,下面是

  • 主要内容:UPDATE 语句的基本语法,修改表中的数据,根据条件修改表中的数据在 MySQL 中,可以使用 UPDATE 语句来修改、更新一个或多个表的数据。 UPDATE 语句的基本语法 使用 UPDATE 语句修改单个表,语法格式为: UPDATE <表名> SET 字段 1=值 1 [,字段 2=值 2… ] [WHERE 子句 ] [ORDER BY 子句] [LIMIT 子句] 语法说明如下: :用于指定要更新的表名称。 子句:用于指定表中要修改的列名及其列值。其

  • 本文向大家介绍MySQL安全策略(MySQL安全注意事项),包括了MySQL安全策略(MySQL安全注意事项)的使用技巧和注意事项,需要的朋友参考一下 导读 MySQL被运用于越来越多的业务中,在关键业务中对数据安全性的要求也更高,如何保证MySQL的数据安全? 数据安全如果只靠MySQL应用层面显然是不够的,是需要在多个层面来保护的,包括网络、系统、逻辑应用层、数据库层等。 下面是我们可借鉴的一