database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 24926 게시물 읽기
No. 24926
mysqld의 메모리 증가... ㅠ.ㅠ
작성자
Rem
작성일
2006-01-03 17:55ⓒ
2006-01-03 17:57ⓜ
조회수
21,802

mysqld의 메모리가 계속 증가하네요.

지금 top으로 확인중인데... 계속 증가하다 끝내 다운..

mysql을 재시작하면 돼긴 하지만 언제까지 그럴순 없고...

도대체 이유가 뭘까요?

show status 와 show variable 그리고 my.cnf 파일 올립니다. ㅠ.ㅠ

 

top

 

5:53pm up 250 days, 1:41, 3 users, load average: 3.71, 3.71, 3.81
65 processes: 64 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 37.4% user, 31.0% system, 0.0% nice, 131.4% idle
CPU0 states: 15.2% user, 16.2% system, 0.0% nice, 67.4% idle
CPU1 states: 22.0% user, 14.2% system, 0.0% nice, 63.2% idle
Mem: 2068180K av, 1546348K used, 521832K free, 0K shrd, 109872K buff
Swap: 1052216K av, 3036K used, 1049180K free 766568K cached

PID USER PRI NI SIZE RSS SHARE LC STAT %CPU %MEM TIME COMMAND
15973 root 15 0 944 944 712 1 R 3.5 0.0 0:35 top
11133 mysql 15 0 446M 446M 3692 1 S 0.7 22.1 1:47 mysqld
11123 mysql 15 0 446M 446M 3692 1 S 0.3 22.1 2:24 mysqld
11096 root 18 0 956 956 796 1 S 0.0 0.0 0:00 mysqld_safe
11125 mysql 16 0 446M 446M 3692 0 S 0.0 22.1 2:14 mysqld
11126 mysql 20 0 446M 446M 3692 1 S 0.0 22.1 0:00 mysqld
11127 mysql 15 0 446M 446M 3692 1 S 0.0 22.1 0:00 mysqld
11128 mysql 17 0 446M 446M 3692 1 S 0.0 22.1 0:00 mysqld
11129 mysql 15 0 446M 446M 3692 1 S 0.0 22.1 0:00 mysqld
11130 mysql 15 0 446M 446M 3692 0 S 0.0 22.1 0:00 mysqld
11131 mysql 15 0 446M 446M 3692 0 S 0.0 22.1 0:00 mysqld
11132 mysql 15 0 446M 446M 3692 1 S 0.0 22.1 0:00 mysqld

 

 

