powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / MySQL [игнор отключен] [закрыт для гостей] / Поможет ли репликация?
13 сообщений из 13, страница 1 из 1
Поможет ли репликация?
    #40053236
morgot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Есть сайт, PHP+MySQL, некоторая CMS. База занимает около 4гиг и растет. Видимо, цмс не рассчитана на такие объёмы или что, короче периодически mysql "падает", я перезапускаю вручную через
Код: html
1.
systemctl restart mysql

. Но как бы не вариант, потому подскажите:

1. Нужно ли после такого рестарта делать repair table или подобное?
2. Как понять, почему оно вообще падает ?
3. Поможет ли репликация , потому как базу смотрели админы, и вроде как там настройки норм (в плане, не по дефолту взял и указал). Версию не знаю, вроде там даже MariaDB , а может и нет (если важно, уточню).
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40053252
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot
Нужно ли после такого рестарта делать repair table или подобное?
Зависит от движка таблиц.
Если InnoDB, то скорее нет.

morgot
Как понять, почему оно вообще падает ?
Смотреть в логи MySQL. В системные логи ОС тоже неплохо бы посмотреть.

morgot
Поможет ли репликация , потому как базу смотрели админы, и вроде как там настройки норм (в плане, не по дефолту взял и указал). Версию не знаю, вроде там даже MariaDB , а может и нет (если важно, уточню).
А как она в принципе может помочь? Используемая CMS умеет автоматически переключаться на реплику при падении основной БД?

Замечу, что 4 ГБ - довольно небольшой объем и падать из-за него MySQL не должна.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40053253
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot
Версию не знаю, вроде там даже MariaDB , а может и нет (если важно, уточню).
Желательно.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40053852
morgot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
miksoft,
пишет " 5.5.5-10.2.34-MariaDB"

вроде как MySQL "съел" всю память и OOMkiller его убил. База 4 гига, но всей оперативки там также 4.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40053858
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot
MySQL "съел" всю память
Это не от базы зависит, а от настроек MySQL.
Показывайте конфиг-файл.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059229
morgot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
miksoft
Показывайте конфиг-файл.

прошу прощения за задержку с ответом. Вот файл /etc/my.cnf - вроде он нужен?

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

skip-external-locking
key_buffer_size = 16K
max_allowed_packet      = 512M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
innodb_file_format = Barracuda
innodb_flush_log_at_trx_commit=2
innodb_flush_method = O_DIRECT
innodb_strict_mode = OFF
key_buffer              = 16M
thread_stack            = 192K
thread_cache_size       = 8
query_cache_limit       = 8M
query_cache_size        = 64M
max_heap_table_size     = 256M
tmp_table_size          = 128M

#innodb_use_native_aio = 0
innodb_file_per_table = 1

max_connections=100
max_user_connections=100
wait_timeout=60
interactive_timeout=50
long_query_time=5

#slow_query_log=1
#slow_query_log_file=/var/log/mysql-slow-queries.log

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059242
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot,

Не вижу параметры innodb_buffer_pool_size и innodb-flush-log-at-trx-commit от них сильно зависит быстродействие MySQL.

Но в целом не вижу что тут может занять 4 ГБ.


morgot
Код: xml
1.
2.
3.
# include all files from the config directory
#
!includedir /etc/my.cnf.d

Тут ничего нет?
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059244
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059338
morgot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
miksoft, вот еще есть папка my.cnf.d , там 4 файла

Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
[mysqld]

### Some Settings ###

pid-file = /tmp/mysqld.pid
skip-name-resolve = 1
#max_heap_table_size = 768M
#tmp_table_size = 768M

### Caches ###

query_cache_size = 0
query_cache_type = 0
table_open_cache = 1024

### Buffers ###

key_buffer_size = 500M
join_buffer_size = 1M
#sort_buffer_size = 1M
#read_rnd_buffer_size = 1M
#read_buffer_size = 2M
#bulk_insert_buffer_size = 32M
#myisam_sort_buffer_size = 32M

