|
+------------+----------+-----------------------------------------------------------
mysql> show processlist;
+--------+---------+---------------------+--------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+---------+---------------------+--------+---------+------+-------+------------------+
| 7572 | bbsuser | 61.152.X.89:1885 | wy**| Sleep | 4569 | | NULL |
| 235419 | bbsuser | 61.152.X.89:1935 | wy** | Sleep | 7 | | NULL |
| 262995 | root | localhost | NULL | Query | 0 | NULL | show processlist |
| 263404 | bbsuser | 61.152.X.76:53934 | wy** | Sleep | 93 | | NULL |
| 263948 | bbsuser | 61.152.X.76:54559 | wy** | Sleep | 9 | | NULL |
| 263986 | bbsuser | 61.152.X.76:54600 | wy** | Sleep | 4 | | NULL |
| 264005 | bbsuser | 61.152.X.76:54623 | wy** | Sleep | 1 | | NULL |
| 264010 | bbsuser | 61.152.X.76:54629 | wy** | Sleep | 0 | | NULL |
+--------+---------+---------------------+--------+---------+------+-------+------------------+
8 rows in set (0.00 sec)
1. 升级基本上没帮助
2. 改用innodb试试看
3. 优化你的sql
4. 优化你的索引,缓存等
5. 优化你的程序
6. 换更好的server
vi /etc/my.cnf
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-bdb
skip-innodb
skip-locking
back_log=500
skip-name-resolve
#interactive_timeout=20
#wait_timeout=5
#connect_timeout=10
max_connections=10000
key_buffer = 512M
max_allowed_packet = 4M
table_cache = 1024
sort_buffer_size = 32M
read_buffer_size = 32M
join_buffer_size=32M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 128M
thread_cache_size = 64
query_cache_limit=4M
query_cache_size = 64M
query_cache_type=1
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
#log=/usr/local/mysql/data/mysql.log
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
很多时候MYISAM锁表是由于查询语句的问题,我公司的数据库也是这样的情况,我有次观察到连接量的高峰值竟会达到5000,当时觉得很奇怪,因为根据状态参数最多连接量也是百来个,抓取当时的快照才发现,都是LOCKED ,就象马路上的车一样一辆堵了引起整条路交通瘫痪,而首先引起LOCK的是一条很恶心的查询,而这条查询又频繁出现。
我觉得你还是得从分析引起LOCK的查询入手
摘自 yahohi的专栏
|