Jump to content

MariaDB/Clone a host

From Wikitech

Derived from MariaDB/Provisioning a host

Good to know before starting

Please be sure to be aware of the following page(s):

Host preparation

Here is an overview of what a host depends on:

arrow hell

Move the host in the right groups with the right role

Only required if the host is new or it is changing its section
  1. In manifests/site.pp:
    1. Add the DBNAME to the appropriate regexps
    2. Remove the insetup role from DBNAME
  2. In hieradata/hosts/$destination_host.yaml add the configuration content of hieradata/hosts/$source_host.yaml . You can check this example if needed.
  3. If the host is new, you'll have to run puppet on the host before running the cookbook below.

Add the host to dbctl config (example)

Only required if the host is new

In conftool-data/dbconfig-instance/instances.yaml add - DBNAME in the appropriate location and then run dbctl commit command on cumin

  • Merge the change to puppet and then puppet-merge on the Puppet master
  • Check that the new host is present in dbctl using dbctl instance <DBNAME> get
  • Edit the instance's config using dbctl instance <DBNAME> edit
  • Commit the change using dbctl config commit -m <commit_message>

Cloning

The sre.mysql.clone cookbook will:

  • Ensure the new host is configured in dbctl and puppet
  • Depool the source and target servers
  • Disable icinga monitoring for the target
  • Clone the source to target
  • Wait for replication and icinga monitoring to normalize
  • Pool-in the servers (default)
  • Add the new host to zarcillo

See --help for more and try --dry-run on first use.

Clone via the sre.mysql.clone cookbook in a tmux/screen:

sudo cookbook sre.mysql.clone --source <source_fqdn> --target <destination_fqdn> --task <task_id>

Example: db1190 will be recloned from db1180 and will be configured to replicate from db1173.eqiad.wmnet

sudo cookbook sre.mysql.clone --source db1180.eqiad.wmnet --target db1190.eqiad.wmnet --task T1234

Monitor the run output

After a few days of uptime

If required (i.e. upon decomissionning) and if everything works properly, we can now depool our old host (from any cumin host):

sudo cookbook sre.mysql.depool -t $TASKID -r "Decommissioning $HOST" $HOST 

We will also repool the new host (from any cumin host):

sudo cookbook sre.mysql.pool -t $TASKID -r "Pooling $HOST after cloning" $HOST