mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
# There is no MySQL 5.7 for RHEL 8. This will need to be retooled to use 8.0 for RHEL 8 or use the setup_mysql8 role for everything
|
||||
repo_link: https://repo.mysql.com/mysql57-community-release-el{{ ansible_facts.distribution_major_version }}.rpm
|
||||
repo_name: mysql-community
|
||||
mysql_package_name: mysql-community-server
|
||||
|
||||
master_port: 3306
|
||||
standby_port: 3307
|
||||
master_datadir: /var/lib/mysql_master
|
||||
master_cnf: /etc/my-1.cnf
|
||||
standby_cnf: /etc/my-2.cnf
|
||||
standby_datadir: /var/lib/mysql_standby
|
||||
standby_logdir: /var/log/mysql_standby
|
||||
default_logdir: /var/log/mysql
|
||||
mysqld_err_log: '{{ default_logdir }}/mysql-err.log'
|
|
@ -0,0 +1,8 @@
|
|||
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Setup MySQL master-standby replication into one container:
|
||||
- import_tasks: setup_mysql_cluster.yml
|
||||
when:
|
||||
- ansible_facts.distribution == 'CentOS'
|
||||
- ansible_facts.distribution_major_version is version('7', '==')
|
|
@ -0,0 +1,60 @@
|
|||
# We run two servers listening different ports
|
||||
# to be able to check replication (one server for master, another for standby).
|
||||
|
||||
- name: Install Repo
|
||||
yum:
|
||||
name: '{{ repo_link }}'
|
||||
|
||||
- name: Install MySQL community server
|
||||
yum:
|
||||
name: '{{ mysql_package_name }}'
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ item }}"
|
||||
owner: mysql
|
||||
group: mysql
|
||||
loop:
|
||||
- "{{ master_datadir }}"
|
||||
- "{{ standby_datadir }}"
|
||||
- "{{ standby_logdir }}"
|
||||
- "{{ default_logdir }}"
|
||||
|
||||
- name: Copy cnf templates
|
||||
template:
|
||||
src: '{{ item.conf_templ }}'
|
||||
dest: '{{ item.conf_dest }}'
|
||||
owner: mysql
|
||||
group: mysql
|
||||
force: yes
|
||||
loop:
|
||||
- { conf_templ: my-1.cnf.j2, conf_dest: '{{ master_cnf }}' }
|
||||
- { conf_templ: my-2.cnf.j2, conf_dest: '{{ standby_cnf }}' }
|
||||
|
||||
- name: Initialize DBs
|
||||
shell: 'mysqld --user=mysql --initialize-insecure --datadir={{ item }}'
|
||||
loop:
|
||||
- '{{ master_datadir }}'
|
||||
- '{{ standby_datadir }}'
|
||||
|
||||
- name: Start master services
|
||||
shell: 'mysqld --defaults-file={{ master_cnf }} --user=mysql --datadir={{ master_datadir }} --log-error={{ mysqld_err_log }} &'
|
||||
|
||||
- name: Start standby services
|
||||
shell: 'mysqld --defaults-file={{ standby_cnf }} --user=mysql --datadir={{ standby_datadir }} --log-error={{ mysqld_err_log }} &'
|
||||
|
||||
- name: Pause
|
||||
pause: seconds=3
|
||||
|
||||
########### For painful debug uncomment the lines below ##
|
||||
#- name: DEBUG Check log
|
||||
# shell: 'cat {{ mysqld_err_log }}'
|
||||
# ignore_errors: yes
|
||||
##########################################################
|
||||
|
||||
- name: Check connection to the master
|
||||
shell: 'echo "SHOW DATABASES;" | mysql -P {{ master_port }} -h 127.0.0.1'
|
||||
|
||||
- name: Check connection to the standby
|
||||
shell: "echo \"SHOW VARIABLES LIKE '%version%';\" | mysql -P {{ standby_port }} -h 127.0.0.1"
|
|
@ -0,0 +1,11 @@
|
|||
[mysqld]
|
||||
server_id = 1
|
||||
port = {{ master_port }}
|
||||
datadir = {{ master_datadir }}
|
||||
socket = {{ master_datadir }}/mysql.sock
|
||||
pid-file = {{ master_datadir }}/mysql.pid
|
||||
#mysqladmin = /usr/bin/mysqladmin
|
||||
log_bin = /var/log/mysql/mysql-bin.log
|
||||
sync_binlog = 1
|
||||
binlog-format = ROW
|
||||
innodb_flush_log_at_trx_commit = 1
|
|
@ -0,0 +1,13 @@
|
|||
[mysqld]
|
||||
server_id = 2
|
||||
port = {{ standby_port }}
|
||||
socket = /var/run/mysqld/mysqld_slave.sock
|
||||
pid-file = /var/run/mysqld/mysqld_slave.pid
|
||||
datadir = {{ standby_datadir }}
|
||||
log_bin = {{ standby_logdir }}/mysql-bin.log
|
||||
relay-log = {{ standby_logdir }}/relay-bin
|
||||
relay-log-index = {{ standby_logdir }}/relay-bin.index
|
||||
master-info-file = {{ standby_logdir }}/master.info
|
||||
relay-log-info-file = {{ standby_logdir }}/relay-log.info
|
||||
master-info-repository = TABLE
|
||||
relay-log-info-repository = TABLE
|
Loading…
Add table
Add a link
Reference in a new issue