MySQL - my.cnf 中的跳过锁定有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/943723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL - what does skip-locking in my.cnf do?
提问by Richard
I'm using MySQL 5.0.67 on RHEL5 and basing my configuration on my-huge.cnf.
我在 RHEL5 上使用 MySQL 5.0.67 并将我的配置基于 my-huge.cnf。
I can't find anything in the MySQL manual for the row 'skip-locking' which appears in the config file.
我在 MySQL 手册中找不到任何关于配置文件中出现的“跳过锁定”行的内容。
Should this be replaced with 'skip_external_locking' or should I just remove the row entirely as that is now a default.
这应该被替换为“skip_external_locking”,还是我应该完全删除该行,因为现在是默认值。
MySQL Manual for skip-external-locking
Thanks.
谢谢。
采纳答案by Jonathan Fingland
see http://dev.mysql.com/doc/refman/5.0/en/external-locking.html
见http://dev.mysql.com/doc/refman/5.0/en/external-locking.html
quote:
引用:
If you run multiple servers that use the same database directory (not recommended), each server must have external locking enabled.
如果您运行多个使用相同数据库目录的服务器(不推荐),则每个服务器都必须启用外部锁定。
It really just has to do with the dangers presented by multiple processes accessing the same data. In many DBMS situations you want to lock the table/row before performing an operation, and unlocking afterwards. This is to prevent possible data corruption.
它实际上只与访问相同数据的多个进程所带来的危险有关。在许多 DBMS 情况下,您希望在执行操作之前锁定表/行,然后再解锁。这是为了防止可能的数据损坏。
Edit: see http://dev.mysql.com/doc/refman/4.1/en/news-4-0-3.htmlQuote
编辑:见http://dev.mysql.com/doc/refman/4.1/en/news-4-0-3.html报价
Renamed --skip-locking to --skip-external-locking.
将 --skip-locking 重命名为 --skip-external-locking。
回答by codewaggle
An additional note for anyone who doesn't follow the link provided by @Jonathan Fingland :
8.7.4. External Locking
对于不遵循@Jonathan Fingland 提供的链接的任何人的附加说明:
8.7.4。外部锁定
This option only applies to MyISAM tables.
此选项仅适用于 MyISAM 表。
As Richard indicated, external locking is disabled by default. You need to enable external locking if you use myisamchk
for write operations or if you use myisampack
to pack tables.
正如理查德指出的那样,默认情况下禁用外部锁定。如果myisamchk
用于写操作或myisampack
用于打包表,则需要启用外部锁定。
From the docs:
从文档:
If you use myisamchk to perform table maintenance operations on MyISAM tables, you must either ensure that the server is not running, or that the server has external locking enabled so that it locks table files as necessary to coordinate with myisamchk for access to the tables. The same is true for use of myisampack to pack MyISAM tables.
If you use myisamchk for write operations such as repairing or optimizing tables, or if you use myisampack to pack tables, you must always ensure that the mysqld server is not using the table. If you don't stop mysqld, you should at least do a mysqladmin flush-tables before you run myisamchk. Your tables may become corrupted if the server and myisamchk access the tables simultaneously.
如果您使用 myisamchk 在 MyISAM 表上执行表维护操作,您必须确保服务器没有运行,或者服务器启用了外部锁定,以便它根据需要锁定表文件以与 myisamchk 协调以访问表。使用 myisampack 打包 MyISAM 表也是如此。
如果您使用myisamchk 进行修复或优化表等写操作,或者如果您使用myisampack 打包表,则必须始终确保mysqld 服务器没有使用该表。如果你不停止mysqld,你至少应该在运行myisamchk 之前做一个mysqladmin flush-tables。如果服务器和 myisamchk 同时访问表,您的表可能会损坏。