MySQL环境部署神器dbdeployer,Sandbox的替代品

0    134    1

Tags:

👉 本文共约3310个字,系统预计阅读时间或需13分钟。


https://github.com/datacharmer/dbdeployer

https://github.com/datacharmer/mysql-sandbox

dbdeployer是go语言版实现的sandbox,和sandbox同一个作者。

dbdeployer能够快速部署数据库测试环境,一键实现Oracle MySQL、Percona MySQL、MariaDB、TiDB、MySQL NDB Cluster、PXC等测试环境的构建。

DBdeployer is a tool that deploys MySQL database servers easily. This is a port of MySQL-Sandbox, originally written in Perl, and re-designed from the ground up in Go. See the features comparison for more detail.


dbdeployer的安装:

直接到github下载release包即可

tar xf dbdeployer-1.19.0.linux.tar.gz -C ./

chmod +x dbdeployer-1.19.0.linux

mv dbdeployer-1.19.0.linux /usr/local/bin/dbdeployer

mkdir /root/opt/mysql -pv

【方式1、离线方式 部署mysql安装包】

将 mysql(我这里用的是5.7和8.0)的general安装包传到服务器上,然后执行

dbdeployer unpack mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz

dbdeployer unpack mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

unpack后,在/root/opt/mysql 目录下自动解压成如下样子:

image.png

如果要解压后的文件夹名称特殊化,则可以如下方法:

dbdeployer unpack --prefix=ps Percona-Server-5.7.21-linux.tar.gz

Unpacking tarball Percona-Server-5.7.21-linux.tar.gz to $HOME/opt/mysql/ ps5.7.21

【方式2、在线下载的方式部署mysql安装包】

dbdeployer remote --help

dbdeployer remote list # 查看远程可下载的mysql安装包

Files available in https://raw.githubusercontent.com/datacharmer/mysql-docker-minimal/master/dbdata/available.json

4.1 -> [mysql-4.1.22]

5.0 -> [mysql-5.0.15 mysql-5.0.96]

5.1 -> [mysql-5.1.72]

5.5 -> [mysql-5.5.61 mysql-5.5.62]

5.6 -> [mysql-5.6.41 mysql-5.6.43]

5.7 -> [mysql-5.7.24 mysql-5.7.25]

8.0 -> [mysql-8.0.13 mysql-8.0.15]

dbdeployer remote download mysql-5.6.43 # 在线下载 mysql-5.6.43的安装包

dbdeployer unpack mysql-5.6.43.tar.xz

常用命令:

dbdeployer -h 列出各种帮助命令

image.png

本人提供Oracle、MySQL、PG等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

dbdeployer sandboxes 查看当前部署了哪些mysql sanbox

dbdeployer deploy -h 查看部署相关的命令及参数

Available Commands:

dbdeployer deploy multiple --help 部署多个独立的mysql

dbdeployer deploy replication --help 部署复制环境的mysql

dbdeployer deploy single --help 部署单节点mysql

dbdeployer deploy replication --help 查看帮助

dbdeployer deploy replication 8.0.15 --bind-address='0.0.0.0' --gtid --read-only-slaves --nodes=2 --semi-sync --topology=master-slave # 部署一套1M1S的gtid复制集群

dbdeployer deploy replication 5.7.25 --bind-address='0.0.0.0' --topology=group 部署一套多主MGR集群

dbdeployer deploy replication 5.7.25 --bind-address='0.0.0.0' --topology=group --single-primary 部署一套单主MGR集群

dbdeployer deploy single 5.7.25 --bind-address='0.0.0.0' --gtid 部署一台单机GTID的MySQL5.7实例

dbdeployer deploy single 5.7.25 --bind-address='0.0.0.0' --gtid --init-general-log --enable-general-log --disable-mysqlx --force #强制覆盖部署一他gtid 5.7实例,并且generallog

dbdeployer global status 列出全部sanbox实例的情况

dbdeployer delete rsandbox_8_0_15 删除 rsandbox_8_0_15 实例

dbdeployer delete rsandbox_8_0_11 --sandbox-home=/home/data -- sandbox-binary=/usr/local;

--部署1主多从(1拖4) (using ports 18601, 18602, 18603,18604)
dbdeployer deploy replication 8.0.11 --bind-address=0.0.0.0 --base-port=18600 --sandbox-home=/home/data --sandbox-binary=/usr/local --nodes=4;

