Scenario
In offline environments, many users use OpenStack to build cloud environments. In order to reduce costs, some users choose to migrate their offline OpenStack environments to cloud service providers. In this scenario, the cloud servers that simulate the OpenStack offline environment are migrated to eSurfing Cloud, and the services provided by eSurfing Cloud are used to improve resource O&M management capabilities and reduce costs.
Architecture migration illustration:
Procedure
In this section, we will use VMWare to build a local OpenStack environment to simulate the migration and import process.
The simulated environment is as follows:
· OS: CentOS Linux release 7.9.2009
· VMWare Workstation:16.1.0
· The simulation process consists of the following steps:
· Install the OpenStack environment
· Create a cloud server
· Export the cloud server
· Import eSurfing Cloud
· Create a cloud server (eSurfing Cloud environment)
Install the OpenStack environment.
OpenStack is able to create cloud server and we need to guarantee that the following requirements are met:
(1) CPU supports virtualization
(2) At least 8GB of RAM
Step 1: Check if the CPU supports virtualization
Download LeoMoon CPU-V and double-click to open it.
Step 2: If the result is as shown in the figure below, it indicates that virtualization is supported.
Step 3: Install OpenStack (all-in-one) on the VM.
This time, we use PackStack to automatically install the Rocky version, and the preparations are as follows:
1) Execute the following command to disable NetworkManager and configure a static IP.
systemctl stop NetworkManager && systemctl disable NetworkManager
vim /etc/sysconfig/network-scripts/ifcfg-ens33
Modify the IP in the configuration file as shown below and save it.
2) Execute the following command to modify the host name.
hostname set-hostname controller
3) As shown in the figure below, write the host name and IP mapping into hosts.
4) Execute the following command to disable firewalld.
hostname set-hostname controller
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
5) Modify the selinux configuration file and set SELINUX to disabled.
6) Execute the following command to configure the yum source.
[root@controller yum.repos.d(keystone_admin)]# cat CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
[root@controller yum.repos.d(keystone_admin)]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
#baseurl=http://download.example/pub/epel/7/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[root@controller yum.repos.d(keystone_admin)]# cat CentOS-OpenStack-rocky.repo
[centotack-rocky]
name=openstack-rocky
baseurl=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-rocky/
enabled=1
gpgcheck=0
[qume-kvm]
name=qemu-kvm
baseurl= https://mirrors.aliyun.com/centos/7/virt/x86_64/kvm-common/
enabled=1
gpgcheck=0
7) Execute the following command to install PackStack.
#Install leatherman
yum -y install leatherman
#Install packstack
yum -y install openstack-utils openstack-packstack
8) Execute the following command to generate an answer file and edit the configuration file.
packstack --gen-answer-file=/root/openstack.ini
vim openstack.ini
#Except for modifying the items listed below, all other items remain unchanged (password field can be modified as needed, all of which are configured as 123456)
CONFIG_DEFAULT_PASSWORD=123456
CONFIG_AODH_INSTALL=n
CONFIG_MARIADB_USER=root
CONFIG_MARIADB_PW=123456
CONFIG_KEYSTONE_DB_PW=123456
CONFIG_KEYSTONE_ADMIN_EMAIL=root@localhost
CONFIG_KEYSTONE_ADMIN_USERNAME=admin
CONFIG_KEYSTONE_ADMIN_PW=123456
CONFIG_NEUTRON_ML2_TYPE_DRIVERS=vxlan,flat
CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES=vxlan
CONFIG_NEUTRON_ML2_MECHANISM_DRIVERS=openvswitch
CONFIG_NEUTRON_L2_AGENT=openvswitch
CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=extnet:br-ex
CONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-ex:eth0
CONFIG_NEUTRON_OVS_EXTERNAL_PHYSNET=extnet
CONFIG_PROVISION_DEMO=n
9) Execute the following command to install via the answer file.
packstack --answer-file=/root/openstack.ini
10) Open the browser, enter http://IP, in this example, http://192.168.43.128/, and log in to the OpenStack management page.
11) Execute the following command to import the image.
openstack image create "centos" --file centos.img --disk-format qcow2 --container-format bare --public
12) Execute the following command to create the network.
openstack create net vnet
openstack network create --provider-network-type=flat --provider-physical-network=extnet --external --share ext_net
13) Execute the following command to create the subnet.
openstack subnet create subnet1 --network int --subnet-range 172.16.1.0/24 --gateway 172.16.1.1
openstack subnet create ex --network ext_net --gateway 192.168.101.254 --allocation-pool start=192.168.101.200,end=192.168.101.205 --subnet-range 192.168.101.0/24
14) Execute the following command to create the route.
openstack router create route
openstack router add subnet route ex
openstack router add subnet route subnet1
15) Execute the following command to create the specification.
openstack flavor create --vcpus 1 --ram 512 --disk 10 test1
16) Execute the following command to create the key.
openstack keypair create cy
17) Execute the following command to create the VM.
openstack server create --flavor test1 --image centos --nic net-id=cc9d7710-d82e-4109-9412-56ae02a18d7d --security-group default --key-name cy test
18) Execute the following commands to connect to the VM and upload the qemu-ga, cloudinit, and virtio components.
The download path can be found on the Image Service > Private Image > Create Private Image page.
Follow the instructions to install and shut down the VM.
19) Execute the following command to convert the cloud server to image.
openstack server image create 1b1d3411-b755-4980-9da6-db01d8331600 --name cytestimg
20) Execute the following command to save the image locally (in raw format).
openstack server image create 1b1d3411-b755-4980-9da6-db01d8331600 --name cytestimg
21) Execute the following command to convert the image to qcow2 format (to prevent the image from being too large to upload to the bucket).
qemu-img convert -f raw -o qcow2 cytestimg centos.qcow2
22) Upload the image to eSurfing Cloud.
Go to OSS (Native Version), create a bucket and then upload the image to the bucket (larger images are recommended to be uploaded via OSS API).
23) Create a private image.
Go to Image Service > Private Image > Create Private Image, select the image file, fill in the address of the object, and convert it to a private image.
The address can be copied from the OSS console under More > Copy URL.
24) After successful creation, select Elastic Cloud Server > Create Cloud Server and select a private image in the image section. After creation, you can enter the cloud server to check the data integrity.