mysql> show status;
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| Aborted_clients | 16 |
| Aborted_connects | 3 |
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 0 |
| Bytes_received | 568610005 |
| Bytes_sent | 2401481832 |
| Com_admin_commands | 369 |
| Com_alter_db | 0 |
| Com_alter_table | 0 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 894207 |
| Com_change_master | 0 |
| Com_check | 15 |
| Com_checksum | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 0 |
| Com_dealloc_sql | 0 |
| Com_delete | 86 |
| Com_delete_multi | 0 |
| Com_do | 0 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 0 |
| Com_drop_user | 0 |
| Com_execute_sql | 0 |
| Com_flush | 0 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_help | 0 |
| Com_insert | 914 |
| Com_insert_select | 0 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 0 |
| Com_optimize | 0 |
| Com_preload_keys | 0 |
| Com_prepare_sql | 0 |
| Com_purge | 0 |
| Com_purge_before_date | 0 |
| Com_rename_table | 0 |
| Com_repair | 1 |
| Com_replace | 0 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_revoke_all | 0 |
| Com_rollback | 0 |
| Com_savepoint | 0 |
| Com_select | 5838651 |
| Com_set_option | 0 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_charsets | 0 |
| Com_show_collations | 0 |
| Com_show_column_types | 0 |
| Com_show_create_db | 0 |
| Com_show_create_table | 0 |
| Com_show_databases | 0 |
| Com_show_errors | 0 |
| Com_show_fields | 0 |
| Com_show_grants | 0 |
| Com_show_innodb_status | 0 |
| Com_show_keys | 0 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_privileges | 0 |
| Com_show_processlist | 25 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 2 |
| Com_show_storage_engines | 0 |
| Com_show_tables | 1 |
| Com_show_variables | 1 |
| Com_show_warnings | 0 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 101367 |
| Com_update_multi | 0 |
| Connections | 894385 |
| Created_tmp_disk_tables | 99123 |
| Created_tmp_files | 16761 |
| Created_tmp_tables | 99895 |
| Delayed_errors | 0 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 146 |
| Handler_discover | 0 |
| Handler_read_first | 370 |
| Handler_read_key | 3806513 |
| Handler_read_next | 149639885 |
| Handler_read_prev | 101530319 |
| Handler_read_rnd | 1935765 |
| Handler_read_rnd_next | 776436586 |
| Handler_rollback | 0 |
| Handler_update | 101324 |
| Handler_write | 5621205 |
| Key_blocks_not_flushed | 0 |
| Key_blocks_unused | 14034 |
| Key_blocks_used | 464 |
| Key_read_requests | 50306812 |
| Key_reads | 976 |
| Key_write_requests | 1138 |
| Key_writes | 1068 |
| Max_used_connections | 67 |
| Not_flushed_delayed_rows | 0 |
| Open_files | 90 |
| Open_streams | 0 |
| Open_tables | 64 |
| Opened_tables | 865 |
| Qcache_free_blocks | 0 |
| Qcache_free_memory | 0 |
| Qcache_hits | 0 |
| Qcache_inserts | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_queries_in_cache | 0 |
| Qcache_total_blocks | 0 |
| Questions | 7733991 |
| Rpl_status | NULL |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 226127 |
| Select_range_check | 0 |
| Select_scan | 2982046 |
| Slave_open_temp_tables | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 0 |
| Sort_merge_passes | 8379 |
| Sort_range | 5277 |
| Sort_rows | 4994012 |
| Sort_scan | 628085 |
| Table_locks_immediate | 6148624 |
| Table_locks_waited | 21250 |
| Threads_cached | 0 |
| Threads_connected | 1 |
| Threads_created | 894384 |
| Threads_running | 1 |
| Uptime | 114633 |
+--------------------------+------------+

 

 

