配置过程主要有如下几步:

1.启动vCenter Orchestrator Configuration服务

2.配置vCenter Orchestrator 网络连接

3.创建一个LDAP 服务器,本环境使用活动目录

4.配置后台数据库,本环境使用Sql2008R2

5.为vCenter Orchestrator创建SSL证书

6.输入vCenter Server的许可证

7.配置缺省插件

 

1. 启动vCenter Orchestrator Configuration服务

缺省该服务启动状态为手动,修改为自动,并启动它。

sc config vCOConfiguration start= auto

sc start vCOConfiguration

服务启动之后,通过http://vcenter Server的IP:8282来访问,缺省的用户名及密码是vmware/vmware

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

红色部分提示,配置未完成,配置完成之后,状态将改为绿色

2. 配置vCenter Orchestrator 网络连接

点击上图的Network,在右侧的IP Address栏,选择vCenter Orchestrator使用的IP,然后点击Apply Changes。可以看到,状态变绿。

使用vCenter Orchestrator实现VMware vSphere的自动化任务

3. 配置LDAP

点击LDAP,

在右侧LDAP Client选择Active Directory,

Primary LDAP Host输入域控的FQDN,

Root文本框里面输入活动目录的root DN,形如DC=xyz,DC=com,

在Username文本框,输入用户名,该用户名为Orchestrator登录活动目录的凭据,用户名的格式要么是DN 格式 (cn=username,cn=Users,dc=domain,dc=com) 要么是UPN格式 ([email protected]),此处是[email protected]

User Lookup Base 文本框,提供Orchestrator用来搜索用户帐户的base DN,可配置成与root DN一致,DC=xyz,DC=com

Group Lookup Base 文本框,可配置成与root DN一致,DC=xyz,DC=com

vCO Admin Group文本框,指定具有vCenter Orchestrator管理员权限的DN,可以使用域管理员组cn=Administrators,cn=Builtin,dc=domain,dc=com,本实验指定CN=vmadmin,OU=vmwareOU,DC=xyz,DC=com,将域管理员及xyz\vcadmin用户添加到该组,

点击Apply Changes,然后状态变为绿色。

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

用ldap方式访问AD域的的错误一般会如下格式:

LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece

其中红字部分的意思如下:

525 - 用户没有找到

52e - 证书不正确,或者凭据不正确

530 - not permitted to logon at this time

532 - 密码期满

533 - 帐户不可用

701 - 账户期满

773 - 用户必须重设密码

4. 配置后台数据库

先在Sql2008R2 服务器上新建一空的数据库vcodb,Db_owner为xyz\vcadmin

点击Database,选择SqlServer

信息输入完成之后,点Apply Changes,然后点上方的Install the database

使用vCenter Orchestrator实现VMware vSphere的自动化任务

点击Instal the database之后,Database标签状态变绿

5. 配置服务器证书

即可使用自签名的证书,也可使用第三方证书

使用vCenter Orchestrator实现VMware vSphere的自动化任务

创建自签名证书

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Server的FQDN

使用vCenter Orchestrator实现VMware vSphere的自动化任务

6. 输入vCenter Server的许可证

使用vCenter Orchestrator实现VMware vSphere的自动化任务

导入vCenter Server的证书

使用vCenter Orchestrator实现VMware vSphere的自动化任务

此处应该使用IP地址,不能使用FQDN

使用vCenter Orchestrator实现VMware vSphere的自动化任务

C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\SSL\rui.crt

使用vCenter Orchestrator实现VMware vSphere的自动化任务

7. 配置插件

vCenter Orchestrator使用插件连接工作流引擎。缺省情况下,vCenter Orchestrator提供了一一套插件,但需要使用具有vCenter Orchestrator管理员权限的用户来执行。

单击Plug-Ins

指定属于vCO Administration组的用户

Apply Changes

使用vCenter Orchestrator实现VMware vSphere的自动化任务

此步骤完成之后,Startup Options标签随之变绿

8. 添加vCenter Server主机

与vCenter Orchestrator通讯的vCenter Server

不配置vCenter Server,vCenter Orchestrator同样能工作,但将失去在vCenter Server内自动化任务的能力

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

9. 安装和启动vCenter Orchestrator Server服务

单击Startup Options标签

单击Install vCO Server As A Service链接,当状态再次变绿,单击启动服务链接

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

10. 使用Orchestrator工作流

vCenter Orchestrator Client是配置工作的工具软件

运行vCenter Orchestrator Client,会看到vCenter Orchestrator已经提供了预安装的工作流。

使用vCenter Orchestrator实现VMware vSphere的自动化任务

