# GCP Console 共筆 ## Compute Engine 所有 GCE 相關設定都在這裡 >GCE : `Google Compute Engine` 的簡稱,是由 GCP 提供的 VM 及相關資源 ![](https://i.imgur.com/Jja7WX4.png) ### 創建個體 #### 筆記 - 區域- 影響可共用的==網路介面== ~e.g.~ ~台灣~ - 機器設定- 機器配置, 注意 :money_with_wings: :money_with_wings: - 開機磁碟- OS、磁碟大小, 可以直接匯入image - 身分及API存取權- ```存取權範圍-> 針對各個 API 設定存取權-> Cloud 原始碼存放區=> 唯讀``` - 網路- ```網路介面-> 編輯網路介面-> 與我共用的子網路->《選擇要共用的子網路》``` - 安全性- ```安全殼層金鑰-> 新增項目->《輸入金鑰》``` ~金鑰為各跳版機SSH~ ~key~ ### 初始新個體 - terminal登入(ssh) - 檢查git套件及版本(2.x.x以上) ```git --version``` - 安裝最新版本git - 刪除舊版本 ```sudo yum -y remove git```、```sudo yum -y remove git-*``` - 安裝最新 `sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm` 、 `sudo yum install git` - ![](https://i.imgur.com/FXnsc1J.png) - 建立新路徑(資料夾) `mkdir [name]` ~e.g.~ ~mkdir~ ~Demo~ 並移至該路徑(資料夾) - `gcloud source repos clone [git source] --project=[當前專案ID]` ~e.g.~ ~gcloud~ ~source~ ~repos~ ~clone~ ~BattlePomelo_Stephen~ ~--project=gcp-20201229-002~! * 後續更新code (拉下git) `git pull` --- ## 監控(Monitoring) GCP 資源監控都在這設定 ![](https://i.imgur.com/JEEB3bw.png) --- ## 紀錄(Logging) 收集 GCP 相關服務產生的日誌 * [官方文案-記錄查詢語言](https://cloud.google.com/logging/docs/view/logging-query-language) * [將 Ops Agent 安裝在單台虛擬機上](https://cloud.google.com/logging/docs/agent/ops-agent/installation) ![](https://i.imgur.com/04R44qm.png) ### 捕捉紀錄檔 進入各台預捕捉log的機器 - 安裝 `curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh` `sudo bash add-google-cloud-ops-agent-repo.sh --also-install` * [官方文案](https://cloud.google.com/logging/docs/agent/ops-agent/installation) - 啟動 `systemctl start google-fluentd.service` - 重啟 `systemctl restart google-fluentd.service` - 停止 `systemctl stop google-fluentd.service` - 檢查狀態 `systemctl status google-fluentd.service` ![](https://i.imgur.com/zK0Ebf7.png) --- ## 網路服務 GCP 的網路相關服務,像是負載平衡,DNS CDN 等服務的設定 :::warning :exclamation: 這在我們的專案是相當重要的一塊,要多做筆記 ::: ![](https://i.imgur.com/EQU2DXk.png) * [負載平衡範例](https://hackmd.io/Ey_CyF7MSPyIErVG_Y_Tsw) --- ## Cloud Source Repo GCP 提供的 [source code repo 服務](https://hackmd.io/FbKjyNYRSmG3WNVQfUpE7g) ![](https://i.imgur.com/ivTlFMI.png) ### 新增SSH key Push Commit需要擁有SSH Keys, 進入Manage SSH Keys新增及管理 - ![](https://i.imgur.com/nHlMIci.png) - ![](https://i.imgur.com/G5DFD49.png) ### 新增存放區 ![](https://i.imgur.com/btiLSh0.png) - 建立新的存放區 ![](https://i.imgur.com/l4V9Q3E.png) - 存放區名稱-> 自定義 專案-> 搜尋game 2 #### 從本機Git存放區推送程式碼![](https://i.imgur.com/u29drLE.png) - 於本地欲存放git之路徑建立新的git - 建立==README.md==檔案 - `git add .` - `git commit -m "project init"` - 執行步驟2、3指令 ~*~ ~"google"此參數可自定義~ #### 在本機Git存放區中為您的存放區建立副本![](https://i.imgur.com/0yM2zlG.png) - 移至欲存放git的路徑 - 執行步驟2~5 --- ## 帳單 記得定期查看累積費用 >這邊 DC 有統一做監控並發送異常警告,但還是建議每天上來巡一下 ![](https://i.imgur.com/3ikHKuW.png) --- ###### tags: `GCP` `RD7` `Game2` `創新研發組`