mysql> show variables;
+---------------------------------+-------------------------------------------+
| Variable_name | Value |
+---------------------------------+-------------------------------------------+
| back_log | 50 |
| basedir | /usr/local/mysql/ |
| binlog_cache_size | 32768 |
| bulk_insert_buffer_size | 8388608 |
| character_set_client | ujis |
| character_set_connection | ujis |
| character_set_database | ujis |
| character_set_results | ujis |
| character_set_server | ujis |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |
| collation_connection | ujis_japanese_ci |
| collation_database | ujis_japanese_ci |
| collation_server | ujis_japanese_ci |
| concurrent_insert | ON |
| connect_timeout | 5 |
| datadir | /usr/local/mysql/var/ |
| date_format | %Y-%m-%d |
| datetime_format | %Y-%m-%d %H:%i:%s |
| default_week_format | 0 |
| delay_key_write | ON |
| delayed_insert_limit | 100 |
| delayed_insert_timeout | 300 |
| delayed_queue_size | 1000 |
| expire_logs_days | 0 |
| flush | OFF |
| flush_time | 0 |
| ft_boolean_syntax | + -><()~*:""&| |
| ft_max_word_len | 84 |
| ft_min_word_len | 4 |
| ft_query_expansion_limit | 20 |
| ft_stopword_file | (built-in) |
| group_concat_max_len | 1024 |
| have_archive | NO |
| have_bdb | NO |
| have_compress | YES |
| have_crypt | YES |
| have_csv | NO |
| have_example_engine | NO |
| have_geometry | YES |
| have_innodb | YES |
| have_isam | NO |
| have_ndbcluster | NO |
| have_openssl | NO |
| have_query_cache | YES |
| have_raid | NO |
| have_rtree_keys | YES |
| have_symlink | YES |
| init_connect | |
| init_file | |
| init_slave | |
| innodb_additional_mem_pool_size | 1048576 |
| innodb_autoextend_increment | 8 |
| innodb_buffer_pool_awe_mem_mb | 0 |
| innodb_buffer_pool_size | 8388608 |
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir | |
| innodb_fast_shutdown | ON |
| innodb_file_io_threads | 4 |
| innodb_file_per_table | OFF |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_flush_method | |
| innodb_force_recovery | 0 |
| innodb_lock_wait_timeout | 50 |
| innodb_log_arch_dir | |
| innodb_log_archive | OFF |
| innodb_log_buffer_size | 1048576 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_max_dirty_pages_pct | 90 |
| innodb_table_locks | ON |
| innodb_max_purge_lag | 0 |
| innodb_mirrored_log_groups | 1 |
| innodb_open_files | 300 |
| innodb_thread_concurrency | 8 |
| interactive_timeout | 28800 |
| join_buffer_size | 131072 |
| key_buffer_size | 16777216 |
| key_cache_age_threshold | 300 |
| key_cache_block_size | 1024 |
| key_cache_division_limit | 100 |
| language | /usr/local/mysql/share/mysql/english/ |
| large_files_support | ON |
| license | GPL |
| local_infile | ON |
| locked_in_memory | OFF |
| log | OFF |
| log_bin | ON |
| log_error | |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_update | OFF |
| log_warnings | 1 |
| long_query_time | 10 |
| low_priority_updates | OFF |
| lower_case_file_system | OFF |
| lower_case_table_names | 0 |
| max_allowed_packet | 2096128 |
| max_binlog_cache_size | 4294967295 |
| max_binlog_size | 1073741824 |
| max_connect_errors | 10 |
| max_connections | 100 |
| max_delayed_threads | 20 |
| max_error_count | 64 |
| max_heap_table_size | 16777216 |
| max_insert_delayed_threads | 20 |
| max_join_size | 4294967295 |
| max_length_for_sort_data | 1024 |
| max_relay_log_size | 0 |
| max_seeks_for_key | 4294967295 |
| max_sort_length | 1024 |
| max_tmp_tables | 32 |
| max_user_connections | 0 |
| max_write_lock_count | 4294967295 |
| myisam_data_pointer_size | 4 |
| myisam_max_extra_sort_file_size | 2147483648 |
| myisam_max_sort_file_size | 2147483647 |
| myisam_recover_options | OFF |
| myisam_repair_threads | 1 |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 8192 |
| net_read_timeout | 30 |
| net_retry_count | 10 |
| net_write_timeout | 60 |
| new | OFF |
| old_passwords | OFF |
| open_files_limit | 1024 |
| pid_file | /usr/local/mysql/var/localhost.pid |
| port | 3306 |
| preload_buffer_size | 32768 |
| protocol_version | 10 |
| query_alloc_block_size | 8192 |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 0 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
| query_prealloc_size | 8192 |
| range_alloc_block_size | 2048 |
| read_buffer_size | 258048 |
| read_only | OFF |
| read_rnd_buffer_size | 520192 |
| relay_log_purge | ON |
| rpl_recovery_rank | 0 |
| secure_auth | OFF |
| server_id | 1 |
| skip_external_locking | ON |
| skip_networking | OFF |
| skip_show_database | OFF |
| slave_net_timeout | 3600 |
| slow_launch_time | 2 |
| socket | /tmp/mysql.sock |
| sort_buffer_size | 524280 |
| sql_mode | |
| storage_engine | MyISAM |
| sync_binlog | 0 |
| sync_frm | ON |
| system_time_zone | JST |
| table_cache | 64 |
| table_type | MyISAM |
| thread_cache_size | 0 |
| thread_stack | 196608 |
| time_format | %H:%i:%s |
| time_zone | SYSTEM |
| tmp_table_size | 33554432 |
| tmpdir | |
| transaction_alloc_block_size | 8192 |
| transaction_prealloc_size | 4096 |
| tx_isolation | REPEATABLE-READ |
| version | 4.1.7-log |
| version_comment | Source distribution |
| version_compile_machine | i686 |
| version_compile_os | pc-linux |
| wait_timeout | 28800 |
+---------------------------------+-------------------------------------------+

 

 