如果系统内存低于4GB,VMware vCenter Orchestrator Server有可能无法启动

使用vCenter Orchestrator实现VMware vSphere的自动化任务

11. 使用PowerShell和PowerCLI实现自动化任务

Windows 2008 R2已经内置PowerShell2

安装PowerCLI,首先提示安装VIX

使用vCenter Orchestrator实现VMware vSphere的自动化任务

 

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

使用vCenter Orchestrator实现VMware vSphere的自动化任务

在使用PowerCLI之前,需要设置PowerShell执行策略允许运行PowerCLI的组件

使用vCenter Orchestrator实现VMware vSphere的自动化任务

Set-ExecutionPolicy RemoteSigned

Get-ExecutionPolicy

运行PowerCLI

Everything is object.Esx主机、虚拟机、快照等等均为对象。

首先需要连接到vCenter Server或者Esx/Esxi主机

Connect-VIServer -Server <vCenter Server hostname> -User <Username> -Password <password>

Get-VMHost

Get-VMHost <Hostname> | Get-VM

Get-VMHost <Hostname> | Get-VM | Get-NetworkAdapter

Get-VMHost <Hostname> | Get-VM | Get-NetworkAdapter | Select NetworkName, Type

Get-Datacenter Datacenter

Get-Datastore Datastore

Get-Folder Folder

Get-HardDisk Virtual hard disk

Get-NetworkAdapter Virtual network adapter

Get-ResourcePool Resource pool

Get-Snapshot Virtual machine snapshot

Get-Template Virtual machine template

Get-VirtualPortGroup Port group

Get-VirtualSwitch Virtual switch

Get-VM Virtual machine

Get-VMGuest Virtual machine guest operating system

Get-VMHost ESX/ESXi host

Move-VM Moves a VM to a new host, cluster, or datastore

Move-ResourcePool Moves a resource pool

New-Cluster Creates a new cluster of ESX/ESXi hosts

New-HardDisk Creates a new hard disk on a VM

New-NetworkAdapter Creates a new network adapter on a VM

New-ResourcePool Creates a new resource pool

New-Snapshot Creates a new snapshot on a VM

New-VM Creates a new VM

Remove-Snapshot Removes a VM snapshot or snapshots

Restart-VMGuest Restarts a VM guest operating system

Set-CDDrive Changes VM’s virtual CD configuration

Set-Datacenter Changes the name of the datacenter

Set-Datastore Changes the name of the datastore

Set-FloppyDrive Updates a VM’s virtual floppy configuration

Set-HardDisk Changes VM’s hard disk configuration

Set-NetworkAdapter Modifies VM’s network adapter configuration

Set-ResourcePool Updates resource pool configuration

Set-VirtualPortGroup Updates virtual port group configuration

Set-VirtualSwitch Changes virtual switch configuration

Set-VM Changes virtual machine configuration

Set-VMHost Updates ESX/ESXi host configuration

Set-VMResourceConfiguration Changes resource allocation for a VM

Shutdown-VMGuest Shuts down a VM guest operating system

Suspend-VMGuest Suspends a VM guest operating system

一些示例:

Get-VMHost <FirstHost> | Get-VM | Move-VM –destination (Get-VMHost <SecondHost>)
利用vmotion移动主机1上的虚拟机到主机2
Get-VMHost <Hostname> | Get-VM | New-Snapshot -Name "Target-Snapsht"
主机上所有的虚拟机都创建一份快照
Get-VMHost <Hostname> | Get-VM | Get-Snapshot -Name "Target-Snapsht" | Remove-Snapshot
删除快照
Get-VMHost <Hostname> | Get-VM | Get-Snapshot
列出快照
Get-VM | Get-NetworkAdapter | Where-Object { $_.NetworkName -like "OldPortGroupName" } | Set-NetworkAdapter –NetworkName "NewPortGroupName" –Confirm:$false
将某个端口组的虚拟机移动到另外一个端口组
Get-ResourcePool <ResourcePoolName> | Get-VM | Get-VMGuest
Get-ResourcePool <ResourcePoolName> | Get-VM | Get-VMGuest | Where-Object { $_.OSFullName –match " ? Microsoft Windows.*" }
列出资源池中操作系统为windows的虚拟机
\MoveWindowsVMs.ps1
$VMs = Get-VM -Location (Get-ResourcePool Infrastructure)
foreach ($vm in $VMs) {
$vmguest = Get-VMGuest -VM $vm
if ($vmguest.OSFullName -match " ^ Microsoft Windows.*") {
Move-VM -VM $vm -Destination (Get-ResourcePool "Windows VMs") } }