# ONOX MariaDB Konfigürasyonu
# Bu dosya Ansible tarafından yönetilmektedir. Manuel düzenlemeyin.

[mysqld]
# --- Temel ---
server-id                  = {{ mariadb_server_id }}
bind-address               = 127.0.0.1
socket                     = /var/lib/mysql/mysql.sock
datadir                    = /var/lib/mysql

# --- Karakter seti ---
character-set-server       = utf8mb4
collation-server           = utf8mb4_unicode_ci

# --- InnoDB ---
innodb_buffer_pool_size    = {{ mariadb_innodb_buffer_pool_size }}
innodb_buffer_pool_instances = {% if server_ram_gb is defined and server_ram_gb | int >= 8 %}4{% else %}1{% endif %}

innodb_log_file_size       = 256M
innodb_flush_log_at_trx_commit = 1
innodb_flush_method        = O_DIRECT

# --- Bağlantılar ---
max_connections            = {{ mariadb_max_connections }}
wait_timeout               = 300
interactive_timeout        = 300

# --- Geçici tablolar ---
tmp_table_size             = {{ mariadb_tmp_table_size }}
max_heap_table_size        = {{ mariadb_max_heap_table_size }}

# --- Binary log (replikasyon) ---
{% if mariadb_replication_role == 'master' %}
log_bin                    = /var/lib/mysql/mysql-bin
binlog_format              = {{ mariadb_binlog_format }}
expire_logs_days           = {{ mariadb_binlog_expire_days }}
sync_binlog                = 1
{% endif %}

# --- Yavaş sorgu günlüğü ---
slow_query_log             = 1
slow_query_log_file        = /var/log/mysql/slow.log
long_query_time            = 2

# --- Güvenlik ---
local_infile               = 0
symbolic-links             = 0

[client]
default-character-set      = utf8mb4
socket                     = /var/lib/mysql/mysql.sock
