Sei sulla pagina 1di 36

VirtualCenter Database

Bouke Groenescheij Jum B.V. bouke@jume.nl, www.jume.nl

When I say VirtualCenter: Sorry Should be vCenter!!!

VirtualCenter Database vCenter Database


Bouke Groenescheij Jum B.V. bouke@jume.nl, www.jume.nl

Introduction
Why this presentation? To get a better overview of your vCenter Database and its data! Write your own tools to gather information from the vCenter Database. For who? Administrators, consultants, developers who want to create reporting and do analysis from the database.

Agenda
vCenter Architectuur Setup (the installation) Database Architecture SQL Some applications

vCenter Architecture

Requirements
Microsoft SQL Server 2000 Standard Microsoft SQL Server 2000 Enterprise Microsoft SQL Server 2005 Standard Microsoft SQL Server 2005 Enterprise Microsoft SQL Server 2005 Express SP2 Oracle 9i release 2 Standard* Oracle 9i release 2 Enterprise* Oracle 10g Standard Release 1 (10.1.0.3.0) Oracle 10g Enterprise Release 1 (10.1.0.3.0) Oracle 10g Standard Release 2 (10.2.0.1.0)* Oracle 10g Enterprise Release 2 (10.2.0.1.0)*
*Be aware: patches needed! See p. 19 in ESX Server 3 and VirtualCenter Installation Guide

Database Size (upfront)


Use the vc_db_calculator.xls for Microsoft SQL Server or the vc_db_calculator_oracle.xls for Oracle.
http://www.vmware.com/support/pubs/vi_pages/vi_pubs_35u2.html

Database Size (afterwards)


Use vCenter Server: Administration, VirtualCenter Management Server Configuration..., Statistics

Database Maintenance
Monitoring the growth of the log file and compacting the database log file, as needed. Scheduling regular backups of the database. Backing up the database before any vCenter upgrade.

Setup
Oracle local Oracle remote SQL local SQL remote

Setup (Oracle local 1/4)


Download Oracle 9i or Oracle 10g from the Oracle Web site, install it, and create a database (vCenter). Download Oracle ODBC from the Oracle Web site if you are using Oracle 9i. If you downloaded Oracle 10g, the ODBC is included in the product media. Install the Oracle ODBC corresponding driver through the Oracle Universal Installer (directions are provided with the driver). Increase the number of open cursors for the database. Add this entry to the C:\Oracle\ADMIN\VPX\pfile\init.ora file: open_cursors = 300

Connect (Oracle lokaal 2/4)


Create a new tablespace specifically for vCenter using the following SQL statement: CREATE TABLESPACE "VPX" DATAFILE 'C:\Oracle\ORADATA\VPX\VPX.dat' SIZE 1000M AUTOEXTEND ON NEXT 500K; Create a user, such as vpxAdmin, for accessing this table space through ODBC: CREATE USER vpxAdmin IDENTIFIED BY vpxadmin DEFAULT TABLESPACE vpx;

Connect (Oracle lokaal 3/4)


Either grant dba permission to the user, or grant the following permissions to the user:
grant connect to <user> grant resource to <user> grant create view to <user> grant create any sequence to <user> # For vCenter upgrade only grant create any table to <user> # For vCenter upgrade only grant execute on dbms_job to <user> grant execute on dbms_lock to <user> grant unlimited tablespace to <user> # To ensure space limitation is not an issue

Connecteer (Oracle lokaal 4/4)


Create an ODBC connection to the database. The following are example settings: Data Source Name: VMware vCenter TNS Service Name: VPX User Id: vpxAdmin

Setup (Oracle Remote 1/2)


Install the Oracle client on the vCenter Server machine. Download and install the ODBC driver Edit the tnsnames.ora file located at Ora9I or 10g, as appropriate. C:\Oracle\Oraxx\NETWORK\ADMIN In this example, xx is either 9I or 10g.

Setup (Oracle Remote 2/2)


