首先说明一点,每天的访问量并不大每天才2W的访问量,按道理说,访问量再增加一倍这样的服务器也应该足以承受。可是我们的服务器为什么总是这样频频重启呢?经过mysqlreport显示mysql运行的状态如下:MySQL 5.1.-rc-log uptime 0 0:4: Thu Apr :: __ Key _________________________________________________________________Buffer used 7.M of .M %Used: 2. Current .M %Usage: .Write hit 0.%Read hit .%__ Questions ___________________________________________________________Total .k .2/s DMS 9.k .1/s %Total: . QC Hits 3.k .7/s . Com_ 1.k 3.6/s 7. COM_QUIT 1.8/s 3. -Unknown 1 0.0/s 0.Slow 1 s 4 0.0/s 0. %DMS: 0. Log: OFFDMS 9.k .1/s . SELECT 9.k .0/s . . UPDATE 0.1/s 0. 0. REPLACE 0 0/s 0. 0. DELETE 0 0/s 0. 0. INSERT 0 0/s 0. 0.Com_ 1.k /s .4 set_option 1.8/s 3. change_db /s .4 show_proces 5 0.0/s 0.__ SELECT and Sort _____________________________________________________Scan 0.2/s %SELECT: 0.Range 0.1/s 0.Full join 2 0.0/s 0.Range check 0 0/s 0.Full rng join 0 0/s 0.Sort scan 0.2/sSort range 1.6/sSort mrg pass 0 0/s__ Query Cache _________________________________________________________Memory usage .M of .M %Used: 8.Block Fragmnt 0.%Hits 3.k .7/sInserts 9.k .8/sInsrt:Prune 9.k:1 .8/sHit:Insert 0.:1__ Table Locks _________________________________________________________Waited 0 0/s %Total: 0.Immediate .k .4/s__ Tables ______________________________________________________________Open of %Cache: .Opened 0.2/s__ Connections _________________________________________________________Max used 4 of %Max: 0.Total 1.8/s__ Created Temp ________________________________________________________Disk table 1 0.0/sTable 0.6/s Size: .0MFile 5 0.0/s__ Threads _____________________________________________________________Running 2 of 2Cached 2 of %Hit: .Created 4 0.0/sSlow 0 0/s__ Aborted _____________________________________________________________Clients 0 0/sConnects 0 0/s__ Bytes _______________________________________________________________Sent .M .7k/sReceived 1.M 4.7k/s__ InnoDB Buffer Pool __________________________________________________Usage .k of 8.M %Used: 3.Read hit .%Pages Free %Total: . Data 3. %Drty: 0. Misc 0 0. Latched 0.Reads 0.3/s From file 0.0/s . Ahead Rnd 1 0.0/s Ahead Sql 0 0/sWrites 0 0/sFlushes 0 0/sWait Free 0 0/s__ InnoDB Lock _________________________________________________________Waits 0 0/sCurrent 0Time acquiring Total 0 ms Average 0 ms Max 0 ms__ InnoDB Data, Pages, Rows ____________________________________________Data Reads 0.1/s Writes 3 0.0/s fsync 3 0.0/s Pending Reads 0 Writes 0 fsync 0Pages Created 0 0/s Read 0.1/s Written 0 0/sRows Deleted 0 0/s Inserted 0 0/s Read 0 0/s Updated 0 0/s大家可以看到在Com_中占的比例是相当大的,而一般情况下,这个值应该是3.0%左右。如果这个值过高的话,就说明,你的mysql处理请求中做了一些无谓的工作,占用了大量的系统资源。其中我们看到尤为change_db的占用率比较高。这个值高了,说明我们执行的user database;命令相当多。检查程序,原来我们在执行查询语句的时候应用了mysql_query_db("database","sql");这个语句在每次执行的时候都会自动调用use database;所以我们应该将mysql_db_query 更改成mysql_query();再观察mysql的运行状态,ok。一切正常了。
推荐整理分享mysqlreport显示Com_中change_db占用比例高的问题的解决方法,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
解决mysql不能插入中文Incorrect string value 选项default-charaset-set=utf8;然后创建一个数据表createtablea_table(bvarchar()notnull);insertintoa_tablevalues('北京');这个时候插入的是中文,系统会报告错误:Incorrect
mysql从执行.sql文件时处理n换行的问题 在备份数据库的时候,数据表中可能存在这样的值array('a'='b','c'='d')这种格式的值。而在数据导出的时候会将换行换成n(windows下是这样,unix下可能是
mysql 主从服务器的简单配置 首先在主服务器上添加可登陆的用户权限:GRANTREPLICATESLAVEon*.*to'username'@'host'identifiedby'password'然后设置主服务器的my.ini文件。server-id=1#主服务器标识log-bi