4 minute read

Mariadb Setting

https://mariadb.com/kb/en/library/innodb-system-variables/#innodb_log_file_size

[mysqld] port=16033 innodb_buffer_pool_size=8058993459 innodb_log_file_size = 1104857600 innodb_log_buffer_size = 8388608 innodb_thread_concurrency = 16 innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT innodb_write_io_threads = 4 innodb_read_io_threads = 4 transaction_isolation = READ-COMMITTED general_log=1 general_log_file=Cloud.log skip-name-resolve max_allowed_packet=512M

  1. innodb_buffer_pool_size ์„ค๋ช… : InnoDB ๋ฒ„ํผ ํ’€ ํฌ๊ธฐ (๋ฐ”์ดํŠธ)์ž…๋‹ˆ๋‹ค. ์ „์ฒด / ์ฃผ๋กœ XtraDB / InnoDB ํ…Œ์ด๋ธ”์ด์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„œ๋ฒ„์—์„œ ์กฐ์ •ํ•˜๋Š” ๊ธฐ๋ณธ ๊ฐ’์€ ์ด๋Ÿฌํ•œ ํ™˜๊ฒฝ์—์„œ ์ด ๋ฉ”๋ชจ๋ฆฌ์˜ 80 %๊นŒ์ง€ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 2GB ์ด์ƒ์œผ๋กœ ์„ค์ •ํ•˜๋ฉด innodb_buffer_pool_instances๋„ ์กฐ์ •ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ณ€์ˆ˜ ์„ค์ • ๋ฐ ๋™์ ์œผ๋กœ Innodb ๋ฒ„ํผ ํ’€ ํฌ๊ธฐ ์„ค์ •์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ XtraDB / InnoDB ๋ฒ„ํผ ํ’€์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. Commandline: โ€“innodb-buffer-pool-size=# Scope: Global Dynamic: Yes (>= MariaDB 10.2.2), No (<= MariaDB 10.2.1) Data Type: numeric Default Value: 134217728 (128MB) Range: 5242880 (5MB) to 9223372036854775807 (8192PB)

  2. innodb_buffer_pool_instances ์„ค๋ช… : innodb_buffer_pool_size๊ฐ€ 1GB ์ด์ƒ์œผ๋กœ ์„ค์ •๋œ ๊ฒฝ์šฐ innodb_buffer_pool_instances๋Š” InnoDB ๋ฒ„ํผ ํ’€์„์ด ์—ฌ๋Ÿฌ ์ธ์Šคํ„ด์Šค๋กœ ๋‚˜๋ˆ•๋‹ˆ๋‹ค. MariaDB 5.5์—์„œ๋Š” ๊ธฐ๋ณธ๊ฐ’์ด 1์ด์ง€๋งŒ ๋ฒ„ํผ ํ’€์ด ๊ธฐ๊ฐ€ ๋ฐ”์ดํŠธ ์ธ ๋Œ€๊ทœ๋ชจ ์‹œ์Šคํ…œ์˜ ๊ฒฝ์šฐ ๋งŽ์€ ์ธ์Šคํ„ด์Šค๊ฐ€ ๊ฒฝํ•ฉ ๋™์‹œ์„ฑ์„ ์ค„์ด๋Š” ๋ฐ ๋„์›€์ด๋ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ MariaDB 10์—์„œ 8์ž…๋‹ˆ๋‹ค (Windows 32 ๋น„ํŠธ๋Š” innodb_buffer_pool_size์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฑฐ ๋‚˜ MariaDB 10.2.2์—์„œ๋Š” innodb_buffer_pool_size <1GB ์ธ ๊ฒฝ์šฐ 1๋กœ ์„ค์ • ๋จ). ๊ฐ ์ธ์Šคํ„ด์Šค๋Š” ์ž์ฒด ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์ด ๋ฒ„ํผ ํ’€ ํฌ๊ธฐ์˜ ๋™์ผํ•œ ๋ถ€๋ถ„์„ ์ฐจ์ง€ํ•˜๋ฏ€๋กœ ์˜ˆ๋ฅผ ๋“ค์–ด innodb_buffer_pool_size๊ฐ€ 4GB์ด๊ณ  innodb_buffer_pool_instances๊ฐ€ 4๋กœ ์„ค์ •๋˜๋ฉด ๊ฐ ์ธ์Šคํ„ด์Šค๋Š” 1GB๊ฐ€๋ฉ๋‹ˆ๋‹ค. ๊ฐ ์ธ์Šคํ„ด์Šค์˜ ํฌ๊ธฐ๋Š” 1GB ์ด์ƒ์ด์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. Commandline: โ€“innodb-buffer-pool-instances=# Scope: Global Dynamic: No Data Type: numeric Default Value: <= MariaDB 10.0.3: 1 Default Value: >= MariaDB 10.0.4: 8, 1 (>= MariaDB 10.2.2 if innodb_buffer_pool_size < 1GB), or dependent on innodb_buffer_pool_size (Windows 32-bit) Introduced: MariaDB 5.5.20

  3. innodb_log_file_size ์„ค๋ช… : ๋กœ๊ทธ ๊ทธ๋ฃน์—์žˆ๋Š” ๊ฐ InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ ํŒŒ์ผ์˜ ํฌ๊ธฐ (๋ฐ”์ดํŠธ)์ž…๋‹ˆ๋‹ค. ๊ฒฐํ•ฉ ๋œ ํฌ๊ธฐ๋Š” MariaDB 10.0 ์ด์ „์—๋Š” 4GB๋ฅผ ์ดˆ๊ณผ ํ•  ์ˆ˜ ์—†์œผ๋ฉฐ MariaDB 10.0 ์ด์ƒ์—์„œ๋Š” 512GB๋ฅผ ์ดˆ๊ณผ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ’์ด ํด์ˆ˜๋ก ํ”Œ๋Ÿฌ์‹œ ๊ฒ€์‚ฌ ์  ํ™œ๋™์œผ๋กœ ์ธํ•œ ๋””์Šคํฌ I / O๊ฐ€ ์ค„์–ด๋“ค์ง€ ๋งŒ ์ถฉ๋Œ๋กœ ์ธํ•œ ๋ณต๊ตฌ ์†๋„๊ฐ€ ๋Š๋ ค์ง‘๋‹ˆ๋‹ค. Commandline: โ€“innodb-log-file-size=# Scope: Global Dynamic: No Data Type: numeric Default Value: 50331648 (48MB) (from MariaDB 10.0), 5242880 (5MB) (before MariaDB 10.0) Range: 1048576 to 512GB (1MB to 512GB) (>= MariaDB 10.0), 1048576 to 4294967295 (1MB to 4096MB) (<= MariaDB 5.5),

  4. innodb_log_buffer_size ์„ค๋ช… : InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ ํŒŒ์ผ์„ ๋””์Šคํฌ์— ๊ธฐ๋กํ•˜๊ธฐ์œ„ํ•œ ๋ฒ„ํผ ํฌ๊ธฐ (๋ฐ”์ดํŠธ)์ž…๋‹ˆ๋‹ค. ์ด๋ฅผ ๋Š˜๋ฆฌ๋ฉด ์ปค๋ฐ‹ํ•˜๊ธฐ ์ „์— ๋””์Šคํฌ I / O๋ฅผ ์ˆ˜ํ–‰ ํ•  ํ•„์š”์—†์ด ๋” ํฐ ํŠธ๋žœ์žญ์…˜์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Commandline: โ€“innodb-log-buffer-size=# Scope: Global Dynamic: No Data Type: numeric Default Value: 16777216 (16MB) >= MariaDB 10.1.9, 8388608 (8MB) <= MariaDB 10.1.8 Range: 262144 to 4294967295 (256KB to 4096MB)

  5. innodb_thread_concurrency ์„ค๋ช… :์ด ์Šค๋ ˆ๋“œ ์ˆ˜์— ๋„๋‹ฌํ•˜๋ฉด (์ž ๊ธˆ ๋Œ€๊ธฐ์ค‘์ธ ์Šค๋ ˆ๋“œ ์ œ์™ธ) XtraDB / InnoDB๋Š” ์‹คํ–‰์ค‘์ธ ์Šค๋ ˆ๋“œ ์ˆ˜๋ฅผ ์ œํ•œํ•˜๊ธฐ ์œ„ํ•ด ์ƒˆ ์Šค๋ ˆ๋“œ๋ฅผ ์‹คํ–‰์„์œ„ํ•œ ์„ ์ž… ์„ ์ถœ ํ์— ๋Œ€๊ธฐ ์ƒํƒœ๋กœ ๋‘ก๋‹ˆ๋‹ค. ๋™์‹œ์—. ๊ธฐ๋ณธ๊ฐ’ ์ธ 0์„ ์„ค์ •ํ•˜๋ฉด ํ•„์š”ํ•œ๋งŒํผ ๋งŽ์€ ์Šค๋ ˆ๋“œ๊ฐ€ ํ—ˆ์šฉ๋ฉ๋‹ˆ๋‹ค. ๊ถŒ์žฅ ์„ค์ •์€ CPU ์ˆ˜์— 2๋ฅผ ๋”ํ•œ ๋””์Šคํฌ ์ˆ˜์ž…๋‹ˆ๋‹ค. Commandline: โ€“innodb-thread-concurrency=# Scope: Global Dynamic: Yes Data Type: numeric Default Value: 0 Range: 0 to 1000

  6. innodb_flush_log_at_trx_commit ์„ค๋ช… : ๊ฐ€์žฅ ๋†’์€ ์ˆ˜์ค€์˜ ๋‚ด๊ฒฐํ•จ์„ฑ์„ ์œ„ํ•ด sync_binlog = 1๊ณผ ํ•จ๊ป˜ 1๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. innodb_use_global_flush_log_at_trx_commit์˜ ๊ฐ’์€์ด ๋ณ€์ˆ˜๋ฅผ SET ๋ฌธ์œผ๋กœ ์žฌ์„ค์ • ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค. 1 ๊ธฐ๋ณธ์ ์œผ๋กœ ๋กœ๊ทธ ๋ฒ„ํผ๋Š” InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ ํŒŒ์ผ์— ๊ธฐ๋ก๋˜๊ณ  ๊ฐ ํŠธ๋žœ์žญ์…˜ ํ›„์— ๋””์Šคํฌ๋กœ ํ”Œ๋Ÿฌ์‹œ๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ์™„์ „ํ•œ ACID ์ค€์ˆ˜๋ฅผ ์œ„ํ•ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. 0 ์ปค๋ฐ‹์‹œ ์ˆ˜ํ–‰๋˜๋Š” ์ž‘์—…์ด ์—†์Šต๋‹ˆ๋‹ค. ์˜คํžˆ๋ ค ๋กœ๊ทธ ๋ฒ„ํผ๋Š” 1 ์ดˆ์— ํ•œ ๋ฒˆ์”ฉ InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ์— ๊ธฐ๋ก๋˜๊ณ  ํ”Œ๋Ÿฌ์‹œ๋ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์„ฑ๋Šฅ์€ ํ–ฅ์ƒ๋˜์ง€๋งŒ ์„œ๋ฒ„ ์ถฉ๋Œ๋กœ ์ธํ•ด ๋งˆ์ง€๋ง‰ ํŠธ๋žœ์žญ์…˜์ด ์ง€์›Œ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 2 ๊ฐ ์ปค๋ฐ‹ ํ›„์— ๋กœ๊ทธ ๋ฒ„ํผ๊ฐ€ InnoDB ๋ฆฌ๋‘ ๋กœ๊ทธ์— ๊ธฐ๋ก๋˜์ง€๋งŒ ํ”Œ๋Ÿฌ์‹ฑ์€ 1 ์ดˆ์— ํ•œ ๋ฒˆ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์„ฑ๋Šฅ์€ ์•ฝ๊ฐ„ ๋‚˜์•„์ง€์ง€๋งŒ OS ๋˜๋Š” ์ •์ „์œผ๋กœ ์ธํ•ด ๋งˆ์ง€๋ง‰ ์ดˆ์˜ ํŠธ๋žœ์žญ์…˜์ด ์†์‹ค ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 3 (MariaDB 10.0์—์„œ) MariaDB 5.5 ๊ทธ๋ฃน ์ปค๋ฐ‹ (๊ทธ๋ฃน ์ปค๋ฐ‹ ๋‹น 3 ๊ฐœ์˜ ๋™๊ธฐํ™”)์„ ์—๋ฎฌ๋ ˆ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. Binlog ๊ทธ๋ฃน ์ปค๋ฐ‹ ๋ฐ innodb_flush_log_at_trx_commit์„ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค. Commandline: โ€“innodb-flush-log-at-trx-commit[=#] Scope: Global Dynamic: Yes Data Type: enumeration Default Value: 1 Valid Values: 0, 1, 2 or 3 (from MariaDB 10.0)

  7. innodb_flush_method ์„ค๋ช… : XtraDB / InnoDB ํ”Œ๋Ÿฌ์‹ฑ ๋ฐฉ๋ฒ•. Windows๋Š” ํ•ญ์ƒ async_unbuffered๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ์ด ๋ณ€์ˆ˜๋Š” ์ ์šฉ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์œ ๋‹‰์Šค์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ fsync ()๊ฐ€ ๋ฐ์ดํ„ฐ์™€ ๋กœ๊ทธ๋ฅผ ํ”Œ๋Ÿฌ์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ด ๋ณ€์ˆ˜๋ฅผ ์กฐ์ •ํ•˜๋ฉด ์„ฑ๋Šฅ์ด ํ–ฅ์ƒ ๋  ์ˆ˜ ์žˆ์ง€๋งŒ ํŒŒ์ผ ์‹œ์Šคํ…œ๋งˆ๋‹ค ๋™์ž‘์ด ํฌ๊ฒŒ ๋‹ค๋ฅด๋ฉฐ ์ผ๋ถ€ ์ƒํ™ฉ์—์„œ๋Š” ๊ธฐ๋ณธ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฏ€๋กœ ์กฐ์ •ํ•˜๊ธฐ ์ „์— ํ…Œ์ŠคํŠธํ•˜๊ณ  ๋ฒค์น˜๋งˆํ‚นํ•˜์‹ญ์‹œ์˜ค. MariaDB์—์„œ Windows๋Š” Unix ๋ฉ”์†Œ๋“œ๋ฅผ ์ธ์‹ํ•˜๊ณ  ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ•˜์ง€๋งŒ, ์•„๋ฌด๊ฒƒ๋„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๋ชจ๋“  ํŒŒ์ผ์— ๋Œ€ํ•ด ์ž์ฒด ๊ธฐ๋ณธ ๋ฒ„ํผ๋ง๋˜์ง€ ์•Š์€ ์“ฐ๊ธฐ (O_DIRECT์˜ ์•„๋‚ ๋กœ๊ทธ) + ๋™๊ธฐํ™” (์˜ˆ : FileFlushBuffers ())๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. O_DSYNC-O_DSYNC๋Š” ๋กœ๊ทธ๋ฅผ ์—ด๊ณ  ํ”Œ๋Ÿฌ์‹œํ•˜๊ณ  fsync ()๋Š” ๋ฐ์ดํ„ฐ ํŒŒ์ผ์„ ํ”Œ๋Ÿฌ์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. O_DIRECT-O_DIRECT ๋˜๋Š” directio ()๋Š” ๋ฐ์ดํ„ฐ ํŒŒ์ผ์„ ์—ฌ๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๊ณ  fsync ()๋Š” ๋ฐ์ดํ„ฐ์™€ ๋กœ๊ทธ๋ฅผ ํ”Œ๋Ÿฌ์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. fsync-์œ ๋‹‰์Šค ๊ธฐ๋ณธ๊ฐ’. ์ง์ ‘ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ Unix์—์„œ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ fsync ()๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. O_DIRECT_NO_FSYNC-MariaDB 10.0์—์„œ ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. I / O๋ฅผ ๋น„์šฐ๋Š” ๋™์•ˆ O_DIRECT๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋งŒ ๋‚˜์ค‘์— fsync ()๋ฅผ ๊ฑด๋„ˆ ๋œ๋‹ˆ๋‹ค. XFS ํŒŒ์ผ ์‹œ์Šคํ…œ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ALL_O_DIRECT-MariaDB 5.5์— ๋„์ž…๋˜์—ˆ์œผ๋ฉฐ XtraDB์—์„œ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ์™€ ๋กœ๊ทธ๋ฅผ ๋ชจ๋‘ ์—ฌ๋Š” ๋ฐ O_DIRECT๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๋ฐ์ดํ„ฐ๋Š” ํ”Œ๋Ÿฌ์‹œํ•˜์ง€๋งŒ fsync ()๋Š” ๋กœ๊ทธ๋ฅผ ํ”Œ๋Ÿฌ์‹œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํฐ InnoDB ํŒŒ์ผ ๋งŒ ์‚ฌ์šฉํ•˜๋ฉด ์„ฑ๋Šฅ์ด ์ €ํ•˜ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ext4 ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ innodb_log_block_size๋ฅผ 4096์œผ๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค. ์ด๊ฒƒ์€ ext4์˜ ๊ธฐ๋ณธ ๋กœ๊ทธ ๋ธ”๋ก ํฌ๊ธฐ์ด๋ฉฐ ์ •๋ ฌ๋˜์ง€ ์•Š์€ AIO / DIO ๊ฒฝ๊ณ ๋ฅผ ํ”ผํ•ฉ๋‹ˆ๋‹ค. ๋ฒ„ํผ๋ง๋˜์ง€ ์•Š์Œ-Windows ์ „์šฉ ๊ธฐ๋ณธ๊ฐ’ async_unbuffered-Windows ์ „์šฉ, ๋ฒ„ํผ๋ง๋˜์ง€ ์•Š์€ ๋ณ„๋ช… normal-Windows ์ „์šฉ, fsync์˜ ๋ณ„๋ช… Commandline: โ€“innodb-flush-method=name Scope: Global Dynamic: No Data Type: enumeration (>= MariaDB 10.3.7), string (<= MariaDB 10.3.6) Default Value: fsync (>= MariaDB 10.3.7) Not set (<= MariaDB 10.3.6) Valid Values: Unix: fsync, O_DSYNC, O_DIRECT, O_DIRECT_NO_FSYNC (>=MariaDB 10.0), ALL_O_DIRECT (>= MariaDB 5.5 to <= MariaDB 10.1, XtraDB only) Windows: unbuffered, async_unbuffered, normal

  8. innodb_write_io_threads ์„ค๋ช… : XtraDB / InnoDB ์“ฐ๊ธฐ๋ฅผ์œ„ํ•œ I / O ์Šค๋ ˆ๋“œ ์ˆ˜. ๋“œ๋ฌผ์ง€๋งŒ ์‹œ์Šคํ…œ ํ•œ๊ณ„๋ฅผ ์ดˆ๊ณผํ•˜์ง€ ์•Š๋„๋ก ์—ฌ๋Ÿฌ MariaDB ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•˜๋Š” Linux ์‹œ์Šคํ…œ์—์„œ์ด ๊ธฐ๋ณธ๊ฐ’์„ ์ค„์—ฌ์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. Commandline: โ€“innodb-write-io-threads=# Scope: Global Dynamic: No Data Type: numeric Default Value: 4 Range: 1 to 64