2015年7月10日 星期五

VMWare ESXi 6 窮人備份手冊 by XSIBACKUP 使用深入剖析



研究了許多市面上的ESXi備份軟體,要符合:
1.定時備份
2.差異性備份
3.免費
4.異地備份

符合這前三點的軟體實在屈指可數,雖然有ghetto這個強大的工具,但打算換換口味,就先暫且撇開不用。

XSIBACKUP使用方式如下:
開啟esxi 6 ssh功能,必要時連同client一起開啟,開啟方式可參考如下:
http://www.thomasmaurer.ch/2015/04/enable-ssh-on-vmware-esxi-6-0-via-vsphere-client/

使用環境:
a.vSphere ESXi 6
b.vmdk皆為lazy eager zeroed thick
c.三台VM皆為開機狀態(a-centos66、a-win2k12r2Std、b-win2k12r2Std)
d.測試機A為192.168.2.59、B為192.168.2.60,主要操作皆於A進行
e.HDD 7200 rpm x 4 raid 5
f.a-centos66使用空間如下圖,硬碟空間整體使用不到2GB


 

 

ssh 至ESXi 6


1.安裝


建議先cd /vmfs/volumes/datastore1/下
wget http://33hops.com/downloads/xsibackup.zip -O xsibackup.zip && unzip -o xsibackup.zip && chmod 0700 xsibackup*

2.一般備份

mkdir /vmfs/volumes/datastore1/backup

a.這裡不進行email通知,故無設定相關參數,備份vm為vsphere client中顯示之vm名稱,非datastore1內的名稱
backup policy:

a.--date-dir=yes 以時間命名資料夾
b.--backup-room=500 備份上限為500GB,超過將自動刪除最舊檔案
c. default備份為熱備份
PS:使用b.參數a.參數必須同時存在,不然會出現錯誤

/vmfs/volumes/datastore1/xsibackup --date-dir=yes --backup-room=500 --backup-point=/vmfs/volumes/datastore1/backup --backup-type=custom --backup-vms="a-centos66"

Fri, 10 Jul 2015 03:40:29 +0000
Found --backup-point at /vmfs/volumes/datastore1/backup
The e-mail report will not be sent becouse of the followig reasons:
The --mail-from string has not been set.
The --mail-to string has not been set.
The --smtp-srv string has not been set.
The --smtp-port string has not been set.
The --smtp-usr string has not been set, you need --smtp-usr if --smtp-auth is other than -none-.
The --smtp-pwd string has not been set, you need --smtp-pwd if --smtp-auth is other than -none-.


The backup room has been limited to 500 gb.
Getting list of all VMs...
3      a-centos66    [datastore1] vm3/vm3.vmx                             centos64Guest           vmx-11
6      a-win2k12r2Std    [datastore1] a-win2k12r2Std/a-win2k12r2Std.vmx     windows8Server64Guest   vmx-11
7      b-win2k12r2Std   [datastore1] b-win2k12r2Std/b-win2k12r2Std.vmx   windows8Server64Guest   vmx-11
VMs to backup:
3      a-centos66    [datastore1] vm3/vm3.vmx                             centos64Guest           vmx-11
du: /vmfs/volumes/datastore1/backup/20*: No such file or directory
Needed room: 208 Gb.
Available room: 500 Gb.

Hot backup selected for VM: a-centos66 will not be switched off
All snapshots removed for a-centos66
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/557c07a7-e6aa36f2-9cea-0cc47a180fc8/vm3/vm3.vmdk'...
Clone: 100% done.
再備份一次


 /vmfs/volumes/datastore1/xsibackup --date-dir=yes --backup-room=500 --backup-point=/vmfs/volumes/datastore1/backup --backup-type=custom --backup-vms="a-centos66"


--中略--
The backup room has been limited to 500 gb.
--中略--
Needed room: 208 Gb.
Available room: 493 Gb.

Hot backup selected for VM: a-centos66 will not be switched off
All snapshots removed for a-centos66
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/557c07a7-e6aa36f2-9cea-0cc47a180fc8/vm3/vm3.vmdk'...
Clone: 100% done.
可以發現 Available room減少了,所需空間仍提示為208GB,上次備份實際消耗7GB,表示會自動轉成thin disk,弔詭的地方是VM原始硬碟使用量不到2GB,卻產生出近7GB的備份。