--部署4个mysql,(using ports 18601, 18602, 18603,18604)
dbdeployer deploy multiple 8.0.11 --bind-address=0.0.0.0 --base-port=18600 --sandbox-home=/home/data --sandbox-binary=/usr/local --nodes=4;

安装3主2从(多主多从):

dbdeployer deploy replication --topology=fan-in --nodes=5 --master-list="1,2,3" --bind-address=0.0.0.0 --native-auth-plugin --slave-list="4,5" 8.0.11 --sandbox-home=/home/data --remote-access="%" --sandbox-binary=/usr/local --db-password="cc.123" --db-user="sa" --post-grants-sql=" grant all on . to 'sa'@'%' WITH GRANT OPTION "

--remote-access="%" 账户远程访问的IP,% 为全部

--db-user 新数据库账户

--db-password 数据库密码

--post-grants-sql 后面执行的数据库授权Sql

--native-auth-plugin 客户端如SQLLog可以访问MySQL,是在MySQL 8.0.4+ 有效

安装组复制:

dbdeployer deploy replication --topology=group --bind-address=0.0.0.0 8.0.11 --sandbox-home=/home/data --remote-access="%" --sandbox-binary=/usr/local --native-auth-plugin --db-password="cc.123" --db-user="sa" --post-grants-sql=" grant all on . to 'sa'@'%' WITH GRANT OPTION ";

加上: --single-primary 明确是单主

dbdeployer deploy --topology=all-masters replication --bind-address=0.0.0.0 8.0.11 --sandbox-home=/home/td --remote-access="%" --sandbox-binary=/usr/local --native-auth-plugin --db-password="cc.123" --db-user="sa" --post-grants-sql=" grant all on . to 'sa'@'%' WITH GRANT OPTION " --concurrent;

详细说明:
--base-port int Overrides default base-port (for multiple sandboxes)
--binary-version string Specifies the version when the basedir directory name does not contain it (i.e. it is not x.x.xx)
--bind-address string defines the database bind-address (default "127.0.0.1")
--concurrent Runs multiple sandbox deployments concurrently
--custom-mysqld string Uses an alternative mysqld (must be in the same directory as regular mysqld)
-p, --db-password string database password (default "msandbox")
-u, --db-user string database user (default "msandbox")
--defaults strings Change defaults on-the-fly (--defaults=label:value)
--disable-mysqlx Disable MySQLX plugin (8.0.11+)
--enable-general-log Enables general log for the sandbox (MySQL 5.1+)
--enable-mysqlx Enables MySQLX plugin (5.7.12+)
--expose-dd-tables In MySQL 8.0+ shows data dictionary tables
--force If a destination sandbox already exists, it will be overwritten
--gtid enables GTID
-h, --help help for deploy
--init-general-log uses general log during initialization (MySQL 5.1+)
-i, --init-options strings mysqld options to run during initialization
--keep-server-uuid Does not change the server UUID
--my-cnf-file string Alternative source file for my.sandbox.cnf
-c, --my-cnf-options strings mysqld options to add to my.sandbox.cnf
--native-auth-plugin in 8.0.4+, uses the native password auth plugin
--port int Overrides default port
--post-grants-sql strings SQL queries to run after loading grants
--post-grants-sql-file string SQL file to run after loading grants
--pre-grants-sql strings SQL queries to run before loading grants
--pre-grants-sql-file string SQL file to run before loading grants
--remote-access string defines the database access (default "127.%")
--rpl-password string replication password (default "rsandbox")
--rpl-user string replication user (default "rsandbox")
--sandbox-directory string Changes the default sandbox directory
--skip-load-grants Does not load the grants
--skip-report-host Does not include report host in my.sandbox.cnf
--skip-report-port Does not include report port in my.sandbox.cnf
--skip-start Does not start the database server
--use-template strings [template_name:file_name] Replace existing template with one from file

说明:

​ $ dbdeployer deploy replication 5.7.21
​ # (implies topology = master-slave) 默认主从

​ $ dbdeployer deploy --topology=master-slave replication 5.7.21
​ # (explicitly setting topology) 明确主从

​ $ dbdeployer deploy --topology=group replication 5.7.21 组复制多主
​ $ dbdeployer deploy --top


标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部