Openstack / Migrate Server To Different Host
Migrate Server To Different Host
Migrates a server to a different host, either live or block migration.
openstack server migrate --live <host_hostname> --shared-migration --wait <instance_id> openstack server migrate --live <host_hostname> --shared-migration --wait <instance_id> #!/bin/bash
# Migrate Server To Different Host
openstack server migrate --live {{host_hostname}} {{--shared-migration|--block-migration}} --wait {{instance_id}} import subprocess
# Migrate Server To Different Host
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"openstack",
"server",
"migrate",
"--live",
"<host_hostname>",
"--shared-migration",
"--wait",
"<instance_id>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: openstack not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
During a network maintenance window when live migration is needed to minimize downtime.
Pro Tip
Use `--shared-migration` if your shared storage is properly configured; otherwise, opt for `--block-migration` to avoid I/O errors.
Command Builder
Tune the command before you copy it
openstack server migrate --live <host_hostname> --shared-migration --wait <instance_id> Anatomy of Output
Understanding the result
Starting live migration of instance 1234-5678-90ab-cdef to host hostname.example.com Migration Status Indicates the beginning of the migration process.
MIGRATE: live migration completed successfully Completion Notice Confirms the successful completion of the migration.
Instance now running on hostname.example.com Current Status Verifies the current host of the instance.
Troubleshooting
Common pitfalls
Error: Migration failed: Connection to destination host lost.
Solution: Check network connectivity and ensure destination host is accessible.
Error: Instance cannot be migrated due to disk I/O error.
Solution: Verify shared storage configuration or switch to block migration.
Error: Destination host not suitable for migration.
Solution: Ensure the destination host has adequate resources and compatibility.
Command Breakdown
What each part is doing
-
openstack - Base Command
- The executable that performs this operation. Here it runs Openstack before the shell applies any redirect operators.
-
<host_hostname> - host hostname
- The host or server name supplied to this command.
-
--shared-migration - shared migration| block migration
- The value supplied for shared migration| block migration.
-
<instance_id> - instance id
- The value supplied for instance id.
-
--live - Command Option
- Tool-specific option used by this command invocation.
-
--shared-migration - Command Option
- Tool-specific option used by this command invocation.
-
--wait - Command Option
- Tool-specific option used by this command invocation.
Alternative Approaches
Comparable commands in other tools
Alternative cloud infrastructure tools for the same job.
gcloud compute ssh <user>@<instance> Flyctl / View Status Of Specific Application flyctl status --app <app_name> Aws / Delete Eks Cluster 1608 aws eks delete-cluster --name <cluster_name> Gh / Create Codespace Github Interactively gh cs create Cradle / Submit Elasticsearch Schema cradle elastic map