免费注册 查看新帖 |

Chinaunix

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

关于mysql内存溢出,请高手支招 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-06 17:42 |只看该作者 |正序浏览
有台服务器,只运行了一个mysql
服务器配置两颗4核E5410 8G内存 146G sas 15k转速的硬盘
系统为centos 5.2 64位
mysql 5.1.32 64位
平均每秒约1w次查询,优化的还不错,性能很好,负载4左右也很稳定
加载了google的 tcmalloc
现在的问题是,不知道什么原因,内存貌似失控了。内存的使用率,跟配置的完全不是一回事,一般48小时内就能把8G内存耗光,估计4天左右又能把4G的swap空间耗光,用到swap的时候,性能并没有下降。然后,就内存溢出了,挺郁闷。
目前的内存使用情况
free -m
             total       used       free     shared    buffers     cached
Mem:          7982       6999        983          0        237        955
-/+ buffers/cache:       5806       2175
Swap:         4094          6       4087
预计3天以后就能把物理内存和swap都能耗光,然后溢出
主要的表都用的innodb引擎。不多废话,把配置文件贴出来,请高手们不吝赐教

# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# 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
bind-address=192.168.0.2
socket          = /tmp/mysql.sock
skip-locking
key_buffer = 512M
max_allowed_packet = 1M
table_cache = 1024
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 16
set-variable=max_connections=1000
long_query_time = 1
log_slow_queries       = /backup/logs/mysql/mysql-slow.log
max_heap_table_size = 500M
tmp_table_size = 200M
back_log=400
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
skip-name-resolve

# Disable Federated by default
skip-federated

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

# 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

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
#
# binary logging format - mixed recommended
#binlog_format=mixed

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

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
innodb_data_file_path = ibdata1:1500M;ibdata2:1500M;ibdata3:1500M;ibdata4:1500M;ibdata5:1500M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data/
#innodb_log_arch_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 3072M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 256M
innodb_log_buffer_size = 20M
innodb_flush_log_at_trx_commit = 2
innodb_thread_concurrency = 1000
innodb_flush_method = O_DIRECT

[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

[ 本帖最后由 real_lufeng 于 2009-5-6 17:45 编辑 ]

论坛徽章:
1
射手座
日期:2014-03-06 22:16:03
40 [报告]
发表于 2011-04-27 11:12 |只看该作者
很强大,学习了。让我找到了我问题的解决方法。

论坛徽章:
0
39 [报告]
发表于 2011-03-25 16:30 |只看该作者
学习学习

论坛徽章:
0
38 [报告]
发表于 2009-12-15 16:47 |只看该作者
原帖由 real_lufeng 于 2009-5-8 23:08 发表
该问题解决,引出一个新问题,有兴趣的兄弟可以琢磨一下
这个问题确实是由google的tcmalloc引起的,我把这个插件去掉,重启了mysql。观察了约30小时,确认问题已解决
目前的内存使用情况
Mem:   8174224k to ...



厉害!!!学习

论坛徽章:
0
37 [报告]
发表于 2009-11-23 13:55 |只看该作者
有个办法不知行不行,那就是在这台服务器溢出之前关一下机dump一下就不会了,等mysql有好的版本出来之后,测试之后再用!!!这样比较安全

论坛徽章:
0
36 [报告]
发表于 2009-07-13 14:44 |只看该作者
见识了
都很强啊

论坛徽章:
0
35 [报告]
发表于 2009-06-15 16:16 |只看该作者
建议楼主省升级一下mysq说不定可以解决问题,mysql5.1版本的问题很多,当时官方都建议用户谨慎升级,而且5.1 的现在已经升级多很多次版本了,看升级说明,是修正了不少bug

论坛徽章:
0
34 [报告]
发表于 2009-06-03 11:39 |只看该作者
建议楼主改自己的帖子主题,(看着主题感觉就是MYSQL的问题,其实不然)。
同时在测试机上多花工夫去测试,而不是在生产机器上叫

论坛徽章:
9
技术图书徽章
日期:2014-10-14 15:48:13数据库技术版块每日发帖之星
日期:2015-06-04 22:20:00数据库技术版块每日发帖之星
日期:2015-06-10 22:20:00数据库技术版块每日发帖之星
日期:2015-06-11 22:20:00数据库技术版块每日发帖之星
日期:2015-06-13 22:20:00IT运维版块每日发帖之星
日期:2015-09-22 06:20:00IT运维版块每日发帖之星
日期:2015-12-08 06:20:00综合交流区版块每日发帖之星
日期:2016-02-02 06:20:00IT运维版块每日发帖之星
日期:2016-07-25 06:20:00
33 [报告]
发表于 2009-05-12 10:10 |只看该作者
原帖由 bs 于 2009-5-12 09:53 发表
大师要给予颠覆性言论啊,不然光解释现象不够震撼啊

论坛徽章:
0
32 [报告]
发表于 2009-05-12 09:53 |只看该作者
大师要给予颠覆性言论啊,不然光解释现象不够震撼啊
  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP