2013年6月10日 星期一

Appfog 在 AWS-Asia in Singapore 上配置 MySQL 服務失敗問題

前天為了試一下 Appfog 上的 af delete 指令, 順便把舊的上傳檔案清除乾淨, 就把已申請好, 可以正常使用的 snowball 應用程式刪除掉了, 然後重新佈署新的程式, 但這回沒這麼順利了, 進行到 creating service 時就發生錯誤, 訊息如下 : 

E:\snowball>af push
[WARNING] DL is deprecated, please use Fiddle
Would you like to deploy from the current directory? [Yn]: y
Pushing application 'snowball'...
Creating Application: OK
Creating Service [mysql-c1e30]: Error 503: Unexpected response from service gateway

即使跳過自動產生 MySQL 服務程序先完成 App 部署, 然後再用 create-service 指令來手動產生 MySQL 服務也不行 :

E:\snowball>af create-service mysql snowball

都會出現 Error 503 錯誤. 換個方式到 Appfog 網站登入後, 用網頁方式產生 MySQL 服務也是一樣失敗, 出現如下一樣的錯誤 :

name: VmcError, endpoint: POST:/services, statusCode: 502, code: 503, description: Unexpected response from service gateway

寫了一封信給 support@appfog.com, 但是好幾天了都沒人理我 (是因為 Free 用戶嗎? 這讓我對 Appfog 的好印象已經開始打折 ...). 好吧, 或許是這帳號有甚麼問題, 重新申請一個新帳號試試看, 結果還是一樣. 後來在 doc 中發現 create-service 指令可以指定主機位置 (--infra 選項), 我試著用下列指令, 指定把 MySQL 服務建在其他基礎上, 例如 AWS US East - Virginia 就可以順利建立, 但是唯獨在 AWS Asia SE - Singapore (代號 ap-aws) 就會失敗, 可見新加坡的主機有問題. 指令如下 :

E:\snowball>af create-service mysql snowball --infra aws

此指令是在 AWS US East - Virginia 主機 (代號 aws) 上建立一個 MySQL 資料庫 snowball, 各主機代號如下 (參考 How to use AppFog’s multi-infrastructure architecture in the command line) :

1: AWS US East - Virginia (aws)
2: AWS EU West - Ireland (eu-aws)
3: AWS Asia SE - Singapore (ap-aws)
4: HP AZ 2 - Las Vegas (hp)

建好 MySQL 資料庫後, 就可以用 af bind-service 指令把應用程式聯繫到 MySQL 資料庫 :

E:\snowball>af bind-service snowball snowball

其中第一個 snowball 是指資料庫名稱, 第二個 snowball 是 App 名稱. 經過這樣處理就 OK 了. 但是要注意的是, App 與 Service 必須都位於同一個 infrastructture 才能 bind 起來, 否則會出現]如下訊息 :

E:\snowball>af bind-service snowball snowball
[WARNING] DL is deprecated, please use Fiddle
Binding Service [twstockbot]: Service snowball and App snowball are not on the same infra

所以我只好先把建在新加坡的 App 刪除, 重新 push 時選擇美國東部維吉尼亞的主機來佈署 App 以與 MySQL 配合.

但是我發現網頁速度似乎有比新加坡主機要慢一些, 不過至少可以用啦.
參考網站 :
How To Manage Your AppFog Database from your Desktop on the Other Side of the World
Getting Started with AppFog’s Command Line

沒有留言 :