b.此時如果將備份標的換成a-win2k12r2Std

 /vmfs/volumes/datastore1/xsibackup --date-dir=yes --backup-room=500 --backup-point=/vmfs/volumes/datastore1/backup --backup-type=custom --backup-vms="a-win2k12r2Std"

--中略--
The backup room has been limited to 500 gb.
Getting list of all VMs...
--中略--
Needed room: 208 Gb.
Available room: 486 Gb.

Hot backup selected for VM: a-win2k12r2Std will not be switched off
All snapshots removed for a-win2k12r2Std
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/557c07a7-e6aa36f2-9cea-0cc47a180fc8/a-win2k12r2Std/a-win2k12r2Std.vmdk'...
Clone: 100% done.

可以發現共用的room空見限制是共同的。

注意事項:
a.room大小必須比flat過的vmdk大,否則會出現以下錯誤洗版:

 du: /vmfs/volumes/datastore1/backup/20*: No such file or directory
b.room大小需一致,否則available room有機會會重置
c.只要available room < need room(flat過的vmdk)就會刪除舊檔


3.定時備份


a.先看看沒有安裝前的crontab
cat /var/spool/cron/crontabs/root
#min hour day mon dow command
1    1    *   *   *   /sbin/tmpwatch.py
1    *    *   *   *   /sbin/auto-backup.sh
0    *    *   *   *   /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5  *    *   *   *   /sbin/hostd-probe ++group=host/vim/vmvisor/hostd-probe

b.安裝XSIBACKUP定時備份
/vmfs/volumes/datastore1/xsibackup --install-cron
This command will install XSIBackup cron to your ESXi > 5.1 BOX
xsibackup-cron will be installed to the current working directory
You should cd to the desired directory before installing the cron
Do you wish to continue? (y/n) y
Removing cron info...
Adding new cron info...
The local cron service will be restarted
You might need to reboot the ESxi server for the changes to take effect...
cron service restarted

c.再來看看安裝完後的crontab
cat /var/spool/cron/crontabs/root
#min hour day mon dow command
1    1    *   *   *   /sbin/tmpwatch.py
1    *    *   *   *   /sbin/auto-backup.sh
0    *    *   *   *   /usr/lib/vmware/vmksummary/log-heartbeat.py
*/5  *    *   *   *   /sbin/hostd-probe ++group=host/vim/vmvisor/hostd-probe
*/1 * * * * /vmfs/volumes/datastore1/xsibackup-cron >> /vmfs/volumes/datastore1/xsibackup-cron.log 2>&1
d.使用方式為直接把指令加入/vmfs/volumes/datastore1/xsibackup-cron即可

以上面例子修改如下:
 /vmfs/volumes/datastore1/xsibackup --time="Fri 04:31" --date-dir=yes --backup-room=500 --backup-point=/vmfs/volumes/datastore1/backup --backup-type=custom --backup-vms="a-centos66"

PS: 時間為UTC時間,台灣需自動-8小時



4.遠端備份


xsibackup 有自帶rsync,支援遠端與delta備份,其中rsync程式為作者自行compile並支援delta(增量備份)

備份情境:A--->B:/vmfs/volumes/datastore1/remote-backup/

a. 先建立ssh key
mkdir /.ssh
/vmfs/volumes/datastore1/xsibackup --link-srv=192.168.2.60

@192.168.2.60

應有加入192.168.2.59之pub key
cat /etc/ssh/keys-root/authorized_keys

如沒有澤手動加入 
@192.168.2.59
cat /.ssh/id_dsa.pub


b.使用指令備份方式如下

 /vmfs/volumes/datastore1/xsibackup --backup-point="192.168.2.60:22:/vmfs/volumes/datastore1/remote-backup:D" --date-dir=yes --backup-room=500 --backup-type=custom --backup-vms="a-centos66"


Fri, 10 Jul 2015 05:38:17 +0000
Mirroring to server 192.168.2.60 port 22
Checking xsibackup-rsync exists on the other side...
xsibackup-rsync binary could not be found on the remote ESXi system datastore
Do you wish to copy xsibackup-rsync to the other end? (y/n) y
xsibackup-rsync                                                                            100% 1168KB   1.1MB/s   00:00

