免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2891 | 回复: 6
打印 上一主题 下一主题

centos下的MYSQL问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-10 01:13 |只看该作者 |倒序浏览
服务器日发帖量5000左右 PV 11W左右
服务器为centos
PHP v5.1.6
lighttpd/1.4.18
MYSQL 5.0.45

MYSQL 数据库 1.38 GB
独立服务器

服务器负载了一个官方论坛 使用discuz程序
使用xshow首页四格插件

设置xshow 缓存时间为60秒,如果设置为0 每次刷新首页会造成MYSQL CPU占用率极高
无奈设置了60秒,如果设置过高那就失去了这个首页四格的意义.
服务器内存加到了4G 效果稍微改善,但仅仅这个论坛不可能造成服务器这么卡.
现在设置60秒后 仍然间接性发帖 打开首页 回帖 卡住. 卡肯定是卡在MYSQL上了.

目前深夜服务器负载图



  1. # Example MySQL config file for large systems.
  2. #
  3. # This is for a large system with memory = 512M where the system runs mainly
  4. # MySQL.
  5. #
  6. # You can copy this file to
  7. # /etc/my.cnf to set global options,
  8. # mysql-data-dir/my.cnf to set server-specific options (in this
  9. # installation this directory is /var/lib/mysql) or
  10. # ~/.my.cnf to set user-specific options.
  11. #
  12. # In this file, you can use all long options that a program supports.
  13. # If you want to know which options a program supports, run the program
  14. # with the "--help" option.

  15. # The following options will be passed to all MySQL clients
  16. [client]
  17. #password        = your_password
  18. port                = 3306
  19. socket                = /var/lib/mysql/mysql.sock

  20. # Here follows entries for some specific programs

  21. # The MySQL server
  22. [mysqld]
  23. port                = 3306
  24. socket                = /var/lib/mysql/mysql.sock
  25. skip-locking
  26. key_buffer = 1024M
  27. max_allowed_packet = 4M
  28. table_cache = 10240
  29. sort_buffer_size = 6M
  30. read_buffer_size = 6M
  31. read_rnd_buffer_size = 8M
  32. myisam_sort_buffer_size = 128M
  33. thread_cache_size = 128
  34. query_cache_size= 512M
  35. # Try number of CPU's*2 for thread_concurrency
  36. thread_concurrency = 4
  37. back_log = 200
  38. max_connections = 1024
  39. table_cache = 512
  40. read_rnd_buffer_size = 8M
  41. thread_cache_size = 128
  42. wait_timeout= 20

  43. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  44. # if all processes that need to connect to mysqld run on the same host.
  45. # All interaction with mysqld must be made via Unix sockets or named pipes.
  46. # Note that using this option without enabling named pipes on Windows
  47. # (via the "enable-named-pipe" option) will render mysqld useless!
  48. #
  49. #skip-networking

  50. # Replication Master Server (default)
  51. # binary logging is required for replication
  52. log-bin=mysql-bin

  53. # required unique id between 1 and 2^32 - 1
  54. # defaults to 1 if master-host is not set
  55. # but will not function as a master if omitted
  56. server-id        = 1

  57. # Replication Slave (comment out master section to use this)
  58. #
  59. # To configure this host as a replication slave, you can choose between
  60. # two methods :
  61. #
  62. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  63. #    the syntax is:
  64. #
  65. #    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
  66. #    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
  67. #
  68. #    where you replace <host>, <user>, <password> by quoted strings and
  69. #    <port> by the master's port number (3306 by default).
  70. #
  71. #    Example:
  72. #
  73. #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  74. #    MASTER_USER='joe', MASTER_PASSWORD='secret';
  75. #
  76. # OR
  77. #
  78. # 2) Set the variables below. However, in case you choose this method, then
  79. #    start replication for the first time (even unsuccessfully, for example
  80. #    if you mistyped the password in master-password and the slave fails to
  81. #    connect), the slave will create a master.info file, and any later
  82. #    change in this file to the variables' values below will be ignored and
  83. #    overridden by the content of the master.info file, unless you shutdown
  84. #    the slave server, delete master.info and restart the slaver server.
  85. #    For that reason, you may want to leave the lines below untouched
  86. #    (commented) and instead use CHANGE MASTER TO (see above)
  87. #
  88. # required unique id between 2 and 2^32 - 1
  89. # (and different from the master)
  90. # defaults to 2 if master-host is set
  91. # but will not function as a slave if omitted
  92. #server-id       = 2
  93. #
  94. # The replication master for this slave - required
  95. #master-host     =   <hostname>
  96. #
  97. # The username the slave will use for authentication when connecting
  98. # to the master - required
  99. #master-user     =   <username>
  100. #
  101. # The password the slave will authenticate with when connecting to
  102. # the master - required
  103. #master-password =   <password>
  104. #
  105. # The port the master is listening on.
  106. # optional - defaults to 3306
  107. #master-port     =  <port>
  108. #
  109. # binary logging - not required for slaves, but recommended
  110. #log-bin=mysql-bin

  111. # Point the following paths to different dedicated disks
  112. #tmpdir                = /tmp/               
  113. #log-update         = /path-to-dedicated-directory/hostname

  114. # Uncomment the following if you are using BDB tables
  115. #bdb_cache_size = 64M
  116. #bdb_max_lock = 100000

  117. # Uncomment the following if you are using InnoDB tables
  118. #innodb_data_home_dir = /var/lib/mysql/
  119. #innodb_data_file_path = ibdata1:10M:autoextend
  120. #innodb_log_group_home_dir = /var/lib/mysql/
  121. #innodb_log_arch_dir = /var/lib/mysql/
  122. # You can set .._buffer_pool_size up to 50 - 80 %
  123. # of RAM but beware of setting memory usage too high
  124. #innodb_buffer_pool_size = 256M
  125. #innodb_additional_mem_pool_size = 20M
  126. # Set .._log_file_size to 25 % of buffer pool size
  127. #innodb_log_file_size = 64M
  128. #innodb_log_buffer_size = 8M
  129. #innodb_flush_log_at_trx_commit = 1
  130. #innodb_lock_wait_timeout = 50

  131. [mysqldump]
  132. quick
  133. max_allowed_packet = 16M

  134. [mysql]
  135. no-auto-rehash
  136. # Remove the next comment character if you are not familiar with SQL
  137. #safe-updates

  138. [isamchk]
  139. key_buffer = 384M
  140. sort_buffer_size = 6M
  141. read_buffer = 2M
  142. write_buffer = 2M

  143. [myisamchk]
  144. key_buffer = 384M
  145. sort_buffer_size = 6M
  146. read_buffer = 2M
  147. write_buffer = 2M

  148. [mysqlhotcopy]
  149. interactive-timeout
  150. wait_timeout= 20
  151. interactive_tiomeout=120
