In this blog post about vCloud Director Linux migration SQL DB to embedded PostgreSQL appliance – Part I, I will migrate vCD DB from an external SQL DB to embedded PostgreSQL DB and upgrade a Linux vCloud Director(vCD) to 10.x after I migrate this Linux vCD to a vCloud Director appliance.
Since I need to migrate and upgrade some of the vCloud Director we have in production, I build a PoC with the same Infrastructure to do all the migrations and upgrades and make sure all works ok without any issues before I do it in some of our productions vCloud Director.
This is the source environment:
- Linux CentOs 7
- vCloud Director 9.7
- SQL Server 2017
- vCenter / vSphere 6.7
- NSX-V 6.4.8
Destination source environment(after upgrade and migration):
- vCloud Director 10.x Appliance
- vCenter / vSphere 6.7
- NSX-V 6.4.8
The final plan is to upgrade the vCD to version 10.x and migrate the SQL DB to a vCD Appliance with embedded PostgresSQL.
This task needs to be done in parts since we have a vCD in a Linux machine and an external DB.
- Install PostgreSQL Linux vCD
- Migrate SQL DB to PostgreSQL Linux
- Upgrade vCD 9.7 to vCD 10.x
- Create a new vCD 10.x Appliance
- Migrate external DB to an embedded database
- Copy data and certificates data
The above tasks need to be done in parts and also the blog posts for each part.
So that this blog post is not too big, I will divide this article into two blog posts.
- vCloud Director Linux migration SQL DB to embedded PostgreSQL appliance – Part I
1. Install PostgreSQL Linux vCD
2. Migrate SQL DB to PostgreSQL Linux
3. Upgrade vCD 9.7 to vCD 10.x
- vCloud Director Linux migrationSQL DB to embedded PostgreSQL appliance – Part II
4. Create a new vCD 10.x Appliance
5. Migrate external DB to an embedded database
6. Copy data and certificates data
migration
Note: You don’t need to install in the vCD Linux. You can install it on any Linux server that you may have.
Important note: Always do a backup of all your systems(SQL Server DB, vCloud Director, PostgreSQL, NSX-V, etc.) before starting this process.
1. Install PostgreSQL Linux vCD
I will not go into much detail about how to install PostgreSQL into Linux CentOS 7. I will add the main commands to install the PostgreSQL.
Add PostgreSQL Yum Repository to CentOS 7:
1 2 3 |
$ sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm |
Check all packages:
1 2 3 |
$ sudo yum list postgresql*-server |
1 2 3 |
$ sudo yum install postgresql10-server |
Change Postgres user password.
1 2 3 |
$ Passwd postgres |
After PostgreSQL is installed, Initialize and start database service DB.
1 2 3 |
$ /usr/pgsql-10/bin/postgresql-10-setup initdb |
Enable and Start PostgreSQL
1 2 3 |
$ sudo systemctl start postgresql-10 |
1 2 3 |
$ sudo systemctl enable postgresql-10 |
Open firewall for your new PostgreSQL:
1 2 3 4 |
$ sudo firewall-cmd --add-service=postgresql --permanent $ sudo firewall-cmd --reload |
Or disable your CentOS firewall:
Note: It is not recommended we disable our firewall in a production environment. Only use if you have issues when trying to migrate the SQL DB to the installed PostgreSQL.
Since we need to do this for the migration between SQL DB and PostgreSQL, you can temporarily do it. If this task does not go against your company security policy, you should not use it.
1 2 3 |
$ sudo systemctl stop firewall |
1 2 3 |
$ sudo systemctl disable firewalld |
Run the next command to prevent the firewall from starting by other services.
1 2 3 |
$ sudo systemctl mask --now firewalld |
Change PostgreSQL remote access so that it is possible to connect to your DB outside of this Linux Server.
Login to Postgres user and DB and change password in Postgres user password.
1 2 3 4 5 6 |
$ sudo -i -u postgres $ psql $ \password $ \q |
(use the same password used for Linux Postgres user)
Now we are ready to create our vCD PostgreSQL DB to migrate from SQL Server.
For this task, I used my pgAdmin tool to launch all vCD DB commands easily. New query and run the following commands:
1 2 3 4 5 6 7 |
CREATE DATABASE vcloud; create user vcloud; alter user vcloud password 'ADDYOURPASSWORD'; alter role vcloud with login; grant all privileges on database vcloud to vcloud; |
In the PostgreSQL command line, just login and run psql and launch each command line.
With this last part, we are done installing PostgreSQL DB and ready to start vCD DB migration from SQL Server DB to our new PostgreSQL DB.
2. Migrate SQL DB to PostgreSQL Linux
The DB migration is a simple process.
Note: Before start, do a snapshot of your VMs
First, stop vcd services.
1 2 3 |
$ service vmware-vcd stop |
Second, run the cell migrating tool (use the settings created in the previous task).
1 2 3 4 |
$ cell-management-tool dbmigrate -dbhost "destinationDBIP" -dbport 5432 -dbuser "destinationDB" -dbname vcloud -dbpassword "vcloud user password‘ --private-key-path /vcloud/.ssh/id_rsa |
Note: If you do not include the “–private-key-path /vcloud/.ssh/id_rsa” option, after the migration finishes, you can connect the cells to the target database by running the reconfigure-database subcommand on each cell in the server group.
Error 01.
On my first try, I had an error: vcloud owner– Error executing command: java.lang.IllegalStateException: Task Refresh database views failed
Checking my settings, I notice that my new PostgreSQL DB had the wrong owner. Since I use pgAdmin and the default user is postgres, the DB creating did use the same user, instead of vcloud user.
I change the owner to the right user, rerun the migration tool and get a second error.
Error 02.
–Error executing command: java.lang.IllegalStateException: Error populating the temporary rights_implications table.ERROR: relation “rights_implications” does not exist
For this one, I needed to Google it and found a similar one in VMware KB.
Even is not the same process, but is close enough. And according to the VMware KB, this type of error is because when you try to upgrade more than one attempt, we need to rollback the process and try again.
Since this is not an upgrade and we cannot rollback, the best option here is to delete the vcloud DB in the PostgreSQL and recreate a new DB and restart the process.
After fixing the last error and recreate the PostgreSQL DB, I rerun the vCD migration tool.
This time all finish without any error, except one with “Error executing command: null”.
Checking the logs, I don’t see anything about this, so I think it may be the –private-key-path used. So for the save side, I decided to run the command reconfigure-database.
1 2 3 |
$ /opt/vmware/vcloud-director/bin/cell-management-tool reconfigure-database |
Running the reconfiguration command I get: “Current database connection parameters are the same as those supplied. Exiting now.”, It means all the DB settings are correct.
Next, I stop the SQL Server DB and restart vCD services.
1 2 3 |
service vmware-vcd restart |
After restarting the vCD services, I check logs to see if all is ok and if the cell is running, no issues found. I then start the browser to login to vCloud Director.
All Organizations (only one on this PoC), vApps, and VMs are running and no issues.
As we can see above, vCD DB migration was a success.
3. Upgrade vCD 9.7 to vCD 10.2.
After DB is migrated to PostgreSQL, it is time to upgrade the vCloud Director to v10.2.1.
Note: Before start, do a snapshot of your VMs.
The upgrade process is also simple and does not need much work. The upgrade process is done in two parts:
1. Upgrade vCloud Director Cell.
2. Upgrade vCloud Director DB.
As I informed you in the beginning, this vCloud infrastructure is using an NSX-V 6.4.8. So before we upgrade the vCloud Director, we need to check if PostgreSQL, NSX-V, or other VMware tools that are using this vCloud Director infrastructure is supported with the new vCloud Director v10.2.1
NSX-V and NSX-T support Matrix
As we can see above, v10.2.1 is supported with all the versions that we have.
We also need to know if the upgrade path is supported from v9.7 to v10.2.1.
Looking at the next upgrade path image, all is ok.
First, download the right image file for this upgrade. Since we are using a Linux vCloud Director, we need to download a vCD Linux binary file.
I create a new folder in /tmp/upgrade-package and use WinSCP to upload the image to my vCloud Director.
We need to change execute permissions on the file so that we can run it.
1 2 3 |
$ chmod u+x vmware-vcloud-director-distribution-10.2.1-17444454.bin |
Now let us run the upgrade script file (this file includes the installation script and RPM files).
Note: You cannot run the installation file from a directory whose pathname includes any embedded space characters.
Run the upgrade script.
1 2 3 |
$ ./vmware-vcloud-director-distribution-10.2.1-17444454.bin |
Answer “y” to start the vCloud Director Cell upgrade process.
As we can see above, all files were upgraded with success.
Now we need also to upgrade vCD DB running the command:
1 2 3 |
$ /opt/vmware/vcloud-director/bin/upgrade |
Answer “y” to start the vCloud Director DB upgrade process.
After vCloud Director DB is upgraded, the vCloud Director is fully upgraded.
Now we will open vCloud Director GUI.
As we can see, after the upgrade, we need to indicate our organization. Since now vCD uses HTML5, URL is different.
What is the new default HTML5?
-
- https://vCD-IP-FQDN/provider/
- https://vCD-IP-FQDN/tenant/
- https://vCD-IP-FQDN/provider/cloud/organizations/ (To see all organizations with your administrator user)
Open for the first time(or not providing a provider) just the vCD page. We need to provide an organization name.
For this case, I add my default organization.
Then login with your administrator account.
After login to upgraded vCloud Director v10.2.1, I get an error about certificates.
This error is regarding the NSX-V and vCenter certificates that need to be re-imported to the vCD. We can refresh the connections, save them, and this will fix the issues. But running a command, we can do this automatically to any VMware product connected to the vCD.
1 2 3 |
$ /opt/vmware/vcloud-director/bin/cell-management-tool trust-infra-certs --vsphere --unattended |
This command will download and update all certificates to the vCD
As we can see above, NSX-V and vCenter certificates were downloaded.
Also, we can check this in the vCD GUI trusted certificates.
Checking vSphere Services, we see that now all are connected.
With the above tasks, we finish our vCloud Director upgrade to v10.2.1, and also we finish this vCloud Director Linux migration SQL DB to embedded PostgreSQL appliance – Part I.
In this first blog post with three parts, we did the following tasks:
1. Install PostgreSQL Linux vCD.
2. Migrate SQL DB to PostgreSQL Linux.
3. Upgrade vCD 9.7 to vCD 10.x.
For the third part of this blog post, vCloud Director Migrations: Linux vCD to vCD Appliance – Part 3, we will have the following tasks:
4. Create a new vCD 10.x Appliance.
5. Migrate external DB to an embedded database.
6. Copy data and certificate data.
I hope this first blog post of vCloud Director Linux migration SQL DB to embedded PostgreSQL appliance was useful for your migrations or upgrades on your vCloud Director infrastructures.
vCloud Director migrations series:
- vCloud Director Linux migration SQL DB to embedded PostgreSQL appliance – Part 1
- vCloud Director Migrations: Linux vCD external SQL DB to vCD Appliance – Part 2
- vCloud Director Migrations: Linux vCD to vCD Appliance – Part 3
Share this article if you think it is worth sharing. If you have any questions or comments, comment here, or contact me on Twitter.
Leave A Comment
You must be logged in to post a comment.