Open MaxFedotov opened 6 years ago
@shlomi-noach Hi Shlomi. Can you please take a look at this draft? Want to know your opinion and maybe some comments\critics before starting to implement it
What about the CLONE command added in 8.0.17? It seems this could greatly simplify orchestrator's slave provisioning even making it possible without the use of orchestrator-agent at all?
Any updates on this? Would love to see said seed options being implemented.
DeleteDirContents
, which we will use later in order to remove mysql datadir contents and for/api/delete-mysql-backupdir
and/api/delete-mysql-datadir
/api/delete-mysql-backupdir
, which we will use later in order to delete backups after seed will be completed./api/delete-mysql-datadir
from using command from config to DeleteDirContents/api/mysql-backupdir-available-space
Will be used in pre-seed checks. Create new API on agent, add backupDirAvailiable space to type Agent struct/api/available-seed-methods
Agent need to provide information about available seed methods – this depends on binaries we have installed on it. Right now we will support LVM, xtrabackup, xtrabackup-stream, mydumper and mysqldump. Create new API on agent, add seedMethods to type Agent struct/api/mysql-info
Agent need to provide information about MySQL version, MySQL datadir location, if this server is already slave (has output fromSHOW SLAVE STATUS
command, will fail if our targetHost is already a slave), if this server is already master (SHOW SLAVE HOSTS
command, will fail is our targetHost is already a master), if it has currently active connections to MySQL(SELECT COUNT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER NOT IN (‘MySQLUser’, ‘other_system_users’)
, will fail if number of active connections to targetHost is larger than some thresold) We will use it in pre-seed check on targetHost and SourceHost. Create new API on agent, new type MySQLInfo struct and add type MySQLInfo struct to type Agent struct/api/mysql-databases
Agent need to provide information about databases, engines and db sizes, which present on server. We need this because:du database_folder
) - we will need it for partial xtrabackup in order to check if there is enough space in backup directory on sourceHost and in backup directory\data directory on targetHost{"MySQLDatabases":{"employees":{"Engines":["InnoDB"],"PhysicalSize":186929946,"LogicalSize":112157967},"log":{"Engines":["InnoDB"],"PhysicalSize":32307770,"LogicalSize":19384662},"test":{"Engines":["InnoDB","MyISAM"],"PhysicalSize":116501,"LogicalSize":69900},"test2":{"Engines":["InnoDB"],"PhysicalSize":106921,"LogicalSize":64152}},"InnoDBLogSize":100663296}
MySQLTopologyUser
andMySQLTopologyPassword
for agent configMySQLBackupDir
- path where we will store backupsSeedPort
- port we will use in order to stream xtrabackup and copy dataMySQLReplicationUser
- user that will be used for replicationMySQLReplicationPassword
- password for MySQLReplicationUserMySQLBackupUsersOnTargetHost
. When we perform partial backup, we also need to backup system databases. If MySQLBackupUsersOnTargetHost is empty, before restoring backup on targetHost we will first backup mysql database on it and restore after seed operation completes. IfMySQLBackupUsersOnTargetHost
is set, we will backup only these users and restore them after seed operation completesagent-seed/:targetHost/:sourceHost/:seedMethod/:streamToDatadir/:optionalListOfDatabases
/api/start-local-backup/:seedId/:seedMethod/:optionalListOfDatabases
Will be used on sourceHost to:/api/receive-backup/:seedId/:seedMethod/:backupFolder
(backupFolder must be url encoded)/api/send-local-backup/:seedId/:targetHost/:backupFolder
will be used on sourceHost to tar.gz contents of backup folder and send archive to targetHost on SeedPort port using netcat/api/start-streaming-backup/:seedId/:targetHost/:optionalListOfDatabases
Will be used to start xtrabackup stream and send it using netcat to targetHost onSeedPort
. -- Check that replication user exists on sourceHost. If it not exists - create it and GRANT REPLICATION SLAVE ON . TO it/api/start-restore/:seedId/:seedMethod/:sourceHost/:sourcePort/:backupFolder/:optionalListOfDatabases
will be used on targetHost to:backupFolder
-- create replication user -- executeSTART SLAVE
myloader
with nessesary params -- create replication user -- parsemetadata
file in MySQLBackupDir and executeCHANGE MASTER TO
andSTART SLAVE
(2 different cases for GTID and positional replicas – will create separate function for this)optionalListOfDatabases
is empty,backupFolder
!=config.Config.MySQLDatadir
,seedMethod
xtrabackup or xtrabackup-stream): -- runxtrabackup –-prepare
on copied backup inbackupFolder
-- stop MySQL -- remove everything fromconfig.Config.MySQLDatadir
-- remove ib_logfiles from innodb_log_group_home_dir -- runxtrabackup –-copy-back -–target-dir=backupdir
(or may be use --move-back??) -- start MySQL -- parsextrabackup_binlog_info
in MySQL datadir and executeCHANGE MASTER TO
andSTART SLAVE
optionalListOfDatabases
is not empty,backupFolder
!=config.Config.MySQLDatadir
,seedMethod
xtrabackup or xtrabackup-stream): -- runxtrabackup –-prepare
on copied backup inbackupFolder
-- stop MySQL -- remove everything fromconfig.Config.MySQLDatadir
-- remove ib_logfiles from innodb_log_group_home_dir -- runxtrabackup –-copy-back -–target-dir=backupdir
-- start MySQL -- if partial backup - runmysql_update
to restore system databases -- create replication user -- parsextrabackup_binlog_info
in MySQL datadir and executeCHANGE MASTER TO
andSTART SLAVE
optionalListOfDatabases
is empty,backupFolder
=config.Config.MySQLDatadir
,seedMethod
xtrabackup-stream): -- runxtrabackup –-prepare
on config.Config.MySQLDatadir -- start MySQL -- parsextrabackup_binlog_info
in MySQL datadir and executeCHANGE MASTER TO
andSTART SLAVE
optionalListOfDatabases
is not empty,backupFolder
=config.Config.MySQLDatadir
,seedMethod
xtrabackup-stream): -- runxtrabackup –-prepare
on config.Config.MySQLDatadir -- start MySQL -- runmysql_update
to restore system databases -- create replication user -- parsextrabackup_binlog_info
in MySQL datadir and executeCHANGE MASTER TO
andSTART SLAVE
/api/cleanup/:seedId
Will be used on targetHost and sourceHost in order to remove contents ofconfig.Config.MySQLBackupdir
after seed processAll this changes are completely Backward compatible (except that for now we will need to add “lvm” param as seedMethod when we use “Seed” button on an agent page in Snapshots area) and won’t affect current agent and orchestrator workflow.
In order to support this new seed methods, we can reuse part of the logic of current executeSeed function - divide backup\restore flow into finite operations and use UpdateSeedStateEntry function in order to track progress.
As a some type of draft, I suppose following scenarios for new seed methods:
Basic checks for all types of seed methods:
Draft for mysqldump/mydumper/xtrabackup:
agent-seed/:targetHost/:sourceHost/:seedMethod/:streamToDatadir/:optionalListOfDatabases
(:streamToDatadir = false)optionalListOfDatabases
is empty) – calculate backup size as a size of MySQL datadir (use agent API/api/mysql-du
) + some space for ib_logfile which will be created duringxtrabackup --prepare
-- [XTRABACKUP PARTIAL] calculate backup size as a sum of physicalSize of needed databases + some space for ib_logfile which will be created duringxtrabackup --prepare
optionalListOfDatabases
is empty) calculate it as a size of MySQL datadir (use agent API/api/mysql-du
) + some space for ib_logfile which will be created duringxtrabackup --prepare
/api/start-local-backup/:seedId/:seedMethod/:optionalListOfDatabases
. This API call will return path to directory with backup/api/receive-backup/:seedId/:seedMethod/:backupFolder
. If:streamToDatadir = true
than useAgent.MySQLInfo.MySQLDatadirPath
as:backupFolder
, else use path returned from/api/start-local-backup/:seedId/:seedMethod/:optionalListOfDatabases
/api/send-local-backup/:seedId/:targetHost/:backupFolder
/api/start-restore/:seedId/:seedMethod/:sourceHost/:sourcePort/:backupFolder/:optionalListOfDatabases
. If:streamToDatadir = true
than useAgent.MySQLInfo.MySQLDatadirPath
as:backupFolder
, else use path returned from/api/start-local-backup/:seedId/:seedMethod/:optionalListOfDatabases
/api/cleanup/:seedId
on sourceHost/api/cleanup/:seedId
on targetHostDraft for xtrabackup-stream:
agent-seed/:targetHost/:sourceHost/:seedMethod/:streamToDatadir/:optionalListOfDatabases
optionalListOfDatabases
is empty) – calculate backup size as a size of MySQL datadir (use agent API/api/mysql-du
) + some space for ib_logfile which will be created duringxtrabackup --prepare
-- [XTRABACKUP PARTIAL] calculate backup size as a sum of physicalSize of needed databases + some space for ib_logfile which will be created duringxtrabackup --prepare
optionalListOfDatabases
is empty) calculate it as a size of MySQL datadir (use agent API/api/mysql-du
) + some space for ib_logfile which will be created duringxtrabackup --prepare
/api/receive-backup/:seedId/:seedMethod/:backupFolder
. If:streamToDatadir = true
than useAgent.MySQLInfo.MySQLDatadirPath
as:backupFolder
, else useAgent.MySQLInfo.MySQLBackupdirPath\generate_new_folder_name
/api/start-streaming-backup/:optionalListOfDatabases
/api/start-restore/:seedId/:seedMethod/:sourceHost/:sourcePort/:backupFolder/:optionalListOfDatabases
. If:streamToDatadir = true
than useAgent.MySQLInfo.MySQLDatadirPath
as:backupFolder
, else useAgent.MySQLInfo.MySQLBackupdirPath\generate_new_folder_name
/api/cleanup/:seedId
on sourceHost/api/cleanup/:seedId
on targetHostAlso we will need to add these methods to agents page in orchestrator UI, but that’s the thing that I need to research a bit, because I’m not good at all in all this frontend-developers stuff :)
Do not forget to set 700 permissions for orchestrator-agent.conf.json in order to secure passwords