Windows 2008 R2 sysprep 自動化

參考資料:
How to Sysprep in Windows Server 2008 R2 and Windows 7

The Complete Guide to Preparing a Windows 7 Deployment Image using Audit Mode and Sysprep with an unattend.xml Answer File

 

基本上照著reference裡link這幾位高手的SOP跑一遍大概就OK了

幾個重點紀錄一下

  1. 要準備好windows 2008 r2 的source光碟 (裡面的/source/install.wim這個檔案 WAIK要用到)
  2. 將source光碟中的/source/install.wim (約2.7Gb)複製到硬碟 (複製完後把install.wim唯讀屬性移除)
  3. 下載並安裝Windows Automated Installation Kit (WAIK)

unattend.xml範例
目的一:自動化sysprep (全自動執行不跳出需要人工點選畫面)
目的二:修改administrator預設密碼(改成Passw0rd)

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="generalize">
        <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
        </component>
        <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <InputLocale>zh-TW</InputLocale>
            <SystemLocale>zh-TW</SystemLocale>
            <UserLocale>zh-TW</UserLocale>
            <UILanguage>zh-TW</UILanguage>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
            </OOBE>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>UABhAHMAcwB3ADAAcgBkAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
                    <PlainText>false</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverstandard.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

 

XenServer 6.2.0 hotfix update script

2013/12/14 update
XS62ESP1出來了
http://support.citrix.com/article/CTX139789

 

#!/bin/bash
xe patch-upload file-name=XS62E001.xsupdate
xe patch-upload file-name=XS62E002.xsupdate
xe patch-upload file-name=XS62E004.xsupdate
xe patch-upload file-name=XS62E005.xsupdate
xe patch-upload file-name=XS62E009.xsupdate
xe patch-upload file-name=XS62E011.xsupdate
xe patch-upload file-name=XS62E012.xsupdate
xe patch-pool-apply uuid=dedcc0dd-d8f3-4f76-90ca-92697c7a44f0
xe patch-pool-apply uuid=59128f15-92cd-4dd9-8fbe-a0115d1b07a2
xe patch-pool-apply uuid=5579f1f0-ff83-11e2-b778-0800200c9a66
xe patch-pool-apply uuid=aeff92a9-2c60-43eb-b34e-14e4132b411c
xe patch-pool-apply uuid=d9c753b9-a15b-4a31-897b-97fdae609031
xe patch-pool-apply uuid=ff202d2d-2812-4c6b-b500-2f4701de7bc4
xe patch-pool-apply uuid=a4251789-ce6c-4726-942c-3cddbadcaca6

 

MySQL mysql-bin log檔案如何rotate/remove?

Ref:
http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_expire_logs_days
http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html

環境
CentOS 5 x86_64 with MySQL 5.0.95

問題
為了提升MySQL效能有將/etc/my.cnf改成使用/usr/share/mysql/my-huge.cnf
套用/usr/share/mysql/my-huge.cnf後就會enable mysql bin log (for replication/cluster)

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

此設定預設沒有啟動自動logrotate機制跑久了硬碟鐵定爆炸

解法1.1 (自動定期刪除)(修改設定檔)(是否正確生效待驗證)
於/etc/my.cnf加入下面這行 (超過3天的自動移除)

expire_logs_days=3

解法1.2 (自動定期刪除)(動態修改系統變數)

SHOW VARIABLES WHERE Variable_Name='expire_logs_days';
SET GLOBAL expire_logs_days = 1;
SHOW VARIABLES WHERE Variable_Name='expire_logs_days';

 

解法2 (人工刪除)

PURGE BINARY LOGS TO 'mysql-bin.000010';
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';

 

Todo
CentOS 6驗證

csv轉powercli語法大量rename VM

ref:
https://communities.vmware.com/message/2252750

csv example

Old_Name001,VM Description,New_Name001
Old_Name002,VM Description,New_Name002
Old_Name003,VM Description,New_Name003
Old_Name004,VM Description,New_Name004

 

 

<?php

$file1 = file('example.csv');
#print_r($file1);

foreach($file1 as $line){
  $tmp = preg_split("/,/", $line);
  #print_r($tmp);
  $old_name = trim($tmp[0]);
  $new_name = trim($tmp[2]);

  echo "#rename VM $old_name -> $new_name\n";
  echo "\$VM = Get-VM -Name '$old_name'\n";
  echo "Set-VM -VM \$VM -Name '$new_name' -Confirm:\$false\r\n"; #配合Windows txt格式換行符號需調整為\r\n

}//foreach

?>

 

Output

#rename VM Old_Name001 -> New_Name001
$VM = Get-VM -Name 'Old_Name001'
Set-VM -VM $VM -Name 'New_Name001' -Confirm:$false
#rename VM Old_Name002 -> New_Name002
$VM = Get-VM -Name 'Old_Name002'
Set-VM -VM $VM -Name 'New_Name002' -Confirm:$false
#rename VM Old_Name003 -> New_Name003
$VM = Get-VM -Name 'Old_Name003'
Set-VM -VM $VM -Name 'New_Name003' -Confirm:$false
#rename VM Old_Name004 -> New_Name004
$VM = Get-VM -Name 'Old_Name004'
Set-VM -VM $VM -Name 'New_Name004' -Confirm:$false

 

使用Powercli千萬要注意系統proxy設定

參考來源:
http://www.yellow-bricks.com/2011/02/24/connection-problems-with-powercli-due-to-proxy-settings/

 

問題:

硬體Firewall/switch ACL/Windows firewall相關設定都查過

telnet vcenter-ip 443也有通

但使用powercli就是怎樣也連不上

後來google才發現是powercli那台設備有設定proxy,而proxy設備因為firewall policy沒開連不到vCenter

 

解決方式:

關閉proxy或是設定vcenter IP不使用proxy