my.cnf

 

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# 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/var) 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
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 2M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M


# 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

# Replication Master Server (default)
# binary logging is required for replication
log-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

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

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/var/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/var/
#innodb_log_arch_dir = /usr/local/mysql/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[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 = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

이 글에 대한 댓글이 총 11건 있습니다.

아래가 다운되기 직전의 top 결과인지요.

그리고 다운된다는 게, 서비스가 다운되는 것인지, 서버 H/W 자체가 다운인지 다운된다는 증상에 대한 자세한 설명이 필요합니다.

 

그리고 top에서 대문자 M을 누르면 메모리 사용량으로 소팅되서 결과가 나오거든요.

 

지금은 CPU 사용량으로 소팅이 되었군요.

 

메모리 사용량으로 소팅된 top의 결과를 보고 싶습니다.

 

그리고 MySQL 설정 상으로는 특별한 이상은 안 보입니다.

 

허정수(wertyu)님이 2006-01-03 18:09에 작성한 댓글입니다.

메모리로 정렬했을때의 top 화면입니다.....

그리고 현재 top 화면이고요..

메모리가 1GB (?)정도가 넘어가니...SELECT 시 에러가 나더군요..

이게 다운된다고 말씀드린 현상입니다..

select 쿼리만 날리면 에러가 납니다..정확한 에러는 기억이 안나지만..

1030.......스토리지 엔진...뭐.....라고 나왔던것 같네요..ㅠ.ㅠ

 

  6:11pm  up 250 days,  1:59,  3 users,  load average: 3.81, 4.48, 4.37
65 processes: 64 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 48.8% user, 35.8% system,  0.0% nice, 115.0% idle
CPU0 states: 23.4% user, 19.0% system,  0.0% nice, 56.4% idle
CPU1 states: 24.4% user, 16.4% system,  0.0% nice, 58.0% idle
Mem:  2068180K av, 1559664K used,  508516K free,       0K shrd,  109896K buff
Swap: 1052216K av,    3036K used, 1049180K free                  767332K cached

  PID USER     PRI  NI  SIZE  RSS SHARE LC STAT %CPU %MEM   TIME COMMAND
11130 mysql     15   0  457M 457M  3696  0 S     0.0 22.6   0:00 mysqld
11131 mysql     15   0  457M 457M  3696  1 S     0.0 22.6   0:00 mysqld
11132 mysql     15   0  457M 457M  3696  1 S     0.0 22.6   0:00 mysqld
11133 mysql     15   0  457M 457M  3696  1 S     0.0 22.6   1:47 mysqld
28868 mysql     15   0  457M 457M  3696  1 S     0.0 22.6   0:00 mysqld
  692 mysql     16   0  457M 457M  3696  1 S     0.3 22.6   0:00 mysqld
11129 mysql     15   0  457M 457M  3696  1 S     0.0 22.6   0:00 mysqld
11127 mysql     15   0  456M 456M  3696  1 S     0.0 22.6   0:00 mysqld
11128 mysql     17   0  456M 456M  3696  1 S     0.0 22.6   0:00 mysqld
11126 mysql     20   0  456M 456M  3696  1 S     0.0 22.6   0:00 mysqld
11123 mysql     15   0  456M 456M  3696  1 S     0.0 22.6   2:26 mysqld
11125 mysql     15   0  456M 456M  3696  1 S     0.0 22.6   2:15 mysqld
  385 root      15   0  2132 2132  1900  1 S     0.0  0.1   0:02 ntpd
28846 root      15   0  1580 1580  1176  1 S     0.0  0.0   0:00 mysql
 6767 root      15   0  1344 1344  1104  0 S     0.0  0.0   0:05 sshd
15954 root      15   0  1344 1344  1104  1 S     0.0  0.0   0:01 sshd
 6778 root      15   0  1340 1340  1016  0 S     0.0  0.0   0:00 bash
