27
VirtualCenter Database Bouke Groenescheij Jumé B.V. [email protected], www.jume.nl

vCenter Database en - Bouke Groenescheij

Embed Size (px)

Citation preview

Page 1: vCenter Database en - Bouke Groenescheij

VirtualCenter Database

Bouke GroenescheijJumé [email protected], www.jume.nl

Page 2: vCenter Database en - Bouke Groenescheij

“When I say VirtualCenter: Sorry – Should be vCenter!!!”

VirtualCenter Database

Bouke GroenescheijJumé [email protected], www.jume.nl

vCenter Database

Page 3: vCenter Database en - Bouke Groenescheij

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.

Page 4: vCenter Database en - Bouke Groenescheij

Agenda

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

Page 5: vCenter Database en - Bouke Groenescheij

vCenter Architecture

Page 6: vCenter Database en - Bouke Groenescheij

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”

Page 7: vCenter Database en - Bouke Groenescheij

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

Page 8: vCenter Database en - Bouke Groenescheij

Database Size (afterwards)

• Use vCenter Server: “Administration, VirtualCenter Management Server Configuration..., Statistics”

Page 9: vCenter Database en - Bouke Groenescheij

Database Maintenance

• Monitoring the growth of the log file and compactingthe database log file, as needed.

• Scheduling regular backups of the database.�• Backing up the database before any vCenter�

upgrade.Moni

tor

Compact

Backup

Page 10: vCenter Database en - Bouke Groenescheij

Setup

• Oracle local• Oracle remote• SQL local• SQL remote

Page 11: vCenter Database en - Bouke Groenescheij

Database Details

• 1 relational database• 88 tables

select *

from information_schema.tableswhere table_type='BASE TABLE'

• 23 viewsselect *

from information_schema.tableswhere table_type='VIEW'

• 3 jobs• 8 stored procedures

Page 12: vCenter Database en - Bouke Groenescheij

Messages during installation

Page 13: vCenter Database en - Bouke Groenescheij

Jobs & Stored Procedures

• 3 jobs, for RollUp stats– These starts the stored procedures

• 8 stored procedures

Page 14: vCenter Database en - Bouke Groenescheij

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!

Page 15: vCenter Database en - Bouke Groenescheij

SQL Rules

• Number should not be between quotes:– SELECT *

FROM VPX_ENTITYWHERE (TYPE_ID = 1)

• Text MUST be between quotes:– SELECT NAME, VALUE

FROM VPX_PARAMETERWHERE (NAME = 'log.level')

Page 16: vCenter Database en - Bouke Groenescheij

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_EAXFROM VPX_HOST_CPU_CPUID_FEATURE AS HCCF

Page 17: vCenter Database en - Bouke Groenescheij

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.

Page 18: vCenter Database en - Bouke Groenescheij

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_WWNFROM VPX_WWN AS W INNER JOIN VPX_ENTITY AS E ON W.ENTITY_ID = E.ID

Page 19: vCenter Database en - Bouke Groenescheij

IMPORTANT!!!

CREATE BACKUPS!!!

Page 20: vCenter Database en - Bouke Groenescheij

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.

Page 21: vCenter Database en - Bouke Groenescheij

No clue about which table?

• Use the: “SQL Server Profiler”– Be aware: could have a high performance impact!!!

Page 22: vCenter Database en - Bouke Groenescheij

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!!!)

Page 23: vCenter Database en - Bouke Groenescheij

More useful options

• vpxd –p (of –P = scriptable)– For resetting vCenter DB password

• vpxd –s– For vCenter Service standalone startup

• Check eventvwr for hints

Page 24: vCenter Database en - Bouke Groenescheij

Few demos

• SQL Server Profiler• Total VMotions• Performance stats in webinterface• Free Diskspace

Page 25: vCenter Database en - Bouke Groenescheij

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-vmotion-info

-in-excel-2007/– http://www.jume.nl

Page 26: vCenter Database en - Bouke Groenescheij

Questions?!?

Page 27: vCenter Database en - Bouke Groenescheij

vCenter Database

Bouke GroenescheijJumé [email protected], www.jume.nlFollow me on twitter: boukeg