风故故,也依依

Stand still in the wind.

导航

MySQL优化配置

tmp_table_size = 500mb //临时表大小设置

//指定用于索引的缓冲区大小,增加它可得到更好的索引处理性能。
//对于内存在4GB左右的服务器该参数可设置为256M或384M。
//注意:该参数值设置的过大反而会是服务器整体效率降低!
key_buffer_size = 384m

sort_buffer_size = 17mb //排序缓存

read_buffer_size=4m //读取缓存

table_cache=256 //表缓存

ft_min_word_len //全文搜索

query_cache_size 查询缓存

<?
#!/bin/sh
#######检查mysql状态
PORT=`netstat -na | grep "LISTEN" | grep "3306" | awk '{print $4}' | awk -F. '{print $2}'`
if [ "$PORT" -eq "3306" ]
        then
#######检查mysql占CPU负载
        mysql_cpu=`top -U root -b -n 1 | grep mysql | awk '{print $10}'|awk -F. '{print $1}'`
##如果mysql cpu负载大于80,则重启mysql
        if [ "$mysql_cpu" -ge "80" ]
                then
                ps xww |grep 'bin/mysqld_safe' |grep -v grep | awk '{print $1}' | xargs kill -9
                ps xww |grep 'libexec/mysqld' |grep -v grep | awk '{print $1}' | xargs kill -9
                sleep 5
                /usr/local/mysql/bin/mysqld_safe --user=root > /dev/null &
        else
                exit 0
        fi
else
         /usr/local/mysql/bin/mysqld_safe --user=root > /dev/null &
fi
?>

影响列数: 4999 (查询花费 0.1756 秒)
UPDATE `jobs_faces` SET postime = '1250784000' WHERE jid <505000 AND jid >500000

jobs_faces字段
字段 类型 整理 属性 Null 默认 额外 操作
jid int(10)   UNSIGNED 否  auto_increment              
oid int(10)   UNSIGNED 否 0               
cid mediumint(8)   UNSIGNED 否 0               
requests smallint(4)   UNSIGNED 否 0               
views mediumint(6)   UNSIGNED 是 0               
checked tinyint(1)   UNSIGNED 否 0               
istoped tinyint(1)   UNSIGNED 否 0               
postime int(10)   UNSIGNED 否 0               
losetime int(10)   UNSIGNED 否 0               
toped tinyint(1)   UNSIGNED 否 0               
toptime int(10)   UNSIGNED 否 0               
bold tinyint(1)   UNSIGNED 否 0               
highlight varchar(7) gbk_chinese_ci  否                
lightime int(10)   UNSIGNED 否 0               
people smallint(4)   UNSIGNED 否 0               
sex tinyint(1)   UNSIGNED 否 0               
djobskinds varchar(30) gbk_chinese_ci  否                
jname varchar(60) gbk_chinese_ci  否

影响列数: 4999 (查询花费 0.2393 秒)
UPDATE `jobs_faces` SET postime = '1250784000' WHERE jid <455000 AND jid >450000

posted on 2011-08-13 15:45  jadmin  阅读(137)  评论(0编辑  收藏  举报