顯示具有 gce 標籤的文章。 顯示所有文章
顯示具有 gce 標籤的文章。 顯示所有文章

2018年5月11日

google compute engine 下 CentOS 6 升級 python 2.7 產生的問題

/var/log/message 內出現大量訊息

top 顯示下面幾個程序佔用大量 CPU

手動執行後出現

想說直接把裡面的 #!/usr/bin/python 改成 #!/usr/bin/python2.6

還是不行

後來才想到當初安裝參考的文章、直接把 module 複製到新版的目錄下就好了
cp -r /usr/lib/python2.6/site-packages/google_compute_engine /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib/python2.6/site-packages/boto /usr/local/lib/python2.7/site-packages/

cp -r /usr/lib/python2.6/site-packages/google_compute_engine-2.8.1-py2.6.egg-info /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib/python2.6/site-packages/boto-2.34.0-py2.6.egg-info /usr/local/lib/python2.7/site-packages/



更新
後來發現直接下指令安裝就好了、真是昏了我.....
pip install -U boto

reference:CentOS 6.9安裝Python2.7.14
reference:How do I install boto?

2017年11月3日

用 jq 搭配 gcp cli 抓出需要的值

剛好有需求在 shell 下面處理 json 的資料、找到了 jq 這個方便的工具

gcloud 指定用 json 格式輸出搭配 jq 來取值配合 shell script 正好適合我的需求

比如取得 VM 的資訊
gcloud compute instances describe [INSTANCE_NAME] --format=json

得到下面的訊息

搭配下面的指令
jq -r '.networkInterfaces[].accessConfigs[].natIP'
整串指令是
gcloud compute instances describe [INSTANCE_NAME] --format=json | jq -r '.networkInterfaces[].accessConfigs[].natIP'

就可以直接得到目前 VM 使用的外部 IP 或其他訊息、搭配 shell script 可以做更多的動作

GCP VM 使用 gcloud 取消-取得暫時外部 IP

先取得 VM 的資訊
gcloud compute instances describe [INSTANCE_NAME]


下指令刪除目前的外部 IP
gcloud compute instances delete-access-config [INSTANCE_NAME] --access-config-name "external-nat"

成功以後取得的資訊會變成下面這樣


過個一分鐘再配發 IP 給 VM、這裡是給暫時 IP
gcloud compute instances add-access-config [INSTANCE_NAME] --access-config-name "external-nat"


就可以拿到新的暫時 IP 了


reference:https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address

2016年9月7日

Google Compute Engine 使用 root 和密碼登入

先使用 ssh key 登入後、先幫root設定密碼、然後修改 /etc/sshd/sshd_config,順便修改回應比較慢的問題

1.$ sudo passwd root
2.$ su -
3.# vi /etc/sshd/sshd_config
4.# service sshd restart


42 PermitRootLogin yes

64 PasswordAuthentication yes
66 #PasswordAuthentication no

80 GSSAPIAuthentication no
81 #GSSAPIAuthentication yes

122 UseDNS no