この記事は以下のハンズオン部分です。
googlecomputeengine - Google Compute Engine 入門 - Qiita
http://qiita.com/yuko/items/460ac35d8706e8df1290
この実践をする前に準備が必要となりますので、準備がまだの方は上記を参照して下さい。
Google Cloud SDK
Google Cloud SDK とは?
- Google Cloud Platform のプロダクトに関係するコマンド類を一つにまとめたものです。それまではバラバラに配られていました。(gsutil, gcutil, bq, App Engine に関係するもの 等々 )
- 認証や共通する機能は gcloud にまとめられました。
##Google Cloud SDK コマンド
###バージョン確認
Google Cloud SDK のバージョンを確認すると、一緒に入っているコンポーネントのバージョンも表示されます。
gcutilコマンドがインストールされているか確認して下さい。
gcloud --version
コマンド実行例
~ $ gcloud --version
Google Cloud SDK 0.9.20
Copyright Google Inc. 2013.
bq 2.0.18
bq-nix 2.0.18
core 2014.04.02
core-nix 2014.03.24
dns 2014.03.24
gae-python 1.9.2
gae-python-launcher-mac 1.9.2
gcutil 1.15.0
gcutil-nix 1.13.0
gsutil 3.42
gsutil-nix 3.42
preview 2014.03.24
sql 2014.03.18
gcloud ヘルプの見方
gcloudコマンドでは以下のようにヘルプを確認することができます。
gcloud --help
コマンド実行例
~ $ gcloud --help
gcloud [optional flags] <group | command>
group is one of auth | components | config | dns | preview | sql
command is one of init | interactive | version
Manage Google Cloud Platform resources and your cloud developer workflow.
optional flags:
--project PROJECT Google Cloud Platform project to use for this
invocation.
--quiet, -q Disable all interactive prompts.
--user-output-enabled USER_OUTPUT_ENABLED
Control whether user intended output is printed to the
console. (true/false)
--verbosity VERBOSITY Override the default verbosity for this command. This
must be a standard logging verbosity level: [debug,
info, warning, error, critical, none] (Default:
[warning]).
-h, --help Print a summary help and exit.
gcloud コンポーネント詳細確認
インストールされているコンポーネントの詳細を見ることができます。
gcloud components list
コマンド実行例
~ $ gcloud components list
The following are the components available through the Google Cloud
SDK. You may choose to install one or more of the pre-configured
packages (which contain everything you need to get started), and/or
any of the individual components below.
-------------------------------------------------------------------------------
| Packages |
|-----------------------------------------------------------------------------|
| Status | Name | ID | Size |
|---------------+-----------------------------------------+------------+------|
| Not Installed | Cloud SDK for Go Developers | pkg-go | |
| Not Installed | Cloud SDK for Java Developers | pkg-java | |
| Installed | Cloud SDK Core Command Line Tools | pkg-core | |
| Installed | Cloud SDK for Python and PHP Developers | pkg-python | |
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
| Individual Components |
|-----------------------------------------------------------------------------------------------|
| Status | Name | ID | Size |
|---------------+------------------------------------------+-------------------------+----------|
| Not Installed | App Engine SDK for Go (Mac OS X, x86_64) | gae-go-darwin-x86_64 | 30.1 MB |
| Not Installed | App Engine SDK for Java | gae-java | 146.5 MB |
| Installed | App Engine Launcher Application for Mac | gae-python-launcher-mac | 7.4 MB |
| Installed | App Engine SDK for Python and PHP | gae-python | 35.9 MB |
| Installed | Big Query Command Line Tool | bq | < 1 MB |
| Installed | Cloud DNS Admin Command Line Interface | dns | < 1 MB |
| Installed | Cloud SDK Core Libraries | core | < 1 MB |
| Installed | Cloud SQL Admin Command Line Interface | sql | < 1 MB |
| Installed | Cloud Storage Command Line Tool | gsutil | 1.8 MB |
| Installed | Commands That Are In Developer Preview | preview | < 1 MB |
| Installed | Compute Engine Command Line Tool | gcutil | < 1 MB |
-------------------------------------------------------------------------------------------------
To install new components or update existing ones, run:
$ gcloud components update [component ids]
###gcloud コンポーネントアップデート
インストールされているコンポーネントをアップデートします。
gcloud components update
コマンド実行例
アップデートがある場合は以下のようになります。
~ $ gcloud components update
The following components will be updated:
-----------------------------------------------------------------------
| App Engine SDK for Python and PHP | 1.9.2 | 35.9 MB |
| BigQuery Command Line Tool | 2.0.18 | < 1 MB |
| Cloud DNS Admin Command Line Interface | 2014.04.08 | < 1 MB |
| Cloud SDK Core Libraries | 2014.04.08 | < 1 MB |
| Cloud SDK Core Libraries (Platform Specific) | 2014.04.08 | < 1 MB |
| Cloud SQL Admin Command Line Interface | 2014.04.08 | < 1 MB |
| Cloud Storage Command Line Tool | 3.42 | 1.8 MB |
| Commands That Are In Developer Preview | 2014.04.08 | < 1 MB |
| Compute Engine Command Line Tool | 1.15.0 | < 1 MB |
-----------------------------------------------------------------------
Do you want to continue (Y/n)? y
Creating update staging area...
Uninstalling: App Engine SDK for Python and PHP ... Done
Uninstalling: Big Query Command Line Tool ... Done
Uninstalling: Cloud DNS Admin Command Line Interface ... Done
Uninstalling: Cloud SDK Core Libraries ... Done
Uninstalling: Cloud SDK Core Libraries (Platform Specific) ... Done
Uninstalling: Cloud SQL Admin Command Line Interface ... Done
Uninstalling: Cloud Storage Command Line Tool ... Done
Uninstalling: Commands That Are In Developer Preview ... Done
Uninstalling: Compute Engine Command Line Tool ... Done
Installing: App Engine SDK for Python and PHP ... Done
Installing: BigQuery Command Line Tool ... Done
Installing: Cloud DNS Admin Command Line Interface ... Done
Installing: Cloud SDK Core Libraries ... Done
Installing: Cloud SDK Core Libraries (Platform Specific) ... Done
Installing: Cloud SQL Admin Command Line Interface ... Done
Installing: Cloud Storage Command Line Tool ... Done
Installing: Commands That Are In Developer Preview ... Done
Installing: Compute Engine Command Line Tool ... Done
Creating backup and activating new installation...
Done!
gcloud 認証
Googleへの認証をセットします。
gcloud auth login
コマンド実行例
~ $ gcloud auth login
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?scope=https% 〜
自動的にブラウザが表示されるので認証して下さい。
もし、自動でブラウザが起動しない場合は、そのURLをブラウザにコピーアンドペーストし承認をして下さい。
Google Cloud SDK を仮想マシンの上で実施している場合は、仮想マシン上のブラウザを利用して下さい。
承認が成功するとコンソールに以下の表示が出ます。
自分のProjectIDを入れてEnterして下さい。
プロジェクトIDは下記で確認できます。https://cloud.google.com/console
You can view your existing projects and create new ones in the Google
Developers Console at: https://console.developers.google.com. If you
have a project ready, you can enter it now.
Enter your Google Cloud project ID (or leave blank to not set): プロジェクトID
You are logged in as xxxxx@gmail.com.
これで認証が完了です。