1 / 35

OracleLinux 灌好做完基本設定匯出 HA- node.ova 之後

OracleLinux 灌好做完基本設定匯出 HA- node.ova 之後. 第 2 台先匯 .ova 來改設定值 : ESXi5-02. 匯入 .ova: File > Deploy OVF Template > Deploy from a file or URL OVF Template Details: ova 範本檔細節 Name: apache02 Disk Format: 不用改. Network Mapping : 應該會配對成功 若有紅字 , 表示之前 Service 或 DRBD-Heartbeat 打錯字  請手動配對正確.

marlee
Download Presentation

OracleLinux 灌好做完基本設定匯出 HA- node.ova 之後

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OracleLinux灌好做完基本設定匯出HA-node.ova之後

  2. 第2台先匯.ova來改設定值: ESXi5-02 • 匯入.ova: • File > Deploy OVF Template > Deploy from a file or URL • OVF Template Details: • ova範本檔細節 • Name: apache02 • Disk Format: 不用改

  3. Network Mapping: 應該會配對成功若有紅字,表示之前Service 或DRBD-Heartbeat打錯字  請手動配對正確

  4. Network Mapping: 就配對成功了

  5. Ready to Complete • 確定都ok了後,勾”Power on after deployment”. > Finish 開機.

  6. apache02開機後 • 1.) 改hostname: apache02.abc.com • /etc/sysconfig/network • hostname=apache02.abc.com • 2.) bond0 ip: 改為10.10.88.112 • 原為101 bond1 ip: 改為192.168.88.112 • 原為101 重啟網路 service network restart 網路還是不通!! 因為 eth0 1 2 3  4 5 6 7

  7. apache02開機後 • 網卡變為 eth4 5 6 7 > 辛苦一點,改回 eth0 1 2 3 (mac要配對) • 查網卡名稱變化 • dmesg | grep eth0 • dmesg | grep eth1 • dmesg | grep eth2 • dmesg | grep eth3 • ip a > mac.txt, 然後以 vim (split編修) • 重點是要改煩人的 70-perXXX • eth0 1 2 3 換回正確的 mac • 有時在ping的response顯示有「DUP!」,表明存在loop.(因為有 host-only關係) • 改好後reboot • win7 test ping apache02.abc.com (10.10.88.112) • test ifdown eth0 • win7 test ping 192.168.88.112 • test ifdown eth2

  8. apache02開機後 • 網卡變為 eth4 5 6 7 > 辛苦一點,改回 eth0 1 2 3 (mac要配對) • 查網卡名稱變化 • dmesg | grep eth0 • dmesg | grep eth1 • dmesg | grep eth2 • dmesg | grep eth3 • ip a > mac.txt, 然後以 vim (split編修) • 重點是要改煩人的 70-perXXX • eth0 1 2 3 換回正確的 mac • 有時在ping的response顯示有「DUP!」,表明存在loop.(因為有 host-only關係) • 改好後reboot • win7 test ping apache02.abc.com (10.10.88.112) • test ifdown eth0 • win7 test ping 192.168.88.112 • test ifdown eth2

  9. apache01開機 • 1.) 改hostname: apache01.abc.com • /etc/sysconfig/network • hostname=apache01.abc.com • 2.) bond0 ip: 改為10.10.88.111 • 原為101 bond1 ip: 改為192.168.88.111 • 原為101 重啟網路 service network restart •  一樣不通,eth4567要改回0123,同apache02

  10. /etc/hosts on apache01 & 02 • 10.10.88.111 apache01.abc.com apache01 • 10.10.88.112 apache02.abc.com apache02 • ftp://120.125.145.81/ha/hosts_apache.txt

  11. apache01 & 02以 hostname互ping必須會通 • 01 ping 02 service卡 • apache01# ping apache02.abc.com • 01 ping 02 DRBD-Heartbeat卡 • apache01# ping 192.168.88.112 • 02 ping 01 service卡 • apache02# ping apache01.abc.com • 02 ping 01 DRBD-Heartbeat卡 • apache02# ping 192.168.88.112

  12. apache01 & 02安裝 apache • yum -y install httpd

  13. DRBD 設定檔 /etc/drbd.con01 & 02都要改 • (Distributed Replicated Block Device) • Network RAID-1 • 01 & 02: 修改drbd.conf設定檔(apache01 & 02內容相同) • ftp://120.125.145.81/ha/drbd.conf.txt

  14. /etc/drbd.conf • resource ha DRBD資源名稱:ha • DRBD同步速率為100Mbps(bits),單.conf中的單位為bytes除以8,取約略10Msyncer { rate 10M; } • apache01 server資訊on apache01.abc.com { device /dev/drbd0; //device名稱,用來代表 /dev/sda5,就是/data disk /dev/sda5; // “/data”的partition,可用fdisk -l查 address 192.168.88.111:7788; //drbd同步ip & port meta-disk internal;} • apache02 server資訊,意義同上

  15. 修改DRBD相關執行檔權限 • ftp://120.125.145.81/ha/change_per_drbd.txt • chgrphaclient /sbin/drbdsetup • chmod o-x /sbin/drbdsetup • chmodu+x /sbin/drbdsetup • chgrphaclient /sbin/drbdmeta • chmod o-x /sbin/drbdmeta • chmodu+x /sbin/drbdmeta • 目的是讓後續建DRBD資源時,可以順切執行相關指令

  16. 載入 drbd模組並建立 resource01 及 02 都必須做 • modprobe指令載入drbd模組 (locate drbd.ko確認有此module) • modprobedrbd • 確認 drbd模組是否載入 • lsmod|grepdrbd • 執行drbd之前,必須塞一些資料到/dev/sda5內,否則create-md時會出現錯誤 • dd if=/dev/zero of=/dev/sda5 bs=1M count=100 • sda5就是/data的partition • 載入drbd moduleok後,建立 drbd resource, 指令 • drbdadm create-md 資源名稱,因為在 drbd設定檔(drbd.conf)中 resource 名稱為 ha 所以上述的資源名稱就是以ha取代,指令如下:drbdadm create-md ha (執行成功後,可以以 ctrl+c跳出) • 啟動 drbd服務 • service drbd start • 設定 drbd開機時自動啟動 • chkconfigdrbd on • 所有指令: • ftp://120.125.145.81/ha/drbd_load_mo_create_rs.txt

  17. 上一頁,指令匯整(01 & 02都要做) • modprobedrbd //載入 drbd模組 • lsmod|grepdrbd //確認 drbd模組是否載入 • dd if=/dev/zero of=/dev/sda5 bs=1M count=100//執行drbd之前,必須塞一些資料到/dev/sda5內(否則 create-md 時會出現錯誤) • drbdadm create-md ha //建立 drbd resource • service drbd start //啟動 drbd服務 • chkconfigdrbd on //設定 drbd開機時自動啟動

  18. drbd狀態檢視 • drbd啟動後可用 service drbdstatus查看目前 drbd的狀態 • service drbd status • 當01啟動 drbd服務而02尚未啟動時, 狀態為 Secondary/Unknown當02也啟動 drbd服務後,狀態為 Secondary/Secondary,而 ds 狀態為 Inconsistent 表示二台主機資料尚未同步

  19. 01: 先啟動drbd • 01: watch service drbd status • 02: service drbd start  觀察 01 drbd status • 01: service drbd stop  觀察 01 drbd status • drbd成功連線後,兩者role都是Secondary • 目前沒有開始同步,沒有任一server是primary • Active node的drbd資源角色即為primary • Standby node的drbd資源角色即為secondary • ds (data state)狀態為 Inconsistent • 表示二台主機資料尚未同步

  20. 只有apache01要做:初始化apache01的/dev/sda5(即/data的掛載partition)只有apache01要做:初始化apache01的/dev/sda5(即/data的掛載partition) • 同時,提昇apache01為primary(即active)並開始同步 /dev/drbd0就是/dev/sda5 • 確定01及02 都可偵測到對方 (drbd state roll: Secondary/Secondary),將01設為 Primary(active) Node(與上一句話同義) • 並使二台主機開始同步/dev/sda5硬碟資料(也就是/dev/drbd0) • 此時查看 drbd狀態可發現同步的百分比及進度(只有01需要執行)

  21. 初始化apache01的/dev/sda5,指令: • drbdadm -- --overwrite-data-of-peer primary ha • ftp://120.125.145.81/ha/drbd_init_dev_sda5_only_apache01.txt • 馬上在01&02執行: • watch service drbd status觀察同步的百分比,可看到 兩邊跑的速度是一樣的 • 當同步完成後,可發現二台主機的 ds 狀態都為 UpToDate (service drbd status) • 表示同步完成,二台主機擁有相同且最新的資料 • 如影片: http://youtu.be/tkyVp76w2ck?hd=1 • 也可看出 “左邊是自己角色/右邊是對方角色” • 01: Primary, 02: Secondary

  22. 只有01要執行格式化(mkfs.ext4) /dev/sda5 • 剛剛在drbd.conf中: • device /dev/drbd0;disk /dev/sda5;已設定 /dev/drbd0指的就是/dev/sda5 • 01 及 02都完成資料同步作業後(即 /dev/drbd0 完成初始化),將/dev/drbd0(/dev/sda5)格式化(mkfs.ext4),格式化完成後將/dev/drbd0掛載至 /data,指令如下: • mkfs.ext4 /dev/drbd0 • mount /dev/drbd0 /data • df -h • 可看到 /data 已 mount成功到/dev/drbd0 (即/dev/sda5) • 在01看drbd status: • service drbd status • 可看到掛載點 /data與檔案系統 ext4已出現,如下頁

  23. 01 & 02都要修改apache設定檔 • locate httpd.conf • 兩處:“/var/www/html”改為”/data” • DocumentRoot"/var/www/html“ • <Directory "/var/www/html">

  24. 只在01:啟動apache • service httpd start • echo “<h1>hello jj</html>” > /data/index.html • win7 test: http://apache01.abc.com

  25. (Only 01)確定apache01可正確http連線後,開始Heartbeat前 • stop apache • service httpd stop • 卸載 /dev/drbd0(就是drbd mount point) • umount /dev/drbd0 • 把apache01的資源角色從Primary降為Secondary node,否則待會兒Heartbeat會無法順切執 • drbdadm secondary ha • service drbd status • apache drbd角色已變為Secondary

  26. Heartbeat • 2台 HA Server,其中一台會產生一個cluster ip,擁有cluster ip的 active node會回應client users的要求,當故障轉移(failover)時,新的active node會接手該cluster ip,並更新arp cache中cluster ip所對應的mac(改成自己的mac,client就可以”無斷線感地”持續要求服務.

  27. 01 & 02都要設定 /etc/ha.d/ha.cf(Heartbeat通訊檔) • 其實偵測對方是否死掉,就是用簡單的ping而已 • 每隔2秒互ping對方一次 • 超過15秒對方沒有回應,就認定對方死了 • 兩台server的Heartbeat通訊設定檔為 • /etc/ha.d/ha.cf (原無此檔) • ftp://120.125.145.81/ha/ha.cf.txt

  28. 01的/etc/ha.d/ha.cf • debugfile /var/log/ha-debug //Heartbeat服務除錯記錄檔 • logfile /var/log/ha-log //Heartbeat服務記錄檔logfacilitylocal0 • autojoin none • ucastbond0 10.10.75.112 //指定對方(apache02)的bond0 ip (service) • ucastbond1 192.168.75.112//指定對方(apache02)的bond1 ip (drbd+heartbeat) • ping 10.10.75.254 ////IP 連線偵測用,設定區網內的 Gateway (當網路或 Heartbeat 失效時測試用 • (因為有可能是 heartbeat掉了而已,所以ping一下gw是否還是通的) • respawnhacluster /usr/lib/heartbeat/ipfail • respawnhacluster /usr/lib/heartbeat/dopd • apiauthdopdgid=haclientuid=hacluster • udpport694 // 使用 udp, port 694來 做通訊 • warntime5 //網路disconnect超過5秒就warn • deadtime15 // 網路disconnect超過15秒,就判定對方主機失效 • initdead60 //初始化超過60秒沒有連上對方,就判定 heartbeat 一開始就沒有成功 • keepalive2 //每2秒互ping對方是否還活著 • node apache01.abc.com // 第一台 • node apache02.abc.com // 第二台 • auto_failbackoff // Active node 恢復也不會搶回主控權

  29. 02的/etc/ha.d/ha.cf • debugfile /var/log/ha-debug //Heartbeat服務除錯記錄檔 • logfile /var/log/ha-log //Heartbeat服務記錄檔logfacilitylocal0 • autojoin none • ucastbond0 10.10.75.111 //指定對方(apache01)的bond0 ip (service) • ucastbond1 192.168.75.111 //指定對方(apache01)的bond1 ip (drbd+heartbeat) • ping 10.10.75.254 ////IP 連線偵測用,設定區網內的 Gateway (當網路或 Heartbeat 失效時測試用 • (因為有可能是 heartbeat掉了而已,所以ping一下gw是否還是通的) • respawnhacluster /usr/lib/heartbeat/ipfail • respawnhacluster /usr/lib/heartbeat/dopd • apiauthdopdgid=haclientuid=hacluster • udpport694 // 使用 udp, port 694來 做通訊 • warntime5 //網路disconnect超過5秒就warn • deadtime15 // 網路disconnect超過15秒,就判定對方主機失效 • initdead60 //初始化超過60秒沒有連上對方,就判定 heartbeat 一開始就沒有成功 • keepalive2 //每2秒互ping對方是否還活著 • node apache01.abc.com // 第一台 • node apache02.abc.com // 第二台 • auto_failbackoff // Active node 恢復也不會搶回主控權

  30. 01 & 02都要設的Heartbeat資源檔(兩者同) /etc/ha.d/haresources • 設定 01 & 02的 haresource資源設定檔 01 及 02 設定檔內容一模一樣, • 表示預設使用 01 主機擔任 Primary Node 角色,此設定檔內容可分為五段來看。(01 及 02 都必須設定) • 1.) active Node 的 FQDN >> apache01.abc.com • 2.) 指定 Cluster IP Address : 10.10.88.110 • 3.) 指定 Cluster Resource Name >> drbddisk::ha • 4.) 指定 Cluster Device, Mount Point、File System Type • >> drbddisk::ha Filesystem::/dev/drbd0::/data::ext4 • 5.) 指定 Service>> Apache • haresources設定檔內容如下 • apache01.abc.com 10.10.88.110 drbddisk::ha Filesystem::/dev/drbd0::/data::ext4 Apache • ftp://120.125.145.81/ha/haresources.txt

  31. Heartbeat 驗證設定檔01 & 02均同, /etc/ha.d/authkeys • auth 1 • 1 sha1 9bc29cfe2f182c3e3ba556fc520d89c3 • ftp://120.125.145.81/ha/authkeys.txt • 600 permission: • chmod 600 /etc/ha.d/authkeys

  32. Heartbeat 監控服務設定檔01 & 02均同, /etc/ha.d/resource.d/Apache • ftp://120.125.145.81/ha/Apache.txt • Active 死掉後,standby根豦此檔決定要啟動什麼服務 • 755 permission

  33. 01 & 02新增heartbeat為系統服務 • chkconfig --add heartbeat • chkconfig heartbeaton

  34. 01 & 02 啟動 heartbeat • service heartbeat start • ifconfig bond0:0

More Related