2017年4月17日 星期一

ESXI 重啟動,還原自訂修改過的設定檔(個人備忘記錄)

ESXI 重開機都會還原系統的某些設定值,所以最好的做法是備份修改後的設定檔,
並於重啟後還原這些備份的設定檔,才不用每次重啟後還要再調整一次系統設定。

相關會還原或被清除的檔案:
1.root 的 crontab 設定: /var/spool/cron/crontabs/root
2.firewall 設定: /etc/vmware/firewall/service.xml
3.localtime 檔: /etc/localtime
4.ghettoVCB.conf 被清除: /opt/ghettovcb/ghettoVCB.conf,vmlist(指定備份的 guest os 列表)
我用 ghettoVCB 備份 Guest OS,新增獨立的 conf 檔......也會被清除所以也要備份
5........有遇到再繼續補充

以上的檔案都已備份到 /vmfs/volumes/datastore1/(這裡的檔案一定不會被還原)


/etc/rc.local.d/local.sh,讓系統重啟後執行還原自訂的設定檔(local.sh 檔案重啟 ESXI 不會被還原):
/etc/rc.local.d/local.sh 新增要執行的動作:
#backup crond
/vmfs/volumes/datastore1/crondtab.sh

#Open firewall SMTP (ghettovcb 備份後寄送 e-mail,所以要開通 firewall,裡面還包含後續新增開通的 rules)
/vmfs/volumes/datastore1/firewall.sh

#localtime(從 Ubuntu 16.04 拿來替代的檔案)
/vmfs/volumes/datastore1/re-localtime.sh

#ghettoVCB
/vmfs/volumes/datastore1/re-ghettovcb.sh


四個 Srcitp 檔案內容(檔案需可執行權限 755 OR 555):
crondtab.sh 內容:
#!/bin/sh
#add backup crond shell
/bin/kill $(cat /var/run/crond.pid)
cp /vmfs/volumes/datastore1/crontabsroot /var/spool/cron/crontabs/root
/usr/lib/vmware/busybox/bin/busybox crond

firewall.sh 內容:
#!/bin/sh
#Firwall rules
rm -rf /etc/vmware/firewall/service.xml
cp /vmfs/volumes/datastore1/service.xml /etc/vmware/firewall/
esxcli network firewall refresh

re-localtime.sh 內容:
#!/bin/sh
#Restore localtime file
rm -rf /etc/localtime
cp /vmfs/volumes/datastore1/localtime /etc/

re-ghettovcb.sh 內容:
rm -rf /opt/ghettovcb/bin/ghettoVCB.sh /opt/ghettovcb/bin/ghettoVCB-restore.sh
cp /vmfs/volumesdatastore1/ghettoVCB.sh /opt/ghettovcb/bin/
cp /vmfs/volumesdatastore1/ghettoVCB-restore.sh /opt/ghettovcb/bin/
cp /vmfs/volumesdatastore1/ghettoVCB.conf /opt/ghettovcb/
cp /vmfs/volumesdatastore1/vmlist /opt/ghettovcb/

系統 /var/spool/cron/crontabs/root 檔案內容:
30 1 * * 2,4,6 /opt/ghettovcb/bin/ghettoVCB.sh -g /opt/ghettovcb/ghettoVCB.conf -f /opt/ghettovcb/vmlist -l /tmp/vmbackup_$(date +%F_%H-%M).log > /dev/null
40 3 * * * /etc/init.d/snmpd restart > /dev/null 2>&1    
##發現 snmp 有時候會停掉,所以加入每天 03:40 重啟服務

/etc/vmware/firewall/service.xml 新增的內容:
  <service id='0044'>
    <id>VIC Outgoing</id>
    <rule id='0000'>
      <direction>outbound</direction>
      <protocol>tcp</protocol>
      <port type='dst'>2377</port>
    </rule>
    <enabled>true</enabled>
    <required>true</required>
  </service>

  <service id='0045'>
    <id>SMTP client</id>
      <rule id='0000'>
        <direction>outbound</direction>
        <protocol>tcp</protocol>
        <porttype>dst</porttype>
        <port>25</port>
      </rule>
    <enabled>true</enabled>
    <required>true</required>
  </service>





沒有留言:

張貼留言

ManageEngine EventLog Analyzer版本更新步驟

更新檔下載位址: Upgrade to Latest Version of EventLog Analyzer Build (manageengine.com) 先將下載的更新檔上傳到主機裡,再進行下列動作。 切換到 ManageEngine EventLog Analyzer ...