Google Compute Engine HAproxy高可用度 - Linux

Michael avatar
By Michael
at 2018-03-15T10:35

Table of Contents

請問各位版友
有人在Google Compute Engine
用兩個VM架設過Keepalived+HAproxy的設計嗎
我在AWS有架設成功,參考此篇文章
https://goo.gl/QEteZQ
此篇文章是google internal load balance文章(因為不是external但有參考價值)
https://cloud.google.com/solutions/best-practices-floating-ip-addresses

我也是參考
https://goo.gl/QEteZQ
這寫類似的script檔案,讓兩個instance VM(haproxy-a與haproxy-b)
共用一個固定靜態IP
notify_master /etc/keepalived/failover.sh
----------------------
這是我在google compute engine haproxy-a裡的failover.sh
----------------------
currentserver="haproxy-b"
currentzone="us-central1-c"
accessConfigName=$(gcloud compute instances describe $currentserver \ --zone $currentzone | awk -F "name: " '$2 == "external-nat" || $2 == "External NAT" {print $2}')
gcloud compute instances delete-access-config $currentserver --access-config-name $accessConfigName --zone $currentzone gcloud compute instances add-access-config $currentserver --zone $currentzone
currentip="104.198.xx.xx"<---換此靜態固定IP
^^^^^^^^^^^^^^^^^^^^^^^^^
currentserver="haproxy-a"
currentzone="us-central1-f"
accessConfigName=$(gcloud compute instances describe $currentserver --zone $currentzone | awk -F "name: " '$2 == "external-nat" || $2 == "External NAT" {print $2}')
gcloud compute instances delete-access-config $currentserver --access-config-name $accessConfigName --zone $currentzone
gcloud compute instances add-access-config $currentserver --address $currentip --zone $currentzone
----------------------


在下此指令之後(在VM裡面下,有別於google cloud shell)
gcloud compute instances delete-access-config $server \
--access-config-name $accessConfigName --zone $currentzone

已經把ip位置刪除,接下來要執行以下的換固定靜態IP的指令就失敗了
^^^^^^^^^^^^^^^^

應該是沒有IP位置就不在執行以下指令
gcloud compute instances add-access-config $server --address $currentip

希望有人有更好的建議,謝謝大家

--
Tags: Linux

All Comments

那些資料夾可以放在 LVM ?

Zenobia avatar
By Zenobia
at 2018-03-14T15:58
最近在研究 LVM 建立跟設定 大多數找到的好像都是已經裝好系統在設定 LVM 不過還是有找到開機的時候就設定 LVM 的文章 這是安裝系統 http://mistech.pixnet.net/blog/post/178426682-oracle-linux-install-using-lvm https: ...

一條完整的 mail 紀錄?

Eartha avatar
By Eartha
at 2018-03-13T21:49
最近在查詢 mail log 主要服務是 exim 雖然找出 mail 的 ID 但是要搜尋這個ID 的寄件 IP 我就抓瞎了~Orz 這是我用 mail ID 查詢的紀錄 https://ideone.com/Zc3HlC (Sorry , 發信主機的 IP 跟 username 拿掉了) 但是不知道要怎 ...

不明的 httpd 啟動?

William avatar
By William
at 2018-03-13T09:25
這兩天在檢查主機的時候 看見一堆奇怪的 apache 啟動項目 一連串的 /usr/sbin/httpd -k start 系統是 centos + cpanel 有時候還會造成 CPU 負載過重 有想過是不是有人在大量 loading 查過 cpanel 的設定 /usr/local/cpanel/ ...

Linux bash 語法問題

Elma avatar
By Elma
at 2018-03-12T20:46
#!/bin/bash if [$(cat ~/.bashrc |grep python3)=*and#39;$HOME/python3/binand#39;*];then sudo source ~/.bashrc python3 -V else echo and#34;and#34; ech ...

lubuntu無法開機

Una avatar
By Una
at 2018-03-11T15:03
剛剛安裝完VMware player workstation後 重開機便出現這樣的錯誤 recovery mode 也是同樣的問題 請問該如何解決 謝謝! http://i.imgur.com/ufOTFrc.jpg http://i.imgur.com/aPc771h.jpg ----- Sent fr ...