### Slow logs ###

#slow_query_log = 1
#slow_query_log_file = /var/log/mysql/slow.log
#long_query_time = 10
#log_queries_not_using_indexes = 0

### InnoDB ###

innodb_buffer_pool_size = 4000M
innodb_log_file_size = 512M
innodb_buffer_pool_instances = 4

[isamchk]
key_buffer = 1G
sort_buffer_size = 64M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 1G
sort_buffer_size = 64M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout



и еще три не особо важные, наверное (там какие-то настройки шифрования).
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059341
morgot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
miksoft,

Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
# perl mysqltuner.pl
 >>  MySQLTuner 1.7.24 - Major Hayden <major@mhtx.net>;
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.pl/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: [OK] Currently running supported MySQL version 10.2.34-MariaDB
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mariadb/mariadb.log exists
[--] Log file: /var/log/mariadb/mariadb.log(33M)
[OK] Log file /var/log/mariadb/mariadb.log is not empty
[!!] Log file /var/log/mariadb/mariadb.log is bigger than 32 Mb
[OK] Log file /var/log/mariadb/mariadb.log is readable.
[!!] /var/log/mariadb/mariadb.log contains 14864 warning(s).
[!!] /var/log/mariadb/mariadb.log contains 11523 error(s).
[--] 0 start(s) detected in /var/log/mariadb/mariadb.log
[--] 0 shutdown(s) detected in /var/log/mariadb/mariadb.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in InnoDB tables: 7.4G (Tables: 78)
[--] Data in MEMORY tables: 8.1M (Tables: 2)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User ''admin_main'@%' does not specify hostname restrictions.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 20d 16h 34m 24s (188M q [105.393 qps], 11M conn, TX: 584G, RX: 46G)
[--] Reads / Writes: 73% / 27%
[--] Binary logging is disabled
[--] Physical Memory     : 9.9G
[--] Max MySQL memory    : 54.9G
[--] Other process memory: 0B
[--] Total buffers: 4.8G global + 513.8M per thread (100 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 55.4G (559.63% of installed RAM)
[!!] Maximum possible memory usage: 54.9G (554.56% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (2K/188M)
[!!] Highest connection usage: 100%  (101/100)
[OK] Aborted connections: 0.17%  (20358/11874592)
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (9K temp sorts / 2M sorts)
[!!] Joins performed without indexes: 4300995
[OK] Temporary tables created on disk: 1% (10K on disk / 864K total)
[OK] Thread cache hit rate: 99% (4K created / 11M connections)
[!!] Table cache hit rate: 0% (553 open / 88K opened)
[OK] table_definition_cache(400) is upper than number of tables(238)
[OK] Open file limit used: 0% (35/16K)
[OK] Table locks acquired immediately: 99% (11M immediate / 11M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 4 thread(s).
[--] Using default value is good enough for your version (10.2.34-MariaDB)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (95M used / 524M cache)
[OK] Key buffer size / total MyISAM indexes: 500.0M/121.0K

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 4.0G/7.4G
[OK] Ratio InnoDB log file size / InnoDB Buffer pool size: 512.0M * 2/4.0G should be equal to 25%
[OK] InnoDB buffer pool instances: 4
[--] Number of InnoDB Buffer Pool Chunk : 32 for 4 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (107426645659 hits/ 107429115943 total)
[!!] InnoDB Write Log efficiency: 56.67% (32086765 hits/ 56624702 total)
[OK] InnoDB log waits: 0.00% (0 waits / 24537937 writes)

-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/0B
[OK] Aria pagecache hit rate: 99.9% (11M cached / 9K reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    /var/log/mariadb/mariadb.log is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!
    Control warning line(s) into /var/log/mariadb/mariadb.log file
    Control error line(s) into /var/log/mariadb/mariadb.log file
    Restrict Host for 'admin_main'@% to 'admin_main'@LimitedIPRangeOrLocalhost
    RENAME USER 'admin_main'@'%' TO 'admin_main'@LimitedIPRangeOrLocalhost;
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Reduce or eliminate persistent connections to reduce connection usage
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    Increase table_open_cache gradually to avoid file descriptor limits
    Read this before increasing table_open_cache over 64: https://bit.ly/2Fulv7r
    Read this before increasing for MariaDB https://mariadb.com/kb/en/library/optimizing-table_open_cache/
    This is MyISAM only table_cache scalability problem, InnoDB not affected.
    See more details here: https://bugs.mysql.com/bug.php?id=49177
    This bug already fixed in MySQL 5.7.9 and newer MySQL versions.
    Beware that open_files_limit (16519) variable
    should be greater than table_open_cache (1024)
    Performance schema should be activated for better diagnostics
    Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
    Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    max_connections (> 100)
    wait_timeout (< 60)
    interactive_timeout (< 50)
    join_buffer_size (> 1.0M, or always use indexes with JOINs)
    table_open_cache (> 1024)
    performance_schema = ON enable PFS
    innodb_buffer_pool_size (>= 7.4G) if possible.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059347
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot
Код: sql
1.
2.
3.
key_buffer_size = 500M
...
innodb_buffer_pool_size = 4000M

morgot
Код: sql
1.
2.
3.
4.
[--] Physical Memory     : 9.9G
[--] Max MySQL memory    : 54.9G
[--] Other process memory: 0B
[--] Total buffers: 4.8G global + 513.8M per thread (100 max threads)

У вас всего 10 ГБ памяти ( а не 4, как был сказано изначально), но расход памяти на MySQL при текущих настройках может быть до 55 ГБ. Вот поэтому памяти и не хватает.

morgot
Код: sql
1.
[OK] Key buffer size / total MyISAM indexes: 500.0M/121.0K

key_buffer_size нет смысла ставить больше, чем суммарный размер индексов MyISAM таблиц с запасом в 10-20%.
morgot
Код: sql
1.
[!!] InnoDB buffer pool / data size: 4.0G/7.4G

Желательно, чтобы innodb_buffer_pool_size вмещал в себя все таблицы и индексы InnoDB, но сейчас это роскошь. Можно попробовать увеличить, если получится снизить расход памяти на каждый клиентский поток и если после этого устойчиво будет достаточно свободной памяти.
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059350
Фотография Alex_Ustinov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: sql
1.
innodb_buffer_pool_size (>= 7.4G) if possible.

увеличить innodb_buffer_pool_size > 7.4G если возможно,
а это возможно, допустим =6G
уменьшить max_connections=100 (допустим на 25% т.е. =75)

----
затем еще раз запустить тюнер
...
Рейтинг: 0 / 0
Поможет ли репликация?
    #40059351
miksoft
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
morgot
Код: sql
1.
513.8M per thread

Это много. Подумайте, как можно уменьшить.
Считается это так:
Код: sql
1.
2.
3.
4.
5.
6.
7.
        $mycalc{'per_thread_buffers'} =
          $myvar{'read_buffer_size'} +
          $myvar{'read_rnd_buffer_size'} +
          $myvar{'sort_buffer_size'} +
          $myvar{'thread_stack'} +
          $myvar{'max_allowed_packet'} +
          $myvar{'join_buffer_size'};


Из всего этого явно избыточен max_allowed_packet.
Хотя, насколько я в курсе, он не создается сразу на полный размер, а расширяется по мере необходимости.
Попробуйте его уменьшить до разумных значений.

innodb_buffer_pool_size попробуйте уменьшить до 1-2 ГБ, посмотрите как изменится быстройдествие и стабильность
...
Рейтинг: 0 / 0
13 сообщений из 13, страница 1 из 1
Форумы / MySQL [игнор отключен] [закрыт для гостей] / Поможет ли репликация?
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]