15959 root      15   0  1336 1336  1012  1 S     0.0  0.0   0:00 bash
11096 root      18   0   956  956   796  1 S     0.0  0.0   0:00 mysqld_safe
32399 root      15   0   940  940   712  0 R     4.3  0.0   0:04 top
 3298 root      15   0  1296  736   452  0 S     0.0  0.0  26:25 snmpd
  353 root      15   0   928  172   120  1 S     0.0  0.0   0:00 klogd
  343 root      15   0   204  156   112  0 S     0.0  0.0   0:03 syslogd

Rem님이 2006-01-03 18:14에 작성한 댓글입니다. Edit

다운된다는 것이 그런 의미였군요.

 

일단 말씀하신 에러 메시지를 봐야 정확한 판단을 할 수 있습니다.

 

그리고 시스템 가용 메모리는 Free + Cached 입니다.

따라서 Rem님의 경우는 약 500MB(free) + 767MB(cached) = 1.2GB 정도가 여유있고요. 시스템의 메모리가 모두 고갈된 것은 아닌 것입니다.

 

일단 지금 my.cnf는 버퍼들이 작게 되어 있는데, 메모리 때문에다운(?)된다고 생각하셔서 일부러 작은 값을 주셨는지요.

 

암튼 에러 메시지를 캡쳐해서 올려주시구요.

 

테이블 타입이 MyISAM인지 InnoDB인지도 알려주세요.

key_buffer는 테이블 타입에 따라 사용하지 않을 수도 있거든요.

허정수(wertyu)님이 2006-01-03 18:27에 작성한 댓글입니다.

댓글 감사합니다....ㅜ.ㅡ

첫번째 top과 두번째 top을 보시면 아시겠지만..

지금도 메모리가 꾸준히 증가하고 있어서요..이대로라면 내일이면 메모리가 고갈될것 같아서요..

mysql을 리스타트 시키면 괜찮긴 한데 리스타트 시키기 전에 원인이라고 알고싶어 문의드린 겁니다..

 

테이블 타입은 모두 MyISAM입니다... 그리고 에러메시지는...

 

로그를 살펴보니 이거군요...

[ERROR] /usr/local/mysql/libexec/mysqld: Got error 12 from storage engine

 

perror로 확인 결과....

Error code  12:  Cannot allocate memory

 

ㅠ.ㅠ

 

Rem님이 2006-01-03 18:35에 작성한 댓글입니다.
이 댓글은 2006-01-03 19:26에 마지막으로 수정되었습니다. Edit

일단 서버 uptime이 250일인 것을 보니, 서버에 메모리가 완전 고갈되서 먹통이 되서 리부팅한 적은 없어 보이군요.

램이 다 없어질까바 두려우셔서(?) MySQL 데몬만 껐다 키신 듯 합니다.

 

일단 갈 때까지 가보시고, 스와핑이 엄청나게 일어날 때쯤에 top 결과를 좀 올려줘보세요. 제 생각에는 어느 정도 올라다가가 일정 수준을 유지할 것으로 예상됩니다.

 

[ERROR] /usr/local/mysql/libexec/mysqld: Got error 12 from storage engine

Error code  12:  Cannot allocate memory

 

암튼 앞에서 다운된다는 말씀이 12번 에러를 말씀하시는 듯 한데요.

이게 참 골치 아픈 문제입니다. 10번 에러, 11번 에러, 12번 에러.. 이것들이요....

 

메모리를 alloc하지 못하는 이유는 실제 피지컬한 메모리가 부족할 수도 있고, 아니면 피지컬 메모리가 넉넉하더라도, MySQL 데몬이 쓸 수 있는 메모리가 부족할 수 있는 경우입니다.

 

앞에 말씀드린 데로 시스템 가용 메모리는 free + cached이므로, 만약 앞의 상황에서 12번 에러가 난 것이라면 피지컬 메모리가 부족한 원인은 아니라고 생각됩니다. 왜냐면 약 1.2GB 나 남아있거든요.

 

그렇다면 후자의 경우라는 이야기인데 이건 ulimit -a 의 결과를 보면 알 수 있습니다.

 

일단

 

1) 사용하시는 OS와 버전

2) ulimit -a 의 결과(주의. mysql 계정에서의 ulimit 결과가 필요합니다.)