复制代码
mysql配置

各位大家有什么意见没

论坛徽章:
0
2 [报告]
发表于 2009-06-10 01:39 |只看该作者
phpmyadmin下 show processlist 发现

  ID   用户   主机   数据库   命令   时间   状态   SQL 查询  
Kill   1828184   root   localhost   mlkz   Query   1   Sorting result   SELECT t . * , f.name
FROM cdb_threads t, cdb_forums f
WHERE f.fid = t.fid
AND f.fid NOT
IN ( 24, 160, 106 )   
Kill   1828186   root   localhost   mlkz   Sleep   0   ---   ---  
Kill   1828187   root   localhost   mlkz   Query   3   Sorting result   SELECT t . * , f.name
FROM cdb_threads t, cdb_forums f
WHERE f.fid = t.fid
AND f.fid NOT
IN ( 24, 160, 106 )   
Kill   1828190   root   localhost   mlkz   Query   1   Sending data   SELECT p . * , m.uid, m.username, m.groupid, m.adminid, m.regdate, m.lastactivity, m.posts, m.digestpos

就是在这个时候 论坛会卡住

论坛徽章:
0
3 [报告]
发表于 2009-06-10 09:51 |只看该作者
是不是mysql可以设置一些优化?
感觉像首页这种应该可以缓存长时间的

论坛徽章:
0
4 [报告]
发表于 2009-09-01 19:13 |只看该作者
我以前用Centos带DZ的论坛也是很慢,后来没找出问题,直接换win2003server比centos快多了

论坛徽章:
0
5 [报告]
发表于 2009-09-30 17:08 |只看该作者
优化下mysql缓存看看。
看到你的my.cnf是memory = 512M  的配置,换成large模式的cnf试试。

论坛徽章:
0
6 [报告]
发表于 2009-10-19 20:15 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
7 [报告]
发表于 2009-10-20 22:08 |只看该作者
死楼主没优化好
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP