MysqlManage

class playback.mysql_manage.MysqlManage(user='ubuntu', hosts=None, key_filename=None, password=None, parallel=True, *args, **kwargs)

Bases: playback.common.Common

Manage Galera Cluster for MySQL

Parameters:
  • user(str) – the user for remote server to login
  • hosts(list) – this is a second param
  • key_filename(str) – the ssh private key to used, default None
  • password(str) – the password for remote server
  • parallel(bool) – paralleler execute on remote server, default True
Returns:

None

Examples:
# create two mysql instances
mysql1 = MysqlManage(user='ubuntu', hosts=['controller1'])
mysql2 = MysqlManage(user='ubuntu', hosts=['controller2'])

# bootstrap the first cluster node
mysql1.start_wsrep_new_cluster()

# start the second cluster node
mysql2.start_mysql()

# change the mysql root password
mysql1.change_root_password('changeme')

# show the cluster status
mysql1.show_cluster_status('changeme')
change_root_password(*args, **kwargs)

Change the mysql root password

Parameters:pwd – the new password of root user
Returns:None
show_cluster_status(*args, **kwargs)

Display the cluster status

Parameters:root_db_pass – the password of mysql root user
Returns:None
start_mysql()

Start the database server to join the cluster

Returns:None
start_wsrep_new_cluster()

Initialize the primary component on one cluster node

Returns:None
stop_mysql()

Stop the mysql service

Returns:None