mysql 세팅값 어떤가요? 정보
mysql 세팅값 어떤가요?본문
서버 사양
E3 1280 v6
56GB ECC DDR4 RAM
512gb MLC NVME x 2 (RAID)
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4
# === Required Settings ===
basedir = /usr
bind_address = 127.0.0.1 # Change to 0.0.0.0 to allow remote connections
datadir = /var/lib/mysql
max_allowed_packet = 256M
max_connect_errors = 1000000
#pid_file = /var/run/mysqld/mysqld.pid
port = 3306
socket = /var/lib/mysql/mysql.sock
tmpdir = /tmp
#user = mysql
# === SQL Compatibility Mode ===
# Enable for b/c with databases created in older MySQL/MariaDB versions
# (e.g. when using null dates)
#sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES
# === InnoDB Settings ===
default_storage_engine = InnoDB
innodb_buffer_pool_instances = 20 # Use 1 instance per 1GB of InnoDB pool size
innodb_buffer_pool_size = 24G # Use up to 70-80% of RAM
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_stats_on_metadata = 0
innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:5G
#innodb_temp_data_file_path = ibtmp1:64M:autoextend:max:20G # Control the maximum size for the ibtmp1 file
#innodb_thread_concurrency = 4 # Optional: Set to the number of CPUs on your system (minus 1 or 2) to better
# contain CPU usage. E.g. if your system has 8 CPUs, try 6 or 7 and check
# the overall load produced by MySQL/MariaDB.
innodb_read_io_threads = 64
innodb_write_io_threads = 64
#innodb_io_capacity = 1000 # Max is 2000
# === MyISAM Settings ===
# The following 3 options are ONLY supported by MariaDB & up to MySQL 5.7
# Do NOT un-comment on MySQL 8.x+
#query_cache_limit = 4M # UPD
#query_cache_size = 64M # UPD
#query_cache_type = 1 # Enabled by default
key_buffer_size = 32M # UPD
low_priority_updates = 1
concurrent_insert = 2
# === Connection Settings ===
max_connections = 1024 # UPD - Important: high no. of connections = high RAM consumption
back_log = 512
thread_cache_size = 100
thread_stack = 192K
interactive_timeout = 180
wait_timeout = 180
# For MySQL 5.7+ only (disabled by default)
#max_execution_time = 30000 # Set a timeout limit for SELECT statements (value in milliseconds).
# This option may be useful to address aggressive crawling on large sites,
# but it can also cause issues (e.g. with backups). So use with extreme caution and test!
# More info at: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time
# For MariaDB 10.1.1+ only (disabled by default)
#max_statement_time = 30 # The equivalent of "max_execution_time" in MySQL 5.7+ (set above)
# The variable is of type double, thus you can use subsecond timeout.
# For example you can use value 0.01 for 10 milliseconds timeout.
# More info at: https://mariadb.com/kb/en/aborting-statements/
# === Buffer Settings ===
innodb_sort_buffer_size = 64M # UPD 2
join_buffer_size = 8M # UPD 4
read_buffer_size = 24M # UPD 3
read_rnd_buffer_size = 8M # UPD 4
sort_buffer_size = 64M # UPD 4
# === Table Settings ===
# In systemd managed systems like Ubuntu 16.04+ or CentOS 7+, you need to perform an extra action for table_open_cache & open_files_limit
# to be overriden (also see comment next to open_files_limit).
# E.g. for MySQL 5.7, please check: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
# and for MariaDB check: https://mariadb.com/kb/en/library/systemd/
#table_definition_cache = 40000 # UPD
#table_open_cache = 40000 # UPD
#open_files_limit = 60000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
# open files limit usually set in /etc/sysctl.conf or /etc/security/limits.conf
# In systemd managed systems this limit must also be set in:
# /etc/systemd/system/mysqld.service.d/override.conf (for MySQL 5.7+) and
# /etc/systemd/system/mariadb.service.d/override.conf (for MariaDB)
max_heap_table_size = 128M
tmp_table_size = 128M
# === Search Settings ===
ft_min_word_len = 3 # Minimum length of words to be indexed for search results
# === Logging ===
log_error = /var/log/mariadb/mysql-error.log
log_queries_not_using_indexes = 1
long_query_time = 5
slow_query_log = 0 # Disabled for production
slow_query_log_file = /var/log/mariadb/mysql-slow.log
# Don't listen on a TCP/IP port at all.
skip-networking
skip-name-resolve
skip-host-cache
skip-external-locking
[mysqldump]
# Variable reference
# For MySQL 5.7+: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html
# For MariaDB: https://mariadb.com/kb/en/library/mysqldump/
quick
quote_names
max_allowed_packet = 512M
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
추천
0
0
베스트댓글
innodb_sort_buffer_size = 64M # UPD 2
join_buffer_size = 8M # UPD 4
read_buffer_size = 24M # UPD 3
read_rnd_buffer_size = 8M # UPD 4
sort_buffer_size = 64M # UPD 4
이 값중에 session당 할당되는 메모리가 있을건데.... 이렇게 크게 잡으시면,,, 최대 사용 메모리가 늘어나서,,,, os가 kill 시킬수 있습니다.
최대 사용 메모리가 기본사용 메모리(innodb buffer pool size .....) + max_connection * (join_buffer_size + 그외 세션별로 할당되는 메모리)
암튼 저런 계산식이 있어요. 저걸 보고 설정하셔야 합니다.
보통 mysql connection 은 100 이하라서 문제가 없겠지만,,, 피크 시간대나 일시적으로 사이트가 느려지는 시점이 생기면,,, 메모리가 많이 필요해지게 되는데, 실제 메모리는 부족하니까 OOM(out of memory) killer 가
메모리를 가장 많이 쓰는 프로세스를 죽이게 됩니다.(아마 mysql 이겠죠..)
slow_query_log = 0 <-- 슬로우 로그는 항상 모니터링 해야 하니까 활성화 해두는게 좋음.
long_query_time = 5 <-- 2~3 초 정도가 적당함.. 사실 1초 이상 걸리는 쿼리는 다 모니터링 하는게 맞음.
빠진 설정중에
tx_isolation 은 변경하는게 좋음. 디폴트값이 성능이 별로임.
mysql_tunner.pl 돌려보시는거 추천..
join_buffer_size = 8M # UPD 4
read_buffer_size = 24M # UPD 3
read_rnd_buffer_size = 8M # UPD 4
sort_buffer_size = 64M # UPD 4
이 값중에 session당 할당되는 메모리가 있을건데.... 이렇게 크게 잡으시면,,, 최대 사용 메모리가 늘어나서,,,, os가 kill 시킬수 있습니다.
최대 사용 메모리가 기본사용 메모리(innodb buffer pool size .....) + max_connection * (join_buffer_size + 그외 세션별로 할당되는 메모리)
암튼 저런 계산식이 있어요. 저걸 보고 설정하셔야 합니다.
보통 mysql connection 은 100 이하라서 문제가 없겠지만,,, 피크 시간대나 일시적으로 사이트가 느려지는 시점이 생기면,,, 메모리가 많이 필요해지게 되는데, 실제 메모리는 부족하니까 OOM(out of memory) killer 가
메모리를 가장 많이 쓰는 프로세스를 죽이게 됩니다.(아마 mysql 이겠죠..)
slow_query_log = 0 <-- 슬로우 로그는 항상 모니터링 해야 하니까 활성화 해두는게 좋음.
long_query_time = 5 <-- 2~3 초 정도가 적당함.. 사실 1초 이상 걸리는 쿼리는 다 모니터링 하는게 맞음.
빠진 설정중에
tx_isolation 은 변경하는게 좋음. 디폴트값이 성능이 별로임.
mysql_tunner.pl 돌려보시는거 추천..
댓글 2개
innodb_sort_buffer_size = 64M # UPD 2
join_buffer_size = 8M # UPD 4
read_buffer_size = 24M # UPD 3
read_rnd_buffer_size = 8M # UPD 4
sort_buffer_size = 64M # UPD 4
이 값중에 session당 할당되는 메모리가 있을건데.... 이렇게 크게 잡으시면,,, 최대 사용 메모리가 늘어나서,,,, os가 kill 시킬수 있습니다.
최대 사용 메모리가 기본사용 메모리(innodb buffer pool size .....) + max_connection * (join_buffer_size + 그외 세션별로 할당되는 메모리)
암튼 저런 계산식이 있어요. 저걸 보고 설정하셔야 합니다.
보통 mysql connection 은 100 이하라서 문제가 없겠지만,,, 피크 시간대나 일시적으로 사이트가 느려지는 시점이 생기면,,, 메모리가 많이 필요해지게 되는데, 실제 메모리는 부족하니까 OOM(out of memory) killer 가
메모리를 가장 많이 쓰는 프로세스를 죽이게 됩니다.(아마 mysql 이겠죠..)
slow_query_log = 0 <-- 슬로우 로그는 항상 모니터링 해야 하니까 활성화 해두는게 좋음.
long_query_time = 5 <-- 2~3 초 정도가 적당함.. 사실 1초 이상 걸리는 쿼리는 다 모니터링 하는게 맞음.
빠진 설정중에
tx_isolation 은 변경하는게 좋음. 디폴트값이 성능이 별로임.
mysql_tunner.pl 돌려보시는거 추천..
join_buffer_size = 8M # UPD 4
read_buffer_size = 24M # UPD 3
read_rnd_buffer_size = 8M # UPD 4
sort_buffer_size = 64M # UPD 4
이 값중에 session당 할당되는 메모리가 있을건데.... 이렇게 크게 잡으시면,,, 최대 사용 메모리가 늘어나서,,,, os가 kill 시킬수 있습니다.
최대 사용 메모리가 기본사용 메모리(innodb buffer pool size .....) + max_connection * (join_buffer_size + 그외 세션별로 할당되는 메모리)
암튼 저런 계산식이 있어요. 저걸 보고 설정하셔야 합니다.
보통 mysql connection 은 100 이하라서 문제가 없겠지만,,, 피크 시간대나 일시적으로 사이트가 느려지는 시점이 생기면,,, 메모리가 많이 필요해지게 되는데, 실제 메모리는 부족하니까 OOM(out of memory) killer 가
메모리를 가장 많이 쓰는 프로세스를 죽이게 됩니다.(아마 mysql 이겠죠..)
slow_query_log = 0 <-- 슬로우 로그는 항상 모니터링 해야 하니까 활성화 해두는게 좋음.
long_query_time = 5 <-- 2~3 초 정도가 적당함.. 사실 1초 이상 걸리는 쿼리는 다 모니터링 하는게 맞음.
빠진 설정중에
tx_isolation 은 변경하는게 좋음. 디폴트값이 성능이 별로임.
mysql_tunner.pl 돌려보시는거 추천..
@솔그루 감사합니다. transaction_isolation=READ-COMMITTED 써야겠군요