summaryrefslogtreecommitdiff
path: root/MariaDB
diff options
context:
space:
mode:
Diffstat (limited to 'MariaDB')
-rw-r--r--MariaDB/10.5.3/mariadb/hosts2
-rw-r--r--MariaDB/10.5.3/mariadb/install.yml7
-rw-r--r--MariaDB/10.5.3/mariadb/role/defaults/main.yml9
-rw-r--r--MariaDB/10.5.3/mariadb/role/files/pyMysql.zipbin0 -> 46172 bytes
-rw-r--r--MariaDB/10.5.3/mariadb/role/handlers/main.yml29
-rw-r--r--MariaDB/10.5.3/mariadb/role/tasks/deploy-cluster.yml153
-rw-r--r--MariaDB/10.5.3/mariadb/role/tasks/deploy-standalone.yml66
-rw-r--r--MariaDB/10.5.3/mariadb/role/tasks/main.yml11
-rw-r--r--MariaDB/10.5.3/mariadb/role/tasks/status-check.yml14
-rw-r--r--MariaDB/10.5.3/mariadb/role/tasks/uninstall.yml27
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/docker-compose.yml.j215
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/exporter_docker-compose.yml.j217
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/keepalived/check_mariadb.sh.j215
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/keepalived/keepalived-mariadb.conf.j248
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/keepalived/unload_balancer.sh.j218
-rw-r--r--MariaDB/10.5.3/mariadb/role/templates/my.cnf.j2198
-rw-r--r--MariaDB/10.5.3/mariadb/role/vars/main.yml9
17 files changed, 638 insertions, 0 deletions
diff --git a/MariaDB/10.5.3/mariadb/hosts b/MariaDB/10.5.3/mariadb/hosts
new file mode 100644
index 0000000..9ddfaf2
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/hosts
@@ -0,0 +1,2 @@
+[mariadb]
+192.168.45.102
diff --git a/MariaDB/10.5.3/mariadb/install.yml b/MariaDB/10.5.3/mariadb/install.yml
new file mode 100644
index 0000000..4d1be87
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/install.yml
@@ -0,0 +1,7 @@
+- hosts: mariadb
+ remote_user: root
+ roles:
+ - role
+ vars_files:
+ - role/vars/main.yml
+
diff --git a/MariaDB/10.5.3/mariadb/role/defaults/main.yml b/MariaDB/10.5.3/mariadb/role/defaults/main.yml
new file mode 100644
index 0000000..ac8bc01
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/defaults/main.yml
@@ -0,0 +1,9 @@
+#The default installation location
+deploy_dir: /data/olap
+
+#The default data storage location,use storing application data,logs and configuration files
+data_dir: /data/olap
+
+mariadb:
+ #Used to cache data and index data from tables in the InnoDB storage engine.
+ innodb_buffer_pool_size: 2048
diff --git a/MariaDB/10.5.3/mariadb/role/files/pyMysql.zip b/MariaDB/10.5.3/mariadb/role/files/pyMysql.zip
new file mode 100644
index 0000000..ce72a5b
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/files/pyMysql.zip
Binary files differ
diff --git a/MariaDB/10.5.3/mariadb/role/handlers/main.yml b/MariaDB/10.5.3/mariadb/role/handlers/main.yml
new file mode 100644
index 0000000..5062d63
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/handlers/main.yml
@@ -0,0 +1,29 @@
+- name: Loading Image
+ docker_image:
+ name: '{{ image_name }}'
+ tag: '{{ image_tag }}'
+ load_path: '{{ deploy_dir }}/{{ container_name }}/{{ image_name }}-{{ image_tag }}.tar'
+ source: load
+ force_tag: yes
+ force_source: yes
+ timeout: 300
+
+- name: Start Container
+ docker_compose:
+ project_src: '{{ deploy_dir }}/{{ container_name }}/'
+
+- name: Loading Exporter Image
+ docker_image:
+ name: 'mysqld_exporter'
+ tag: 'v1.0'
+ load_path: '{{ deploy_dir }}/{{ container_name }}/monitor/mysqld_exporter-v1.0.tar'
+ source: load
+ force_tag: yes
+ force_source: yes
+ timeout: 300
+
+- name: Start Exporter Container
+ docker_compose:
+ project_src: '{{ deploy_dir }}/{{ container_name }}/monitor/'
+
+
diff --git a/MariaDB/10.5.3/mariadb/role/tasks/deploy-cluster.yml b/MariaDB/10.5.3/mariadb/role/tasks/deploy-cluster.yml
new file mode 100644
index 0000000..983b483
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/tasks/deploy-cluster.yml
@@ -0,0 +1,153 @@
+- name: Setting node_nums variable
+ set_fact: node_nums={{ groups.mariadb|length }}
+
+- name: To terminate execution
+ fail:
+ msg: "MariaDB in master-master mode. The value must have 2 nodes,please checking configurations/hosts -> mariadb"
+ when: node_nums != '2'
+
+- name: Creating directory
+ file:
+ state: directory
+ owner: ods
+ group: root
+ path: '{{ deploy_dir }}/{{ container_name }}/{{ item.dir }}'
+ with_items:
+ - { dir: 'config' }
+ - { dir: 'logs' }
+ - { dir: 'monitor' }
+
+- name: Copying image to {{ deploy_dir }}/{{ container_name }}/
+ copy:
+ src: 'files/{{ image_name }}-{{ image_tag }}.tar'
+ dest: '{{ deploy_dir }}/{{ container_name }}/'
+ force: true
+ notify:
+ - Loading Image
+
+- name: Copying image to {{ deploy_dir }}/{{ container_name }}/monitor
+ copy:
+ src: 'files/mysqld_exporter-v1.0.tar'
+ dest: '{{ deploy_dir }}/{{ container_name }}/monitor/'
+ force: true
+ notify:
+ - Loading Exporter Image
+
+- name: Copying Mariadb config files
+ template:
+ src: '{{ item.src }}'
+ dest: '{{ item.dest }}'
+ mode: 0644
+ with_items:
+ - { src: 'my.cnf.j2', dest: '{{ deploy_dir }}/{{ container_name }}/config/my.cnf' }
+ - { src: 'docker-compose.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml' }
+ notify:
+ - Start Container
+
+- meta: flush_handlers
+
+- name: Waitting for MariaDB running,20s
+ shell: sleep 20
+
+- name: Creating mariadb readonly user
+ shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e "CREATE USER IF NOT EXISTS '{{ mariadb_query_username}}'@'%' IDENTIFIED BY '{{ mariadb_query_pin }}' WITH MAX_USER_CONNECTIONS 3;GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO '{{ mariadb_query_username}}'@'%';FLUSH PRIVILEGES;"
+
+- name: change mariadb remote authority
+ shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e"use mysql;grant all privileges on *.* to 'root'@'%' identified by '{{ mariadb_default_pin }}' with grant option;FLUSH PRIVILEGES;"
+
+- name: copy pyMysql.zip
+ unarchive:
+ src: files/pyMysql.zip
+ dest: /tmp/
+ register: copy_info
+
+- name: pip install pyMysql
+ shell: cd /tmp/pyMysql && pip install --ignore-installed *
+ when: copy_info.changed
+
+- name: Get mariadb slave_status
+ mysql_info:
+ login_host: '{{ groups.mariadb[0] }}'
+ login_user: root
+ login_password: '{{ mariadb_default_pin }}'
+ filter: slave_status
+ register: mariadb_info
+
+- name: change_slave_to_master1
+ mysql_replication:
+ login_unix_socket: "{{ deploy_dir }}/{{ container_name }}/data/mysql.sock"
+ login_host: "{{ groups.mariadb[1] }}"
+ login_port: "3306"
+ login_user: root
+ login_password: "{{ mariadb_default_pin }}"
+ master_host: "{{ groups.mariadb[0] }}"
+ master_user: root
+ master_password: "{{ mariadb_default_pin }}"
+ master_port: "3306"
+ mode: changemaster
+ run_once: true
+ delegate_to: '{{ groups.mariadb[1] }}'
+ tags:
+ - change_slave_to_master1
+
+- name: start_slave1
+ mysql_replication:
+ login_unix_socket: "{{ deploy_dir }}/{{ container_name }}/data/mysql.sock"
+ login_user: root
+ login_host: "{{ inventory_hostname }}"
+ login_port: "3306"
+ login_password: "{{ mariadb_default_pin }}"
+ mode: startslave
+ tags:
+ - start_slave1
+ run_once: true
+ delegate_to: '{{ groups.mariadb[1] }}'
+
+- name: change_slave_to_master2
+ mysql_replication:
+ login_unix_socket: "{{ deploy_dir }}/{{ container_name }}/data/mysql.sock"
+ login_host: "{{ groups.mariadb[0] }}"
+ login_port: "3306"
+ login_user: root
+ login_password: "{{ mariadb_default_pin }}"
+ master_host: "{{ groups.mariadb[1] }}"
+ master_user: root
+ master_password: "{{ mariadb_default_pin }}"
+ master_port: "3306"
+ mode: changemaster
+ run_once: true
+ delegate_to: '{{ groups.mariadb[0] }}'
+ tags:
+ - change_slave_to_master2
+
+- name: start_slave2
+ mysql_replication:
+ login_unix_socket: "{{ deploy_dir }}/{{ container_name }}/data/mysql.sock"
+ login_user: root
+ login_host: "{{ inventory_hostname }}"
+ login_port: "3306"
+ login_password: "{{ mariadb_default_pin }}"
+ mode: startslave
+ tags:
+ - start_slave2
+ run_once: true
+ delegate_to: '{{ groups.mariadb[0] }}'
+
+- name: get_slave_info
+ mysql_replication:
+ login_host: 127.0.0.1
+ login_user: root
+ login_port: "3306"
+ login_password: "{{ mariadb_default_pin }}"
+ mode: getslave
+ register: info
+ tags:
+ - get_slave_info
+
+- name: Copying Mariadb config files
+ template:
+ src: 'exporter_docker-compose.yml.j2'
+ dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml'
+ mode: 0644
+ notify:
+ - Start Exporter Container
diff --git a/MariaDB/10.5.3/mariadb/role/tasks/deploy-standalone.yml b/MariaDB/10.5.3/mariadb/role/tasks/deploy-standalone.yml
new file mode 100644
index 0000000..d94eb38
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/tasks/deploy-standalone.yml
@@ -0,0 +1,66 @@
+- name: Setting node_nums variable
+ set_fact: node_nums={{ groups.mariadb|length }}
+
+- name: To terminate execution
+ fail:
+ msg: "MariaDB standalone mode. The value must have 1 nodes,please checking configurations/hosts -> mariadb"
+ when: node_nums != '1'
+
+- name: Creating directory
+ file:
+ state: directory
+ owner: ods
+ group: root
+ path: '{{ deploy_dir }}/{{ container_name }}/{{ item.dir }}'
+ with_items:
+ - { dir: 'config' }
+ - { dir: 'logs' }
+ - { dir: 'monitor' }
+
+- name: Copying image to {{ deploy_dir }}/{{ container_name }}/
+ copy:
+ src: 'files/{{ image_name }}-{{ image_tag }}.tar'
+ dest: '{{ deploy_dir }}/{{ container_name }}/'
+ force: true
+ notify:
+ - Loading Image
+
+- name: Copying image to {{ deploy_dir }}/{{ container_name }}/monitor
+ copy:
+ src: 'files/mysqld_exporter-v1.0.tar'
+ dest: '{{ deploy_dir }}/{{ container_name }}/monitor/'
+ force: true
+ notify:
+ - Loading Exporter Image
+
+- name: Copying Mariadb config files
+ template:
+ src: '{{ item.src }}'
+ dest: '{{ item.dest }}'
+ mode: 0644
+ with_items:
+ - { src: 'my.cnf.j2', dest: '{{ deploy_dir }}/{{ container_name }}/config/my.cnf' }
+ - { src: 'docker-compose.yml.j2', dest: '{{ deploy_dir }}/{{ container_name }}/docker-compose.yml' }
+ notify:
+ - Start Container
+
+- meta: flush_handlers
+
+- name: Waitting for MariaDB running,20s
+ shell: sleep 20
+
+- name: Creating mariadb readonly user
+ shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e "CREATE USER IF NOT EXISTS '{{ mariadb_query_username}}'@'%' IDENTIFIED BY '{{ mariadb_query_pin }}' WITH MAX_USER_CONNECTIONS 3;GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO '{{ mariadb_query_username}}'@'%';FLUSH PRIVILEGES;"
+
+- name: change mariadb remote authority
+ shell: mysql -uroot -h{{ inventory_hostname }} -p{{ mariadb_default_pin }} -e"use mysql;grant all privileges on *.* to 'root'@'%' identified by '{{ mariadb_default_pin }}' with grant option;FLUSH PRIVILEGES;"
+
+- name: Copying Mariadb config files
+ template:
+ src: 'exporter_docker-compose.yml.j2'
+ dest: '{{ deploy_dir }}/{{ container_name }}/monitor/docker-compose.yml'
+ mode: 0644
+ notify:
+ - Start Exporter Container
+
+- meta: flush_handlers
diff --git a/MariaDB/10.5.3/mariadb/role/tasks/main.yml b/MariaDB/10.5.3/mariadb/role/tasks/main.yml
new file mode 100644
index 0000000..a8a33a1
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/tasks/main.yml
@@ -0,0 +1,11 @@
+- block:
+ - include: uninstall.yml
+ - include: "{{ playbook_name }}"
+ vars:
+ playbook_name: "{{ 'deploy-cluster.yml' if groups.mariadb | length > 1 else 'deploy-standalone.yml' }}"
+ - include: status-check.yml
+ when: (operation) == "install"
+
+- block:
+ - include: uninstall.yml
+ when: (operation) == "uninstall"
diff --git a/MariaDB/10.5.3/mariadb/role/tasks/status-check.yml b/MariaDB/10.5.3/mariadb/role/tasks/status-check.yml
new file mode 100644
index 0000000..60b813e
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/tasks/status-check.yml
@@ -0,0 +1,14 @@
+- name: Check if the MariaDB already exists
+ shell: ps -ef | grep -v mysqld_exporter | grep -v grep | grep mysqld | wc -l
+ register: process_out
+
+- name: Check if the MariaDB already exists
+ shell: netstat -anlp | egrep "3306" | grep LISTEN | wc -l
+ register: port_out
+
+- name: To terminate execution
+ fail:
+ msg: "MariaDB on node {{ inventory_hostname }} is not started. Please check"
+ run_once: true
+ delegate_to: 127.0.0.1
+ when: process_out.stdout != '1' or port_out.stdout != '1'
diff --git a/MariaDB/10.5.3/mariadb/role/tasks/uninstall.yml b/MariaDB/10.5.3/mariadb/role/tasks/uninstall.yml
new file mode 100644
index 0000000..1f9872f
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/tasks/uninstall.yml
@@ -0,0 +1,27 @@
+- block:
+ - name: Stopping and removing {{ container_name }} container
+ docker_container:
+ name: '{{ container_name }}'
+ state: absent
+
+ - name: Removing old {{ image_name }} image
+ docker_image:
+ name: '{{ image_name }}'
+ tag: '{{ image_tag }}'
+ state: absent
+
+ - name: Stopping and removing exporter container
+ docker_container:
+ name: 'mysqld_exporter'
+ state: absent
+
+ - name: Removing old exporter image
+ docker_image:
+ name: 'mysqld_exporter'
+ tag: 'v1.0'
+ state: absent
+
+ - name: Ansible delete old {{ deploy_dir }}/{{ container_name }}
+ file:
+ path: '{{ deploy_dir }}/{{ container_name }}'
+ state: absent
diff --git a/MariaDB/10.5.3/mariadb/role/templates/docker-compose.yml.j2 b/MariaDB/10.5.3/mariadb/role/templates/docker-compose.yml.j2
new file mode 100644
index 0000000..b752df8
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/docker-compose.yml.j2
@@ -0,0 +1,15 @@
+version: "3.7"
+
+services:
+ mariadb:
+ image: {{ image_name }}:{{ image_tag }}
+ container_name: {{ container_name }}
+ restart: always
+ environment:
+ - MYSQL_ROOT_PASSWORD={{ mariadb_default_pin }}
+ volumes:
+ - {{ deploy_dir }}/{{ container_name }}/data:/opt/mariadb/data
+ - {{ deploy_dir }}/{{ container_name }}/logs:/opt/mariadb/logs
+ - {{ deploy_dir }}/{{ container_name }}/config/my.cnf:/etc/mysql/my.cnf
+ network_mode: "host"
+
diff --git a/MariaDB/10.5.3/mariadb/role/templates/exporter_docker-compose.yml.j2 b/MariaDB/10.5.3/mariadb/role/templates/exporter_docker-compose.yml.j2
new file mode 100644
index 0000000..a2ce0a5
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/exporter_docker-compose.yml.j2
@@ -0,0 +1,17 @@
+version: '3'
+services:
+ mysql_exporter:
+ image: mysqld_exporter:v1.0
+ container_name: mysqld_exporter
+ restart: always
+ ports:
+ - 9911:9104
+ hostname: mysqld_exporter
+ environment:
+ - DATA_SOURCE_NAME=tsg_query:{{ mariadb_query_pin }}@({{ inventory_hostname }}:3306)/
+ networks:
+ olap:
+ ipv4_address: 172.20.88.6
+networks:
+ olap:
+ external: true
diff --git a/MariaDB/10.5.3/mariadb/role/templates/keepalived/check_mariadb.sh.j2 b/MariaDB/10.5.3/mariadb/role/templates/keepalived/check_mariadb.sh.j2
new file mode 100644
index 0000000..3dc80d5
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/keepalived/check_mariadb.sh.j2
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+PORT_CHECK=$(netstat -anlp | grep 3306 | grep LISTEN | grep mysqld | grep -v grep | wc -l)
+
+if [[ $PORT_CHECK -eq 0 ]];then
+ echo "`date "+%Y-%m-%d %H:%M:%S"` - Mariadb 端口未监听,服务异常" >> /etc/keepalived/keepalived_check.log
+ exit 1
+fi
+
+SQL_CHECK=`mysql -h{{inventory_hostname}} -utsg_query -p{{mariadb_query_pin}} -e "SELECT 'ok' AS OK;"`
+
+if [[ $? -ne '0' ]];then
+ echo "`date "+%Y-%m-%d %H:%M:%S"` - Mariadb SQL执行失败,服务状态异常" >> /etc/keepalived/keepalived_check.log
+ exit 1
+fi
diff --git a/MariaDB/10.5.3/mariadb/role/templates/keepalived/keepalived-mariadb.conf.j2 b/MariaDB/10.5.3/mariadb/role/templates/keepalived/keepalived-mariadb.conf.j2
new file mode 100644
index 0000000..4cd1970
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/keepalived/keepalived-mariadb.conf.j2
@@ -0,0 +1,48 @@
+#mariadb Load balancing start
+vrrp_script chk_mariadb {
+ script "/etc/keepalived/check_mariadb.sh"
+ #每2s检查一次
+ interval 2
+ #每次检查-20
+ weight -20
+}
+
+#VRRP实例定义块
+vrrp_instance VI_MARIADB {
+{% if inventory_hostname == groups.mariadb[0] %}
+#状态只有MASTER和BACKUP两种,并且要大写,MASTER为工作状态,BACKUP是备用状态。
+state MASTER
+#优先级,同一个vrrp_instance的MASTER优先级必须比BACKUP高。
+priority 150
+{% elif inventory_hostname == groups.mariadb[1] %}
+#状态只有MASTER和BACKUP两种,并且要大写,MASTER为工作状态,BACKUP是备用状态。
+state BACKUP
+#优先级,同一个vrrp_instance的MASTER优先级必须比BACKUP高。
+priority 100
+{% endif %}
+#网卡名称
+interface {{ ansible_default_ipv4.interface }}
+#虚拟路由标识,同一个vrrp_instance的MASTER和BACKUP的vitrual_router_id 是一致的。
+virtual_router_id 66
+#MASTER 与BACKUP 负载均衡器之间同步检查的时间间隔,单位为秒。
+advert_int 1
+authentication {
+#验证authentication。包含验证类型和验证密码。类型主要有PASS、AH 两种,通常使用的类型为PASS
+auth_type PASS
+#据说AH 使用时有问题。验证密码为明文,同一vrrp 实例MASTER 与BACKUP 使用相同的密码才能正常通信
+auth_pass 1111
+}
+#触发的脚本
+track_script {
+#检测脚本,上面配置的
+ chk_mariadb
+}
+virtual_ipaddress {
+#虚拟ip地址,可以有多个地址,每个地址占一行,不需要子网掩码
+ {{ mariadb_virtual_ipaddress }}
+}
+}
+#mariadb Load balancing end
+
+
+
diff --git a/MariaDB/10.5.3/mariadb/role/templates/keepalived/unload_balancer.sh.j2 b/MariaDB/10.5.3/mariadb/role/templates/keepalived/unload_balancer.sh.j2
new file mode 100644
index 0000000..fa717dc
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/keepalived/unload_balancer.sh.j2
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+function del_ipaddr(){
+keepHostCheck=`ip address show {{ vrrp_instance.default.interface }} | grep "{{ vrrp_instance.default.virtual_ipaddress }}" | wc -l`
+if [ $keepHostCheck -eq "1" ];then
+ ip address del {{ vrrp_instance.default.virtual_ipaddress }} dev {{ vrrp_instance.default.interface }}
+fi
+}
+
+
+if [ -f "/etc/keepalived/conf.d/keepalived-mariadb.conf" ];then
+ rm -rf /etc/keepalived/check_mariadb.sh
+ rm -rf /etc/keepalived/conf.d/keepalived-mariadb.conf
+ service keepalived stop && systemctl daemon-reload && sleep 3 && service keepalived start
+ del_ipaddr
+else
+ del_ipaddr
+fi
diff --git a/MariaDB/10.5.3/mariadb/role/templates/my.cnf.j2 b/MariaDB/10.5.3/mariadb/role/templates/my.cnf.j2
new file mode 100644
index 0000000..9ab16d7
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/templates/my.cnf.j2
@@ -0,0 +1,198 @@
+# Example MariaDB config file for very large systems.
+#
+# This is for a large system with memory of 1G-2G where the system runs mainly
+# MariaDB.
+#
+# MariaDB programs look for option files in a set of
+# locations which depend on the deployment platform.
+# You can copy this option file to one of those
+# locations. For information about these locations, do:
+# 'my_print_defaults --help' and see what is printed under
+# Default options are read from the following files in the given order:
+# More information at: http://dev.mysql.com/doc/mysql/en/option-files.html
+#
+# In this file, you can use all long options that a program supports.
+# If you want to know which options a program supports, run the program
+# with the "--help" option.
+
+# The following options will be passed to all MySQL clients
+[client]
+#password = your_password
+port = 3306
+socket = /opt/mariadb/data/mysql.sock
+
+# Here follows entries for some specific programs
+
+# The MySQL server
+[mysqld]
+default-time_zone='+0:00'
+port = 3306
+datadir = /opt/mariadb/data
+socket = /opt/mariadb/data/mysql.sock
+skip-external-locking
+key_buffer_size = 384M
+max_allowed_packet = 1M
+table_open_cache = 512
+sort_buffer_size = 2M
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+myisam_sort_buffer_size = 64M
+thread_cache_size = 8
+query_cache_size = 32M
+# Try number of CPU's*2 for thread_concurrency
+thread_concurrency = 8
+
+innodb_file_per_table = on #为每个表都创建分区
+skip_name_resolve = on #跳过域名解析
+lower_case_table_names = 1 #忽略表名大小写
+character-set-server = utf8mb4 #数据库编码
+character-set-client = utf8mb4
+slow_query_log
+long_query_time = 0.1
+#mysql连接数设置
+max_connections=5000
+log_error=/opt/mariadb/logs/log_error.log
+slow_query_log_file = /opt/mariadb/logs/slow_query.log
+innodb_log_file_size = 512M
+innodb_flush_method = O_DIRECT
+innodb_log_files_in_group = 3
+innodb_buffer_pool_size = {{ mariadb.innodb_buffer_pool_size }}
+innodb_buffer_pool_instances = 4
+socket = /opt/mariadb/data/mysql.sock
+skip-external-locking
+key_buffer_size = 384M
+max_allowed_packet = 128M
+table_open_cache = 1024
+sort_buffer_size = 2M
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+myisam_sort_buffer_size = 64M
+thread_cache_size = 8
+query_cache_size = 32M
+thread_concurrency = 16 #线程数量,推荐为cpu和核数的2倍
+bulk_insert_buffer_size=100M
+
+slave_skip_errors = 1062
+
+# Point the following paths to a dedicated disk
+#tmpdir = /tmp/
+
+# Don't listen on a TCP/IP port at all. This can be a security enhancement,
+# if all processes that need to connect to mysqld run on the same host.
+# All interaction with mysqld must be made via Unix sockets or named pipes.
+# Note that using this option without enabling named pipes on Windows
+# (via the "enable-named-pipe" option) will render mysqld useless!
+#
+#skip-networking
+
+# Replication Master Server (default)
+# binary logging is required for replication
+log-bin=mysql-bin
+
+# required unique id between 1 and 2^32 - 1
+# defaults to 1 if master-host is not set
+# but will not function as a master if omitted
+
+server-id = {{ groups['mariadb'].index(inventory_hostname) +1 }}
+auto_increment_increment = {{ groups.mariadb|length }} #步进值auto_imcrement。一般有n台主MySQL就填n
+auto_increment_offset = {{ groups['mariadb'].index(inventory_hostname) +1 }} #起始值。一般填第n台主MySQL。此时为第一台主MySQL
+
+log_slave_updates=on
+
+binlog-ignore-db = mysql
+binlog-ignore-db = performance_schema
+binlog-ignore-db = information_schema
+
+# Replication Slave (comment out master section to use this)
+#
+# To configure this host as a replication slave, you can choose between
+# two methods :
+#
+# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
+# the syntax is:
+#
+# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
+# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
+#
+# where you replace <host>, <user>, <password> by quoted strings and
+# <port> by the master's port number (3306 by default).
+#
+# Example:
+#
+# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
+# MASTER_USER='joe', MASTER_PASSWORD='secret';
+#
+# OR
+#
+# 2) Set the variables below. However, in case you choose this method, then
+# start replication for the first time (even unsuccessfully, for example
+# if you mistyped the password in master-password and the slave fails to
+# connect), the slave will create a master.info file, and any later
+# change in this file to the variables' values below will be ignored and
+# overridden by the content of the master.info file, unless you shutdown
+# the slave server, delete master.info and restart the slaver server.
+# For that reason, you may want to leave the lines below untouched
+# (commented) and instead use CHANGE MASTER TO (see above)
+#
+# required unique id between 2 and 2^32 - 1
+# (and different from the master)
+# defaults to 2 if master-host is set
+# but will not function as a slave if omitted
+#server-id = 2
+#
+# The replication master for this slave - required
+#master-host = <hostname>
+#
+# The username the slave will use for authentication when connecting
+# to the master - required
+#master-user = <username>
+#
+# The password the slave will authenticate with when connecting to
+#master-password = <password>
+#
+# The port the master is listening on.
+# optional - defaults to 3306
+#master-port = <port>
+#
+# binary logging - not required for slaves, but recommended
+#log-bin=mysql-bin
+#
+# binary logging format - mixed recommended
+#binlog_format=mixed
+
+# Uncomment the following if you are using InnoDB tables
+#innodb_data_home_dir = /usr/local/mysql/data
+#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
+#innodb_log_group_home_dir = /usr/local/mysql/data
+# You can set .._buffer_pool_size up to 50 - 80 %
+# of RAM but beware of setting memory usage too high
+#innodb_buffer_pool_size = 384M
+# Set .._log_file_size to 25 % of buffer pool size
+#innodb_log_file_size = 100M
+#innodb_log_buffer_size = 8M
+innodb_flush_log_at_trx_commit = 1
+innodb_lock_wait_timeout = 300
+sync_binlog=1
+
+relay-log=relay-bin
+relay-log-index=relay-bin-index
+slave-skip-errors=all
+
+[mysqldump]
+quick
+max_allowed_packet = 256M
+
+[mysql]
+no-auto-rehash
+# Remove the next comment character if you are not familiar with SQL
+#safe-updates
+
+[myisamchk]
+key_buffer_size = 256M
+sort_buffer_size = 256M
+read_buffer = 2M
+write_buffer = 2M
+
+[mysqlhotcopy]
+interactive-timeout
+
diff --git a/MariaDB/10.5.3/mariadb/role/vars/main.yml b/MariaDB/10.5.3/mariadb/role/vars/main.yml
new file mode 100644
index 0000000..5b44b38
--- /dev/null
+++ b/MariaDB/10.5.3/mariadb/role/vars/main.yml
@@ -0,0 +1,9 @@
+#镜像名称
+image_name: mariadb
+
+#镜像版本号
+image_tag: 10.5.3
+
+#容器名称
+container_name: mariadb
+