代码拉取完成,页面将自动刷新
同步操作将从 万里数据库/GreatSQL-Ansible 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
- name: install GreatSQL
hosts: greatsql_dbs
remote_user: root
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: modify selinux config file
lineinfile: dest=/etc/selinux/config regexp='SELINUX=enforcing' line='SELINUX=disabled' backrefs=yes state=present
- name: stop firewalld
command: /usr/bin/systemctl stop firewalld.service
- name: disable firewalld
command: /usr/bin/systemctl disable firewalld.service
- name: install jemalloc jemalloc-devel
raw: yum install -y jemalloc jemalloc-devel
- name: add group mysql
group: name={{mysql_user}} state=present
- name: add user mysql
user: name={{mysql_user}} group={{mysql_user}} shell=/sbin/nologin
- name: create data_dir
file: path={{data_dir}} state=directory owner={{mysql_user}} group={{mysql_user}} mode=0700
- name: extract GreatSQL tarball
unarchive: src={{work_dir}}/{{file_name}} dest={{extract_dir}} mode=755
- name: backup /etc/my.cnf
copy: src={{my_cnf}} dest={{my_cnf}}.orig ignore_errors=True
- name: copy my.cnf
copy: src={{work_dir}}/mysql-support-files/my.cnf dest={{my_cnf}} owner={{mysql_user}} group={{mysql_user}} mode=0644
- name: copy mysqld_pre_systemd
copy: src={{work_dir}}/mysql-support-files/mysqld_pre_systemd dest={{base_dir}}/bin/ owner={{mysql_user}} group={{mysql_user}} mode=0755
- name: replace mysqld_pre_systemd MYSQL_BASEDIR
replace:
path: "{{base_dir}}/bin/mysqld_pre_systemd"
regexp: '(MYSQL_BASEDIR)=.*'
replace: '\1={{base_dir}}'
- name: replace my.cnf server_id settings
replace:
path: "{{ my_cnf }}"
regexp: '(.*server_id.*)=.*'
replace: '\1= 3306{{ 1024 | random}}'
- name: replace my.cnf group_replication_local_address settings
replace:
path: "{{ my_cnf }}"
regexp: '(.*group_replication_local_address.*)=.*'
replace: '\1= {{ inventory_hostname }}:33061'
- name: replace my.cnf group_replication_group_seeds settings
replace:
path: "{{ my_cnf }}"
regexp: '(.*group_replication_group_seeds.*)=.*'
replace: '\1= {{ mgr_seeds }}'
- name: replace my.cnf report_host settings
replace:
path: "{{ my_cnf }}"
regexp: '(.*report_host.*)=.*'
replace: '\1= {{ inventory_hostname }}'
- name: replace my.cnf basedir
replace:
path: "{{ my_cnf }}"
regexp: 'basedir.*'
replace: 'basedir = {{ base_dir }}'
- name: replace my.cnf datadir
replace:
path: "{{ my_cnf }}"
regexp: 'datadir.*'
replace: 'datadir = {{ data_dir }}'
- name: replace my.cnf user
replace:
path: "{{ my_cnf }}"
regexp: '^user.*'
replace: 'user = {{ mysql_user }}'
- name: replace my.cnf port
replace:
path: "{{ my_cnf }}"
regexp: '^port.*'
replace: 'port = {{ mysql_port }}'
- name: copy sysconfig/mysql to /etc/sysconfig/mysql
copy: src={{work_dir}}/mysql-support-files/sysconfig/mysql dest=/etc/sysconfig owner=root group=root mode=0644
- name: preload jemalloc
command: /usr/sbin/ldconfig
- name: copy mysql PATH
copy: src={{work_dir}}/mysql-support-files/mysql.sh dest=/etc/profile.d/mysql.sh
- name: replace mysql.sh PATH
replace:
path: /etc/profile.d/mysql.sh
regexp: '(.*PATH.*)=.*'
replace: 'export PATH=$PATH:{{base_dir}}/bin'
- name: copy greatsql.server
copy: src={{work_dir}}/mysql-support-files/greatsql.service dest=/usr/lib/systemd/system/ owner=root group=root mode=0644
- name: replace greatsql.service
replace:
path: /usr/lib/systemd/system/greatsql.service
regexp: '(ExecStartPre=)(.*)(/bin/mysqld.*)'
replace: '\1{{base_dir}}\3'
- name: replace greatsql.service
replace:
path: /usr/lib/systemd/system/greatsql.service
regexp: '(ExecStart=)(.*)(/bin/mysqld.*)'
replace: '\1{{base_dir}}\3'
- name: reload GreatSQL service
command: /usr/bin/systemctl daemon-reload
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr primary
hosts: greatsql_mgr_primary
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: start the GreatSQL service on PRIMARY NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep {{ wait_for_start }}
delay: 1
- name: mgr primary init
shell: >
{{ base_dir }}/bin/mysql -uroot -f -S {{ data_dir }}/mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS {{ mgr_user }} IDENTIFIED WITH mysql_native_password BY '{{ mgr_user_pwd }}';
GRANT REPLICATION SLAVE, BACKUP_ADMIN ON *.* TO {{ mgr_user }};
CHANGE MASTER TO MASTER_USER='{{ mgr_user }}', MASTER_PASSWORD='{{ mgr_user_pwd }}' FOR CHANNEL 'group_replication_recovery';
SET GLOBAL group_replication_local_address = '{{ inventory_hostname }}:33061';
SET GLOBAL group_replication_group_seeds = '{{ mgr_seeds }}';
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr secondary
hosts: greatsql_mgr_secondary
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: start the GreatSQL service on SECONDARY NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep {{ wait_for_start }}
delay: 1
- name: mgr secondary init
shell: >
{{ base_dir }}/bin/mysql -uroot -f -S {{ data_dir }}/mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS {{ mgr_user }} IDENTIFIED WITH mysql_native_password BY '{{ mgr_user_pwd }}';
GRANT REPLICATION SLAVE, BACKUP_ADMIN ON *.* TO {{ mgr_user }};
CHANGE MASTER TO MASTER_USER='{{ mgr_user }}', MASTER_PASSWORD='{{ mgr_user_pwd }}' FOR CHANNEL 'group_replication_recovery';
SET GLOBAL group_replication_local_address = '{{ inventory_hostname }}:33061';
SET GLOBAL group_replication_group_seeds = '{{ mgr_seeds }}';
START GROUP_REPLICATION; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr arbitrator
hosts: greatsql_mgr_arbitrator
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: replace my.cnf arbitrator settings
replace:
path: "{{ my_cnf }}"
regexp: '(.*_arbitrator.*)=.*'
replace: '\1= 1'
- name: start the GreatSQL service on ARBITRATOR NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep {{ wait_for_start }}
delay: 1
- name: mgr arbitrator init
shell: >
{{ base_dir }}/bin/mysql -uroot -f -S {{ data_dir }}/mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS {{ mgr_user }} IDENTIFIED WITH mysql_native_password BY '{{ mgr_user_pwd }}';
GRANT REPLICATION SLAVE, BACKUP_ADMIN ON *.* TO {{ mgr_user }};
CHANGE MASTER TO MASTER_USER='{{ mgr_user }}', MASTER_PASSWORD='{{ mgr_user_pwd }}' FOR CHANNEL 'group_replication_recovery';
SET GLOBAL group_replication_local_address = '{{ inventory_hostname }}:33061';
SET GLOBAL group_replication_group_seeds = '{{ mgr_seeds }}';
START GROUP_REPLICATION; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。