Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAllMastersReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
- func CreateChildSandbox(sandboxDef SandboxDef) (execList []concurrent.ExecutionList, err error)
- func CreateFanInReplication(sandboxDef SandboxDef, origin string, nodes int, ...) error
- func CreateGroupReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
- func CreateMasterSlaveReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
- func CreateMultipleSandbox(sandboxDef SandboxDef, origin string, nodes int) (common.StringMap, error)
- func CreateReplicationSandbox(sdef SandboxDef, origin string, topology string, nodes int, ...) error
- func CreateStandaloneSandbox(sandboxDef SandboxDef) (err error)
- func RemoveSandbox(sandboxDir, sandbox string, runConcurrently bool) (execList []concurrent.ExecutionList, err error)
- type AllTemplateCollection
- type MockFileSet
- type Node
- type SandboxDef
- type ScriptBatch
- type ScriptDef
- type Slave
- type TemplateCollection
- type TemplateDesc
Constants ¶
View Source
const ( GroupReplOptions string = `` /* 331-byte string literal not displayed */ GroupReplSinglePrimary string = ` loose-group-replication-single-primary-mode=on ` GroupReplMultiPrimary string = ` loose-group-replication-single-primary-mode=off ` )
Variables ¶
View Source
var ( Copyright string = `` /* 654-byte string literal not displayed */ SingleTemplates = TemplateCollection{ "Copyright": TemplateDesc{ Description: "Copyright for every sandbox script", Notes: "", Contents: Copyright, }, "replication_options": TemplateDesc{ Description: "Replication options for my.cnf", Notes: "", Contents: replicationOptions, }, "semisync_master_options": TemplateDesc{ Description: "master semi-synch options for my.cnf", Notes: "", Contents: semisyncMasterOptions, }, "semisync_slave_options": TemplateDesc{ Description: "slave semi-synch options for my.cnf", Notes: "", Contents: semisyncSlaveOptions, }, "gtid_options_56": TemplateDesc{ Description: "GTID options for my.cnf 5.6.x", Notes: "", Contents: gtidOptions56, }, "gtid_options_57": TemplateDesc{ Description: "GTID options for my.cnf 5.7.x and 8.0", Notes: "", Contents: gtidOptions57, }, "repl_crash_safe_options": TemplateDesc{ Description: "Replication crash safe options", Notes: "", Contents: replCrashSafeOptions, }, "expose_dd_tables": TemplateDesc{ Description: "Commands needed to enable data dictionary table usage", Notes: "", Contents: exposeDdTables, }, "init_db_template": TemplateDesc{ Description: "Initialization template for the database", Notes: "This should normally run only once", Contents: initDbTemplate, }, "start_template": TemplateDesc{ Description: "starts the database in a single sandbox (with optional mysqld arguments)", Notes: "", Contents: startTemplate, }, "use_template": TemplateDesc{ Description: "Invokes the MySQL client with the appropriate options", Notes: "", Contents: useTemplate, }, "mysqlsh_template": TemplateDesc{ Description: "Invokes the MySQL shell with an appropriate URI", Notes: "", Contents: mysqlshTemplate, }, "stop_template": TemplateDesc{ Description: "Stops a database in a single sandbox", Notes: "", Contents: stopTemplate, }, "clear_template": TemplateDesc{ Description: "Remove all data from a single sandbox", Notes: "", Contents: clearTemplate, }, "my_cnf_template": TemplateDesc{ Description: "Default options file for a sandbox", Notes: "", Contents: myCnfTemplate, }, "status_template": TemplateDesc{ Description: "Shows the status of a single sandbox", Notes: "", Contents: statusTemplate, }, "restart_template": TemplateDesc{ Description: "Restarts the database (with optional mysqld arguments)", Notes: "", Contents: restartTemplate, }, "send_kill_template": TemplateDesc{ Description: "Sends a kill signal to the database", Notes: "", Contents: sendKillTemplate, }, "load_grants_template": TemplateDesc{ Description: "Loads the grants defined for the sandbox", Notes: "", Contents: loadGrantsTemplate, }, "grants_template5x": TemplateDesc{ Description: "Grants for sandboxes up to 5.6", Notes: "", Contents: grantsTemplate5x, }, "grants_template57": TemplateDesc{ Description: "Grants for sandboxes from 5.7+", Notes: "", Contents: grantsTemplate57, }, "grants_template8x": TemplateDesc{ Description: "Grants for sandboxes from 8.0+", Notes: "", Contents: grantsTemplate8x, }, "my_template": TemplateDesc{ Description: "Prefix script to run every my* command line tool", Notes: "", Contents: myTemplate, }, "add_option_template": TemplateDesc{ Description: "Adds options to the my.sandbox.cnf file and restarts", Notes: "", Contents: addOptionTemplate, }, "show_log_template": TemplateDesc{ Description: "Shows error log or custom log", Notes: "", Contents: showLogTemplate, }, "show_binlog_template": TemplateDesc{ Description: "Shows a binlog for a single sandbox", Notes: "", Contents: showBinlogTemplate, }, "show_relaylog_template": TemplateDesc{ Description: "Show the relaylog for a single sandbox", Notes: "", Contents: showRelaylogTemplate, }, "test_sb_template": TemplateDesc{ Description: "Tests basic sandbox functionality", Notes: "", Contents: testSbTemplate, }, "sb_locked_template": TemplateDesc{ Description: "locked sandbox script", Notes: "This script is replacing 'clear' when the sandbox is locked", Contents: sbLockedTemplate, }, "after_start_template": TemplateDesc{ Description: "commands to run after the database started", Notes: "This script does nothing. You can change it and reuse through --use-template", Contents: afterStartTemplate, }, "sb_include_template": TemplateDesc{ Description: "Common variables and routines for sandboxes scripts", Notes: "", Contents: sbIncludeTemplate, }, } MockTemplates = TemplateCollection{ "no_op_mock_template": TemplateDesc{ Description: "mock script that does nothing", Notes: "Used for internal tests", Contents: noOpMockTemplate, }, "mysqld_safe_mock_template": TemplateDesc{ Description: "mock script for mysqld_safe", Notes: "Used for internal tests", Contents: mysqldSafeMockTemplate, }, "tidb_mock_template": TemplateDesc{ Description: "mock script for tidb-server", Notes: "Used for internal tests", Contents: tidbMockTemplate, }, } AllTemplates = AllTemplateCollection{ "mock": MockTemplates, "single": SingleTemplates, "tidb": TidbTemplates, "multiple": MultipleTemplates, "replication": ReplicationTemplates, "group": GroupTemplates, } )
View Source
var ( GroupTemplates = TemplateCollection{ "init_nodes_template": TemplateDesc{ Description: "Initialize group replication after deployment", Notes: "", Contents: initNodesTemplate, }, "check_nodes_template": TemplateDesc{ Description: "Checks the status of group replication", Notes: "", Contents: checkNodesTemplate, }, } )
View Source
var ( MultipleTemplates = TemplateCollection{ "start_multi_template": TemplateDesc{ Description: "Starts all nodes (with optional mysqld arguments)", Notes: "", Contents: startMultiTemplate, }, "restart_multi_template": TemplateDesc{ Description: "Restarts all nodes (with optional mysqld arguments)", Notes: "", Contents: restartMultiTemplate, }, "use_multi_template": TemplateDesc{ Description: "Runs the same SQL query in all nodes", Notes: "", Contents: useMultiTemplate, }, "stop_multi_template": TemplateDesc{ Description: "Stops all nodes", Notes: "", Contents: stopMultiTemplate, }, "send_kill_multi_template": TemplateDesc{ Description: "Sends kill signal to all nodes", Notes: "", Contents: sendKillMultiTemplate, }, "clear_multi_template": TemplateDesc{ Description: "Removes data from all nodes", Notes: "", Contents: clearMultiTemplate, }, "status_multi_template": TemplateDesc{ Description: "Shows status for all nodes", Notes: "", Contents: statusMultiTemplate, }, "test_sb_multi_template": TemplateDesc{ Description: "Run sb test on all nodes", Notes: "", Contents: testSbMultiTemplate, }, "node_template": TemplateDesc{ Description: "Runs the MySQL client for a given node", Notes: "", Contents: nodeTemplate, }, } )
View Source
var ( ReplicationTemplates = TemplateCollection{ "init_slaves_template": TemplateDesc{ Description: "Initialize slaves after deployment", Notes: "Can also be run after calling './clear_all'", Contents: initSlavesTemplate, }, "semi_sync_start_template": TemplateDesc{ Description: "Starts semi synch replication ", Notes: "", Contents: semiSyncStartTemplate, }, "start_all_template": TemplateDesc{ Description: "Starts nodes in replication order (with optional mysqld arguments)", Notes: "", Contents: startAllTemplate, }, "restart_all_template": TemplateDesc{ Description: "stops all nodes and restarts them (with optional mysqld arguments)", Notes: "", Contents: restartAllTemplate, }, "use_all_template": TemplateDesc{ Description: "Execute a query for all nodes", Notes: "", Contents: useAllTemplate, }, "use_all_slaves_template": TemplateDesc{ Description: "Execute a query for all slaves", Notes: "master-slave topology", Contents: useAllSlavesTemplate, }, "use_all_masters_template": TemplateDesc{ Description: "Execute a query for all masters", Notes: "master-slave topology", Contents: useAllMastersTemplate, }, "stop_all_template": TemplateDesc{ Description: "Stops all nodes in reverse replication order", Notes: "", Contents: stopAllTemplate, }, "send_kill_all_template": TemplateDesc{ Description: "Send kill signal to all nodes", Notes: "", Contents: sendKillAllTemplate, }, "clear_all_template": TemplateDesc{ Description: "Remove data from all nodes", Notes: "", Contents: clearAllTemplate, }, "status_all_template": TemplateDesc{ Description: "Show status of all nodes", Notes: "", Contents: statusAllTemplate, }, "test_sb_all_template": TemplateDesc{ Description: "Run sb test on all nodes", Notes: "", Contents: testSbAllTemplate, }, "test_replication_template": TemplateDesc{ Description: "Tests replication flow", Notes: "", Contents: testReplicationTemplate, }, "check_slaves_template": TemplateDesc{ Description: "Checks replication status in master and slaves", Notes: "", Contents: checkSlavesTemplate, }, "master_template": TemplateDesc{ Description: "Runs the MySQL client for the master", Notes: "", Contents: masterTemplate, }, "slave_template": TemplateDesc{ Description: "Runs the MySQL client for a slave", Notes: "", Contents: slaveTemplate, }, "multi_source_template": TemplateDesc{ Description: "Initializes nodes for multi-source replication", Notes: "fan-in and all-masters", Contents: multiSourceTemplate, }, "multi_source_use_slaves_template": TemplateDesc{ Description: "Runs a query for all slave nodes", Notes: "group replication and multi-source topologies", Contents: multiSourceUseSlavesTemplate, }, "multi_source_use_masters_template": TemplateDesc{ Description: "Runs a query for all master nodes", Notes: "group replication and multi-source topologies", Contents: multiSourceUseMastersTemplate, }, "multi_source_test_template": TemplateDesc{ Description: "Test replication flow for multi-source replication", Notes: "fan-in and all-masters", Contents: multiSourceTestTemplate, }, "check_multi_source_template": TemplateDesc{ Description: "checks replication status for multi-source replication", Notes: "fan-in and all-masters", Contents: checkMultiSourceTemplate, }, } )
View Source
var TidbTemplates = TemplateCollection{ "tidb_init_db_template": TemplateDesc{ Description: "Initialization template for the TiDB server", Notes: "This should normally run only once", Contents: tidbInitTemplate, }, "tidb_my_cnf_template": TemplateDesc{ Description: "Default options file for a TiDB sandbox", Notes: "", Contents: tidbMyCnfTemplate, }, "tidb_start_template": TemplateDesc{ Description: "Stops a database in a single TiDB sandbox", Notes: "", Contents: tidbStartTemplate, }, "tidb_stop_template": TemplateDesc{ Description: "Stops a database in a single TiDB sandbox", Notes: "", Contents: tidbStopTemplate, }, "tidb_send_kill_template": TemplateDesc{ Description: "Sends a kill signal to the TiDB database", Notes: "", Contents: tidbSendKillTemplate, }, "tidb_grants_template5x": TemplateDesc{ Description: "Grants for TiDB sandboxes", Notes: "", Contents: tidbGrantsTemplate, }, "tidb_after_start_template": TemplateDesc{ Description: "commands to run after the database started", Notes: "This script does nothing. You can change it and reuse through --use-template", Contents: tidbAfterStartTemplate, }, }
Every template in this collection will replace the corresponding one in SingleTemplates when the flavor is "tidb"
Functions ¶
func CreateAllMastersReplication ¶
func CreateAllMastersReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
func CreateChildSandbox ¶
func CreateChildSandbox(sandboxDef SandboxDef) (execList []concurrent.ExecutionList, err error)
func CreateFanInReplication ¶
func CreateFanInReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp, masterList, slaveList string) error
func CreateGroupReplication ¶
func CreateGroupReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
func CreateMasterSlaveReplication ¶
func CreateMasterSlaveReplication(sandboxDef SandboxDef, origin string, nodes int, masterIp string) error
func CreateMultipleSandbox ¶
func CreateStandaloneSandbox ¶
func CreateStandaloneSandbox(sandboxDef SandboxDef) (err error)
func RemoveSandbox ¶
func RemoveSandbox(sandboxDir, sandbox string, runConcurrently bool) (execList []concurrent.ExecutionList, err error)
Types ¶
type AllTemplateCollection ¶
type AllTemplateCollection map[string]TemplateCollection
type MockFileSet ¶ added in v1.19.0
type MockFileSet struct {
// contains filtered or unexported fields
}
func MySQLMockSet ¶ added in v1.19.0
func MySQLMockSet(debug bool) []MockFileSet
type SandboxDef ¶
type SandboxDef struct { DirName string // Name of the directory containing the sandbox SBType string // Type of sandbox (single, multiple, replication-node, group-node) Multi bool // Either single or part of a multiple sandbox NodeNum int // In multiple sandboxes, which node is this Version string // MySQL version Basedir string // Where to get binaries from (e.g. $HOME/opt/mysql/8.0.11) ClientBasedir string // Where to get client binaries from (e.g. $HOME/opt/mysql/8.0.15) BasedirName string // The bare name of the directory containing the binaries (e.g. 8.0.11) SandboxDir string // Target directory for sandboxes LoadGrants bool // Should we load grants? SkipReportHost bool // Do not add report-host to my.sandbox.cnf SkipReportPort bool // Do not add report-port to my.sandbox.cnf SkipStart bool // Do not start the server after deployment InstalledPorts []int // Which ports should be skipped in port assignment for this SB Port int // Port assigned to this sandbox MysqlXPort int // XPlugin port for this sandbox UserPort int // Custom port provided by user BasePort int // Base port for calculating more ports in multiple SB MorePorts []int // Additional ports that belong to this sandbox Prompt string // Prompt to use in "mysql" client DbUser string // Database user name RplUser string // Replication user name DbPassword string // Database password RplPassword string // Replication password RemoteAccess string // What access have the users created for this SB (127.%) BindAddress string // Bind address for this sandbox (127.0.0.1) CustomMysqld string // Use an alternative mysqld executable ServerId int // Server ID (for replication) ReplOptions string // Replication options, as string to append to my.sandbox.cnf GtidOptions string // Options needed for GTID ReplCrashSafeOptions string // Options needed for Replication crash safe SemiSyncOptions string // Options for semi-synchronous replication ReadOnlyOptions string // Options for read-only passed to child sandboxes InitOptions []string // Options to be added to the initialization command MyCnfOptions []string // Options to be added to my.sandbox.cnf PreGrantsSql []string // SQL statements to execute before grants assignment PreGrantsSqlFile string // SQL file to load before grants assignment PostGrantsSql []string // SQL statements to run after grants assignment PostGrantsSqlFile string // SQL file to load after grants assignment MyCnfFile string // options file to merge with the SB my.sandbox.cnf HistoryDir string // Where to store the MySQL client history LogFileName string // Where to log operations for this sandbox Flavor string // The flavor of the binaries (MySQL, Percona, NDB, etc) SlavesReadOnly bool // Whether slaves will set the read_only flag SlavesSuperReadOnly bool // Whether slaves will set the super_read_only flag Logger *defaults.Logger // Carries a logger across sandboxes InitGeneralLog bool // Enable general log during server initialization EnableGeneralLog bool // Enable general log for regular usage NativeAuthPlugin bool // Use the native password plugin for MySQL 8.0.4+ DisableMysqlX bool // Disable Xplugin (MySQL 8.0.11+) EnableMysqlX bool // Enable Xplugin (MySQL 5.7.12+) KeepUuid bool // Do not change UUID SinglePrimary bool // Use single primary for group replication Force bool // Overwrite an existing sandbox with same target ExposeDdTables bool // Show hidden data dictionary tables (MySQL 8.0.0+) RunConcurrently bool // Run multiple sandbox creation concurrently }
type ScriptBatch ¶
type ScriptBatch struct {
// contains filtered or unexported fields
}
type TemplateCollection ¶
type TemplateCollection map[string]TemplateDesc
Click to show internal directories.
Click to hide internal directories.