MySQL Deployment Quick Start
Example: MySQL 8.4, one master and two standbys.
1. Prepare dbbot and Ansible
dbbot_version="1.11.20250429"
wget "https://github.com/fanderchan/dbbot/releases/download/${dbbot_version}/dbbot-${dbbot_version}-Linux-x86_64.tar.gz"
tar -zxvf "dbbot-${dbbot_version}-Linux-x86_64.tar.gz" -C /usr/local/
cd /usr/local/dbbot/portable-ansible-v0.5.0-py3
sh setup_portable_ansible.sh
source ~/.bashrc
ansible --version
2. Prepare MySQL installation package (optional)
cd /usr/local/dbbot/mysql_ansible/downloads
mysql_version="8.4.5"
wget "https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-${mysql_version}-linux-glibc2.17-x86_64-minimal.tar.xz"
If the server is connected to the Internet and automatic downloading is enabled, manual uploading is not required.
3. Configure host and parameters
inventory/hosts.ini:
[dbbot_mysql]
192.0.2.131 ansible_user=root ansible_ssh_pass="'<your_password>'"
192.0.2.132 ansible_user=root ansible_ssh_pass="'<your_password>'"
192.0.2.133 ansible_user=root ansible_ssh_pass="'<your_password>'"
playbooks/common_config.yml:
mysql_version: "8.4.5"
mysql_port: 3306
Description:
- dbbot’s public default passwords follow
Dbbot_<user>@8888/Dbbot_<linux_user>@9999. - Default
fcs_allow_dbbot_default_passwd: false, so if the public default password is still used, pre-deployment will fail directly in thepre_tasksstage. - The experimental environment can be temporarily set to
true, and the production environment should be changed to your own password.
playbooks/vars/var_master_slave.yml:
master_ip: 192.0.2.131
slave_ips:
- 192.0.2.132
- 192.0.2.133
sub_nets: 1%
4. Pre-execution check
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible dbbot_mysql -m ping
5. Execute deployment
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook master_slave.yml
During execution, enter confirm as prompted to continue.
6. Deployment completion validation
- Check
PLAY RECAPfor nofailed/unreachable. - Perform a version check on the target machine:
mysql -uadmin -h127.0.0.1 -P3306 -pDbbot_admin@8888 -e "select @@version"