# get memory_limit set , get MemTotal if memory_limit is not set.
memory_total=$(awk '/MemTotal:/ {printf("%d", $2/1024)}' /proc/meminfo)
if [[ -f /sys/fs/cgroup/memory/memory.stat ]];then
memory_limit_stat=$(awk '/hierarchical_memory_limit/ {printf("%d", $2/1024/1024)}' /sys/fs/cgroup/memory/memory.stat)
fi
if [[ $memory_total -gt $memory_limit_stat ]];then
export memory_limit=$memory_limit_stat
else
export memory_limit=$memory_total
fi
# innodb_buffer_pool_size
export my_innodb_buffer_pool_size="$(echo $memory_limit | awk '{printf("%d", $0*0.5)}')M"
# innodb_log_file_size
innodb_log_file_size=`echo $my_innodb_buffer_pool_size | awk '{printf("%d", $0*0.2)}'`
if [ $innodb_log_file_size -lt 64 ]; then
innodb_log_file_size="64"
elif [ $innodb_log_file_size -gt 2048 ]; then
innodb_log_file_size="2048"
fi
export my_innodb_log_file_size=${innodb_log_file_size}M
# max_connections
max_connections=`echo $my_innodb_buffer_pool_size | awk '{printf("%d", $0/10)}'`
if [ $max_connections -lt 500 ]; then
max_connections="500"
elif [ $max_connections -gt 16000 ]; then
max_connections="16000"
fi
version: "3.8"
# networks:
# net:
volumes:
data:
services:
mariadb-galera:
image: zctmdc/mariadb-galera
container_name: mariadb-galera
environment:
- cluster_name=mariadb-galera
- my_port=3306
- node1=10.147.18.124
- node2=10.147.18.115
- mysql_root_password=QIK68xzBoNc7yiaam1Ah
- mysql_user=drone
- mysql_user_password=HFDzxM3OfeoZHJT
- mysql_user_database=drone
- interface=zt7nnhlcnn
# - local_addr=10.147.18.124
volumes:
- ./data:/data/mariadb-galera
network_mode: host
# networks:
# net:
# ports:
# - 10.147.18.124:3306:3306
# - 10.147.18.124:4567:4567
# - 10.147.18.124:4568:4568
restart: unless-stopped
# docker compose up
[+] Running 1/1
⠿ Container mariadb-galera Created 0.5s
Attaching to mariadb-galera
mariadb-galera | ==================================== Auto-join Galera Cluster =======================================
mariadb-galera | >> Can't found any activated node, It's maybe the first one, just start without join_address.
mariadb-galera | ==================================== Initialization Infomation =======================================
mariadb-galera | cluster_name: mariadb-galera
mariadb-galera | current_node: 10.147.18.124:3306
mariadb-galera | cluster_members: 10.147.18.124:3306,10.147.18.115:3306
mariadb-galera |
mariadb-galera | >> Start initialize configuration (Touch the file /data/mariadb-galera/lock/global.lock can skiped).
mariadb-galera | set pid_file=/data/mariadb-galera/lock/mysqld.pid
mariadb-galera | set max_connections=500
mariadb-galera | set log_error=/data/mariadb-galera/logs/error.log
mariadb-galera | set port=3306
mariadb-galera | set innodb_buffer_pool_size=0M
mariadb-galera | set slow_query_log_file=/data/mariadb-galera/logs/slow.log
mariadb-galera | set datadir=/data/mariadb-galera/data
mariadb-galera | set innodb_log_file_size=64M
mariadb-galera | set report_host=10.147.18.124:3306
mariadb-galera | set server_id=18124
mariadb-galera | =================================== MySQL Daemon Runing Infomation ===================================
mariadb-galera | >> initializing database
mariadb-galera |
mariadb-galera | Installation of system tables failed! Examine the logs in
mariadb-galera | /data/mariadb-galera/data for more information.
mariadb-galera |
mariadb-galera | The problem could be conflicting information in an external
mariadb-galera | my.cnf files. You can ignore these by doing:
mariadb-galera |
mariadb-galera | shell> /usr/bin/mysql_install_db --defaults-file=~/.my.cnf
mariadb-galera |
mariadb-galera | You can also try to start the mysqld daemon with:
mariadb-galera |
mariadb-galera | shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
mariadb-galera |
mariadb-galera | and use the command line tool /usr/bin/mariadb
mariadb-galera | to connect to the mysql database and look at the grant tables:
mariadb-galera |
mariadb-galera | shell> /usr/bin/mysql -u root mysql
mariadb-galera | mysql> show tables;
mariadb-galera |
mariadb-galera | Try 'mysqld --help' if you have problems with paths. Using
mariadb-galera | --general-log gives you a log in /data/mariadb-galera/data that may be helpful.
mariadb-galera |
mariadb-galera | The latest information about mysql_install_db is available at
mariadb-galera | https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
mariadb-galera | You can find the latest source at https://downloads.mariadb.org and
mariadb-galera | the maria-discuss email list at https://launchpad.net/~maria-discuss
mariadb-galera |
mariadb-galera | Please check all of the above before submitting a bug report
mariadb-galera | at https://mariadb.org/jira
mariadb-galera |
mariadb-galera | >> database initialized
mariadb-galera | >> Found the galera configuration, waiting for mysql really start
mariadb-galera | >> mysql init process in progress...
mariadb-galera | 2022-12-16 2:00:14 0 [Note] mysqld (server 10.10.2-MariaDB-log) starting as process 180 ...
mariadb-galera | /docker-entrypoint.sh: line 114: 180 Aborted mysqld --skip-networking --user=mysql --socket="/tmp/mysql.sock"
mariadb-galera | >> mysql init process in progress...
mariadb-galera | >> mysql init process in progress...
mariadb-galera | >> mysql init process in progress...
......
2022-12-16 2:00:14 0 [ERROR] InnoDB: innodb_page_size=16384 requires innodb_buffer_pool_size >= 5MiB current 2MiB
2022-12-16 2:00:14 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-12-16 2:00:14 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-12-16 2:00:14 0 [Warning] 'innodb-locks-unsafe-for-binlog' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
2022-12-16 2:00:14 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2022-12-16 2:00:14 0 [ERROR] Aborting
2022-12-16 2:00:14 0 [Note] WSREP: Loading provider /usr/lib64/galera-4/libgalera_smm.so initial position: 00000000-0000-0000-0000-000000000000:-1
2022-12-16 2:00:14 0 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib64/galera-4/libgalera_smm.so'
2022-12-16 2:00:14 0 [Note] WSREP: wsrep_load(): Galera 26.4.13(rfe497ae) by Codership Oy <[email protected]> loaded successfully.
2022-12-16 2:00:14 0 [Note] WSREP: Initializing allowlist service v1
2022-12-16 2:00:14 0 [Note] WSREP: CRC-32C: using 64-bit x86 acceleration.
2022-12-16 2:00:14 0 [Warning] WSREP: Could not open state file for reading: '/data/mariadb-galera/data//grastate.dat'
2022-12-16 2:00:14 0 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1, safe_to_bootstrap: 1
2022-12-16 2:00:14 0 [Note] WSREP: GCache DEBUG: opened preamble:
Version: 0
UUID: 00000000-0000-0000-0000-000000000000
Seqno: -1 - -1
Offset: -1
Synced: 0
......
=================================================
2022-12-16 2:00:14 1 [Note] WSREP: Server status change connected -> joiner
2022-12-16 2:00:14 1 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2022-12-16 2:00:14 1 [Note] WSREP: Server status change joiner -> initializing
2022-12-16 2:00:14 1 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2022-12-16 2:00:14 0 [Warning] option 'innodb-buffer-pool-size': unsigned value 0 adjusted to 2097152
2022-12-16 2:00:14 0 [ERROR] InnoDB: innodb_page_size=16384 requires innodb_buffer_pool_size >= 5MiB current 2MiB
2022-12-16 2:00:14 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-12-16 2:00:14 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-12-16 2:00:14 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-12-16 2:00:14 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
2022-12-16 2:00:14 0 [Warning] 'innodb-locks-unsafe-for-binlog' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
2022-12-16 2:00:14 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2022-12-16 2:00:14 0 [ERROR] Aborting
2022-12-16 2:00:14 1 [ERROR] WSREP: Exception: State wait was interrupted
2022-12-16 2:00:14 1 [ERROR] WSREP: View callback failed. This is unrecoverable, restart required. (FATAL)
at /home/buildbot/buildbot/build/galera/src/replicator_smm.cpp:submit_view_info():2442
################ innodb configuration ################
default_storage_engine = InnoDB
sync_binlog=0
innodb_flush_log_at_trx_commit = 0
innodb_file_per_table = 1
# 问题估计出现在这里
innodb_buffer_pool_size=0M
innodb_lock_wait_timeout = 50
innodb_doublewrite=1
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
innodb_strict_mode=0
innodb_log_file_size=64M
innodb_log_buffer_size = 16M
innodb_flush_method='O_DIRECT'
#innodb_read_io_threads = 8
#innodb_write_io_threads = 8
[[email protected]:/data/docker-build/common/mariadb-galera-10.3.12]# cat etc/server.cnf.sample
[client]
port=3306
default_character_set = utf8
socket = /var/lib/mysql/mysql.sock
[mysqld_safe]
open_files_limit=655350
[mysqld]
server_id=18124
bind_address = 0.0.0.0
port=3306
skip_name_resolve=1
character_set_server = utf8
datadir=/data/mariadb-galera/data
tmpdir=/data/mariadb-galera/logs/tmpdir
pid_file=/data/mariadb-galera/lock/mysqld.pid
################ log configuration ################
log_bin=mysql-bin
binlog_format=row
log_slave_updates=1
expire_logs_days=7
slow_query_log=1
long_query_time=3
log_queries_not_using_indexes=0
log_error=/data/mariadb-galera/logs/error.log
slow_query_log_file=/data/mariadb-galera/logs/slow.log
binlog_row_image='MINIMAL'
################ innodb configuration ################
default_storage_engine = InnoDB
sync_binlog=0
innodb_flush_log_at_trx_commit = 0
innodb_file_per_table = 1
innodb_buffer_pool_size=0M
innodb_lock_wait_timeout = 50
innodb_doublewrite=1
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
innodb_strict_mode=0
innodb_log_file_size=64M
innodb_log_buffer_size = 16M
innodb_flush_method='O_DIRECT'
#innodb_read_io_threads = 8
#innodb_write_io_threads = 8
################ sql_Mode configuration ################
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sql_mode=""
slave_exec_mode=IDEMPOTENT
################ common configuration ################
query_cache_type=0
query_cache_size=0
query_cache_limit=0
max_allowed_packet = 512M
max_connections=500
max_connect_errors=999999999
tmp_table_size=128M
max_heap_table_size=128M
table_open_cache = 2000
key_buffer_size = 8M
read_buffer_size = 1M
sort_buffer_size = 1M
read_rnd_buffer_size = 4M
net_buffer_length = 512K
group_concat_max_len = 4096000
interactive_timeout = 28800
wait_timeout = 28800
report_host=10.147.18.124:3306