Use the Net8 Configuration Assistant to add the following entry:
VPX = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS=(PROTOCOL=TCP)(HOST=vpxdOracle)(PORT=1521)) ) (CONNECT_DATA = (SERVICE_NAME = VPX) ) ) HOST =

In this example, HOST is the managed host to which the client needs to connect.

Setup (Microsoft SQL 1/3)


sysadmin

Setup (Microsoft SQL 2/3)


Permissions on VC database: db_owner

Setup (Microsoft SQL 3/3)


Permissions on msdb database: db_owner

Database Details
1 relational database 88 tables
select * from information_schema.tables where table_type='BASE TABLE'

23 views
select * from information_schema.tables where table_type='VIEW'

3 jobs 8 stored procedures

Messages during installation

Jobs & Stored Procedures


3 jobs, for RollUp stats These starts the stored procedures

8 stored procedures

SQL (Structured Query Language)


Simple (yet very powerfull) language, 5 commands USE SELECT UPDATE INSERT DELETE A query can also contain functions, conditions, joins, operators and a lot more!

SQL Rules
Number should not be between quotes: SELECT * FROM VPX_ENTITY WHERE (TYPE_ID = 1)

Text MUST be between quotes: SELECT NAME, VALUE FROM VPX_PARAMETER WHERE (NAME = 'log.level')

Working with aliases


Usage of AS for an alias Simplifies your query and can provide a better overview Example (CPU Features from ESX servers) SELECT HCCF.HOST_ID, HCCF.CPU_EAX FROM VPX_HOST_CPU_CPUID_FEATURE AS HCCF

SQL Join (1/2)


Query data from 2 or more tables Joins types:
INNER JOIN
Only shows the matching records

OUTER JOIN
LEFT OUTER JOIN
All values from the left table, including the non-matching records

RIGHT OUTER JOIN


All values from the right table, including the non-matching records

FULL OUTER JOIN


All values from both tables, including the non-matching records

CROSS JOIN
All values from both tables, creates matches, but also records without matches (10 rows from 1 table and 7 rows from the other will result in 70 rows). Be aware: Cartesian product.

SQL Join (2/2)


With a JOIN use the ON And an operator: =, <>, <=, >=, <, >, ! (not) Example (List of WWNs with servernames): SELECT E.NAME, W.NODE_WWN, W.PORT_WWN FROM VPX_WWN AS W INNER JOIN VPX_ENTITY AS E ON W.ENTITY_ID = E.ID

IMPORTANT!!!

What is possible?!?
Historical overview of the amount of VMs in VI over time Total VMotions Performance graphics in a webinterface List with all VMFS partitions with free-space Properties of the objects All WWNs of HBAs Etc., etc.

No clue about which table?


Use the: SQL Server Profiler Be aware: could have a high performance impact!!!

When something goes wrong (and no backup?)


Stop vCenter services Go to:
C:\Program Files\VMware\Infrastructure\VirtualCenter Server

Start the vCenter Server with option b:


vpxd.exe b

But be carefull: database = completely empty (all ESX servers, VMs, settings, alarms, counters, etc. are erased!!!)

More useful options


vpxd p (of P = scriptable) For resetting vCenter DB password vpxd s For vCenter Service standalone startup Check eventvwr for hints

Few demos
SQL Server Profiler Total VMotions Performance stats in webinterface Free Diskspace

Links
Basis SQL Querys? http://www.w3schools.com/sql/sql_intro.asp http://en.wikipedia.org/wiki/Join_(SQL) VMware vCenter DB Application development http://www.vmguru.com/files/VCDBApps.pdf Examples http://ict-freak.nl/2008/06/12/vmware-vmotioninfo-in-excel-2007/ http://www.jume.nl

vCenter Database
Bouke Groenescheij Jum B.V. bouke@jume.nl, www.jume.nl Follow me on twitter: boukeg

Potrebbero piacerti anche