MySQL基础知识

[MySQL FAQ]系列 -- MySQL 5.1以下如何动态抓取查询日志

想要在MySQL 5.1以下的版本中动态抓取提交到MySQL中的查询日志,可以采用tcpdump的方法,大致如下:

tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'

eth0指mysqld监听的网卡,330自然是指mysqld监听的端口,正则匹配模式里,可以自己添加想要抓取的SQL语句类型。

ERROR 1206 (HY000): The total number of locks exceeds the lock table size 错误解决

错误现象如下:

mysql> DELETE FROM JHF_CP_SPOT_RATE WHERE FRONT_DATE = '20070801';
ERROR 1206 (HY000): The total number of locks exceeds the lock table size

把 delete 改成 select,再explain一下,发现返回结果高达300多万,于是检查 max_write_lock_count 的值,是 8446744073709551615,肯定够用了。
再看看 innodb_buffer_pool_size,我的天,才设置默认的 8M,该死的。加大到合适的值,重启 mysql,一切ok。

还有一招,就是delete时分成多次,每次用 LIMIT 限定记录数,这样也ok :)

Q&A Webinar Part 4 - MySQL Cluster(转贴)

原文转自:http://onlinesolutionsmysql.blogspot.com/2007/05/q-webinar-part-4-mysql-cluster.html

Q from Olivier - Are the data nodes MySQL servers too ?
No, the data node is handled by a separate process, ndbd, that only manages data.

Q from Olivier: So, what is MySQL Cluster? A MySQL AB product ?
Technically speaking, MySQL Cluster is a storage engine, based on a network distributed database. From a commercial point of view, we refer at MySQL Cluster as a product. We also provide APIs to access to the Cluster database directly, bypassing the MySQL Server and the storage engine architecture.

解决MySQL Replication出错一例

os: redhat as4
master: MySQL 4.0.23
slave : MySQL 5.0.37

slave日志中报错信息如下:

060807 11:40:17 [ERROR] While trying to obtain the list of 
slaves from the master 'xxx.xxx.xxx:3306', user 'rep' got the
 following error: 'Access denied. You need the REPLICATION SLAVE
 privilege for this operation'

在master上,执行以下语句查看权限:

mysql>SHOW GRANT FOR 'rep'@'192.168.0.2'\G
*************************** 1. row ***************************
Grants for rep@192.168.0.2: GRANT SELECT, REPLICATION SLAVE ON
 *.* TO 'rep'@'192.168.0.2' IDENTIFIED BY PASSWORD 'xxx'

已经授予了 REPLICAION SLAVE 权限了,怎么还会报这个错呢?

Questions and Answers During the First Session

原文来自: http://onlinesolutionsmysql.blogspot.com/2007/03/questions-and-answers-during-first.html

On Server and Storage Engines

Q from Alessandro: What about the filesystem for MyISAM in a small company? Better ReiserFS or EXT3?
As Anders said, it's a matter of taste. XFS is a good alternative too. Ext3 is stable, but sometimes slow and a bit outdated. Many like Reiser, but it is sometimes difficult to manage. XFS often gives you good performance and reliability out of the box.

Q from Florian: MySQL 5.1 == Falcon?

Questions and Answers in the Second Session of the Online Solutions with MySQL Webinar - On Replication

原文来自: http://onlinesolutionsmysql.blogspot.com/2007/05/questions-and-answers-in-second-session.html

Correction on the INSERT DELAYED
In slide 20 I have mentioned that the INSERT DELAYED statement can increase performance on the slave. This is wrong, since the DELAYED keyword is ignored by the SQL thread on the slave server. The INSERT DELAYED statement can increase the overall performance of an application since the control is returned to the client as soon as the row is queued into the list of inserts to execute. The INSERT DELAYED can be used with MyISAM, MEMORY and ARCHIVE.

Q from Filip: Does master & slave have to be the same db-version, and the same Operative system?

"log_bin.index not found" 启动报错解决

my.cnf 中设置了:

log-bin=log_bin
log-bin-index=log_bin.index

但是启动后,总是报告如下错误:

mysqld: File './log_bin.index' not found (Errcode: 13) 
070428 14:35:59 [ERROR] Aborting 

070428 14:35:59 [Note] mysqld: Shutdown complete

自己 touch 一个文件出来,不行。
修改文件 log_bin.index 的权限为 777,也不行。

[root@localhost]#/usr/local/mysql/bin/perror 13

System error:  13 = Permission denied

看来还是权限的问题,突然想起来 datadir 权限设置可能不对。

[root@localhost]#ls -l /usr/local/mysql | grep data

drw-------   3 nobody nobody  4096 Apr 29 11:17 data

Falcon 存储引擎设计窥探

原文出自: http://www.mysqlperformanceblog.com/2007/01/12/falcon-storage-engine-des...

Falcon Storage Engine Design Review

Now as new MySQL Storage engine - Falcon is public I can write down my thought about its design, which I previously should have kept private as I partially got them while working for MySQL.

These thought base on my understanding, reading docs, speaking to Jim, Monty, Arjen and other people so I might miss something, something might be planned to be changed or not 100% correct but anyway you might find it interesting.

In many cases what I find good or bad would base of my MySQL use with existing applications - if you design new applications which are done specially for Falcon you might find those aspects positive.

mysqldump死住(实际是导致mysqld crash)

在MySQL 5.0.16上,用mysqldump导出数据,mysqldump半天没反应。
操作系统是RHEL4.0。

看日志
*** glibc detected *** free(): invalid pointer: 0xb17d60b0 ***
mysqld got signal 6;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=8388600
read_buffer_size=131072
max_used_connections=2
max_connections=100
threads_connected=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 225791 K

聚合内容