3) MySQL 버전 및 설치 방법(소스 컴파일인지 바이너리 설치인지)

 

이 결과를 보면 해결하는데 도움이 될 것입니다.

허정수(wertyu)님이 2006-01-03 20:29에 작성한 댓글입니다.

늦은시간까지 댓글 감사합니다..

지금 시간의 top 결과입니다..

 

  9:01pm  up 250 days,  4:49,  2 users,  load average: 6.07, 5.90, 5.69
67 processes: 64 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: 109.8% user, 65.0% system,  0.0% nice, 25.0% idle
CPU0 states: 57.3% user, 31.0% system,  0.0% nice, 11.1% idle
CPU1 states: 52.1% user, 33.4% system,  0.0% nice, 13.4% idle
Mem:  2068180K av, 1740192K used,  327988K free,       0K shrd,  109976K buff
Swap: 1052216K av,    3036K used, 1049180K free                  776200K cached

  PID USER     PRI  NI  SIZE  RSS SHARE LC STAT %CPU %MEM   TIME COMMAND
11959 mysql     18   0  611M 611M  3696  0 R    15.2 30.2   0:00 mysqld
11964 mysql     16   0  611M 611M  3696  0 S     0.3 30.2   0:00 mysqld
11921 mysql     15   0  611M 611M  3696  1 S     3.8 30.2   0:00 mysqld
11942 mysql     16   0  611M 611M  3696  0 S     0.0 30.2   0:00 mysqld
11769 mysql     17   0  611M 611M  3696  0 S     0.0 30.2   0:00 mysqld
11133 mysql     15   0  611M 611M  3696  0 S     0.3 30.2   1:56 mysqld
11132 mysql     15   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
11127 mysql     15   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
11126 mysql     20   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
11968 mysql     15   0  610M 610M  3696  0 S     0.0 30.2   0:00 mysqld
11125 mysql     16   0  610M 610M  3696  0 R     0.3 30.2   2:33 mysqld
11123 mysql     15   0  610M 610M  3696  1 S     1.1 30.2   2:45 mysqld
11130 mysql     15   0  610M 610M  3696  0 S     0.0 30.2   0:00 mysqld
11969 mysql     15   0  610M 610M  3696  0 S     0.3 30.2   0:00 mysqld
11128 mysql     17   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
11129 mysql     15   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
11131 mysql     15   0  610M 610M  3696  1 S     0.0 30.2   0:00 mysqld
  385 root      15   0  2132 2132  1900  1 S     0.0  0.1   0:02 ntpd
11671 root      15   0  1344 1344  1104  0 S     0.0  0.0   0:00 sshd
11677 root      15   0  1308 1308   996  1 S     0.0  0.0   0:00 bash
11096 root      18   0   956  956   796  1 S     0.0  0.0   0:00 mysqld_safe
11726 root      16   0   940  940   712  1 R    12.1  0.0   0:01 top
 3298 root      15   0  1296  736   452  0 S     0.0  0.0  26:25 snmpd
  353 root      15   0   928  172   120  1 S     0.0  0.0   0:00 klogd
  343 root      15   0   204  156   112  1 S     0.0  0.0   0:03 syslogd

 

 

보시면 아시겠지만.. 좀 전 보다 mysqld의 메모리 사용량이 더 올라갔네요... 가용메모리는 더 줄었고요..

 

이런식으로 메모리가 계속 증가하다 어느 시점이 되면 12번 에러를 내면서 게시판이 안나오더라고요..

 

어쩔수 없이 mysql을 재기동 시키면 괜찮긴 하지만....

 

1. OS는 turbo linux 입니다.

2. mysql 계정에서의 ulimit -a의 결과는..

   core file size        (blocks, -c) 1000000
   data seg size         (kbytes, -d) unlimited
   file size             (blocks, -f) unlimited
   max locked memory     (kbytes, -l) unlimited
   max memory size       (kbytes, -m) unlimited
   open files                    (-n) 1024
   pipe size          (512 bytes, -p) 8
   stack size            (kbytes, -s) 8192
   cpu time             (seconds, -t) unlimited
   max user processes            (-u) 7168
   virtual memory        (kbytes, -v) unlimited

