Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

How to check the size of your Config & SEAT data in the VCDB in vPostgres? ...

$
0
0

After publishing my article on how to check the size of your vCenter Server's Configuration and Stats, Events, Alarm & Tasks (SEAT) data for both a Microsoft SQL Server and Oracle based database , I had received a few requests for doing the same for the vPostgres database whichthe vCenter Server Appliance (VCSA) uses exclusively. Thanks to one of our Engineers who works on the VCDB, I was able to quickly get therelevant SQL query to performthe exact same lookup as the other two databases.

Since the VCSA is harden and locked down by default, being able to remotely retrieve this information will actually require some additional configuration changes to your VCSA which may or may not be acceptable. Because of this constraint, I will provide two options in how you can perform thisSQL query.

The first option (easy) will be running the SQL querydirectly from within theVCSA. You just need SSH access and no otherinformation or credentials will be required. The second option (complex) will be to remotely connectto the vPostgres database (generallynotrecommend) whichwill require the VCDB's credentials which I will show you how to retrieve. Lastly, I want to quickly mention that in the upcoming vSphere 6.5 release,this information will be super easy to view not only from a UI but also API as shown in tweet below.

Want to see breakdown of your vCenter Server Database in the VCSA? You can now using either UI or API within VAMI interface! #vSphere65 pic.twitter.com/htOzb93aei

― William Lam (@lamw) October 18, 2016

Option 1:

Step 1- Download the following shell script called queryVCDBvPostgres.sh which contains the respective VCDB SQL query.

Step 2- SCP the shell script to your VCSA and then login via SSH.

Step 3- Run the following command to make the script executable:

chmod +xqueryVCDBvPostgres.sh

Step 4- Run the script by issuing the following command:

./queryVCDBvPostgres.sh

Here is a screenshot of what you should see which is a break down of your Config + SEAT data:


How to check the size of your Config & SEAT data in the VCDB in vPostgres? ...
Option 2:

Step 1-Login to the VCSA using SSH.

Step 2- Edit /storage/db/vpostgres/postgresql.conf and add the following entry:

listen_addresses = '*'

This will allow vPostgres to be connected to from any address orif you want to restrict it to a specific IP, you can also just specify that.

Step 3- Edit /storage/db/vpostgres/pg_hba.conf and add the following entry:

host all all 172.30.0.0/24 trust

Similiar to theprevious configuration, you can either specify a network range using CIDR notation or a specific IP Address.

Step 4- Edit /etc/vmware/appliance/firewall/vmware-vpostgres and replace it with the following entry:

{ "firewall": { "enable": true, "rules": [ { "direction": "inbound", "name": "vpostgres_external", "port": "5432", "portoffset": 0, "porttype": "dst", "protocol": "tcp" } ] }, "internal-ports": { "rules": [ { "name": "server_port", "port": 5432 } ] } }

This will openup the VCSA's firewall to allow remote connections to the vPostgres port which the default is 5432.

Step 5- Next, we need to reload the firewall configuration by running the following command:

/usr/lib/applmgmt/networking/bin/firewall-reload

Step 6- We can verify by running the following command:

iptables -L | grep postgres

Here is a screenshot of what you should see as the output:


How to check the size of your Config & SEAT data in the VCDB in vPostgres? ...

Step 7- Lastly, we need to restart the vPostgres service by running the following command:

service vmware-vpostgres restart

Step 8- To verify that you can now remotely connect to the vPostgres DB, run the following command:

netstat -anp | grep LISTEN | grep tcp | grep 5432

Here is a screenshot of what you should see as the output:


How to check the size of your Config & SEAT data in the VCDB in vPostgres? ...

At this point, you have now enabled remote connections to the VCSA's vPostgres DB. The next step is to retrieve the VCDB credentials which you will do so using aPowerShell script that I have written to perform the remote SQL query.This will also require that you setup an ODBC connection on your client system to communicate with the vPostgres DB. Please have a look here for more information on how to setup the ODBC connection.

Step 9- Login to VCSA via SSH and then look at the /root/.pgpass andyou should see the password to your VCDB. Go ahead and record this some where as you will need it in the next step. The username for the DB will be vc which you can also make a note of.

Step 10- Download the following PowerShell script called Get-VCDBUsagevPostgres.ps1 andprovide the connection details that you retrieved in Step 9. If everything was properly configured, you can run the PowerShell script and it should produce a similiar output as shown in the screenshot below.


How to check the size of your Config & SEAT data in the VCDB in vPostgres? ...

Viewing all articles
Browse latest Browse all 11063

Trending Articles