--中略--

The backup room has been limited to 500 gb.
--中略--
Hot backup selected for VM: a-centos66 will not be switched off
All snapshots removed for a-centos66
VMX file transfer succesful
Possible xsibackup-rsync remaining processes killed.
sending incremental file list
vm3.vmdk
            493 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)

sent 579 bytes  received 35 bytes  1,228.00 bytes/sec
total size is 493  speedup is 0.80
sending incremental file list
vm3-flat.vmdk
 13,166,379,008   6%   11.16MB/s    4:53:55

備份時是以flat方式進行備份,由於網路過慢200GB耗時約需5小時,故確認有rsync置目標後隨即停止。

c.於本機使用delta備份
會發現速度比直接在本機執行一般備份緩慢,寫入速度也很飄移,

 /vmfs/volumes/datastore1/xsibackup --backup-point="localhost:22:/vmfs/volumes/datastore1/backup:D" --date-dir=yes --backup-room=500 --backup-type=custom --backup-vms="a-centos66"


--中略--
sent 579 bytes  received 35 bytes  1,228.00 bytes/sec
total size is 493  speedup is 0.80
sending incremental file list
vm3-flat.vmdk
 17,526,292,480   8%   54.33MB/s    0:59:04
速度實在10-50MB/s間飄移,有可能是RAID5所造成因素,另外使用delta此種方式備份,若空間使用狀況為,會發現檔案長到一個地步後,就開始緩步成長。

由下圖可得知,200GB的vmdk備份到了67%,實際成長值卻只到3.6GB


(迷之聲:那為什麼網路還走這麼慢?)

根據官方說法delta備份有使用一種演算法,再來對照下圖便可得知其說法不假:

CPU使用率自開始備份以來皆屬高點





硬碟於初期有寫入高峰,但後期便下降非常多










 網路卡則無任何流量產生,表示直接寫入本機硬碟內

































備份完成後會發現大小比一般備份還要小,原備份為6.8GB,但使用Delta備份為3.7GB
然而代價是所花費時間200GB需時1小時
備份的--date-dir參數會失效,並以實際在vmfs下檔案作為命名。
















d.備份完成後開啟VM下載200M測速檔後再次使用deta備份

不幸的是會卡在

sent 579 bytes  received 41 bytes  413.33 bytes/sec
total size is 493  speedup is 0.80
sending incremental file list


非常久,且CPU使用率如下:


















看來應該是要200GB全數比對完才會開始進行動作,比對完後出現

vm3-flat.vmdk
    685,899,776   0%   61.49MB/s    0:56:39
卡在0%,不過從vSphere client看CPU有在運作


   














很不幸的努力了一小時似乎都還是卡在0%,因此果斷停止
















 

e.使用full進行本機備份

 因使用遠端備份速度並不盡理想,故同場加映本機full端測試

 /vmfs/volumes/datastore1/xsibackup --backup-point="localhost:22:/vmfs/volumes/datastore1/backup:F" --date-dir=yes --backup-room=500 --backup-type=custom --backup-vms="a-centos66"

與Delta相似,但屬於直接覆蓋。且--date-dir=yes並不會生效。

 

   5.復原VM


a.依照一般的匯入VM程序即可


可以發現實際大小為3.7GB,部建大小200GB




選擇copy

可以發現轉換成精簡布建





























如此一來便可正常啟動。


結論:
就備份軟體而言似乎有許多臭蟲存在,一般本機備份沒有什麼大問題,但對於想要將檔案備份置改為遠端主機用戶,建議仍以nfs掛載較為保險
此外rsync將會佔去絕大多數CPU資源,使用時必須多加注意,且--date-dir參數無法生效,造成備份是直接覆蓋原始檔,因此效益不大,如果有先進測試成功還望請告知。


詳細操作可參考:http://33hops.com/xsibackup-help-man-page.html

官方文件:
http://33hops.com/blog-main.asp?topic=xsibackup&lang=EN
http://sourceforge.net/projects/xsibackup/files/?source=navbar

沒有留言:

張貼留言

MariaDB Cluster on CentOS7.6

目標 於3臺 CentOS 7.6 minimal 上建置 MariaDB 10.3 Galera cluster