입니다..

 

3. mysql의 버전은 4.1.7입니다. 소스컴파일이고요..

 

그리고 로그를 보니 아까 12에러가 나면서

/usr/local/mysql/libexec/mysqld: Sort aborted

이 에러도 같이 기록되어 있네요... 소트하는데 메모리가 부족해서 일까요?

Rem님이 2006-01-03 21:09에 작성한 댓글입니다. Edit

>> 이 에러도 같이 기록되어 있네요... 소트하는데 메모리가 부족해서 일까요?

네에. 소트 하는데 메모리가 부족한 듯 보입니다.

(저의 추측이구요)

 

sort_buffer_size가 512k 밖에 안되네요.

램이 넉넉하시니 4MB로 올려보시는 건 어떨지요.

 

그리고, 12번 에러 나기 전까진 램이 계속 줄어들더라도 MySQL 데몬 껐다 키시지 마시구요.

 

4MB로 늘려보고 상황을 보도록 하죠.

 

그리고 램에 비해 key_buffer가 작으니 이것도 128MB 정도로 늘리셔도 될 듯 합니다.

 

저도 내공이 딸려서 여기까지 밖에 못 도와드릴 듯한데요.

각종 변수들 의미를 파악하셔서 부족한 것들은 늘려보시구요.

 

그리고 ulimit -a의 결과를 물어 봤던 건, ulimit -a의 결과 중 data seg size 때문이었습니다. 이게 작으면 아무리 버퍼 사이즈를 많이 줘도 실제 그 만큼을 사용하지 못하기 때문이죠.

(stack size가 지금 8MB인데 이것도 영향을 미칠지는 저도 잘 모르겠습니다.^^)

 

그럼 수고하시구요~ 전 수면 시간이 좀 부족해서 잠을 청해야 겠군요.

 

허정수(wertyu)님이 2006-01-03 21:36에 작성한 댓글입니다.

허정수님 정말 감사합니다.

sort_buffer_size를 늘려봐야 겠네요..

 

my.cnf 파일을 수정하면 되는 거겠죠?

 

헌데...^^;;;;;;

 

my.cnf 파일만 수정하면 적용이 되는 건가요?

 

mysql을 재기동 해야 하지 않나요?

 

잘 몰라서.....

Rem님이 2006-01-03 21:41에 작성한 댓글입니다. Edit

네에. 재가동하시면 됩니다~

허정수(wertyu)님이 2006-01-04 13:12에 작성한 댓글입니다.

여전히 메모리는 계속 올라가는군요....ㅠ.ㅠ

쿼리를 다시 수정해야 겠네요..

 

혹시 이처럼 메모리가 증가할 만한 잘못된 쿼리문의 예시가 있을까요?

Rem님이 2006-01-05 10:07에 작성한 댓글입니다. Edit

>> 여전히 메모리는 계속 올라가는군요

 

어느 선에선가 멈출 것입니다...

 

top의 결과에서 free+cached가 0이 되고, 스와핑이 일어날 때까지 기다려보세요.

 

아마 어느 선에선가 증가가 멈출 것입니다.

 

그리고 중요한 것은 12번 에러가 나느냐 안 나느냐이겠구요.

에러가 안나는 설정을 찾아야 겠죠.

허정수(wertyu)님이 2006-01-05 16:14에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
24931입출력 빈번한 테이블의 lock 문제 [1]
음냐
2006-01-04
2565
24929C API mysql_query() 에 대해...
오호~
2006-01-04
1443
24927MySQL 5.0 stored procedure 리턴형식 질문드립니다. [1]
한상길
2006-01-04
3129
24926mysqld의 메모리 증가... ㅠ.ㅠ [11]
Rem
2006-01-03
21802
24925INDEX 의 사용. [11]
jude
2006-01-03
5305
24924php상에서 쿼리문 사용할때 궁금한 점이 있습니다.
으노
2006-01-03
1039
24923mysql 설치시 발생하는 강제 종료현상...
백성기
2006-01-02
2066
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다