NTTPCコミニュケーションズ社の提供する仮想専用のVPSサービスWebARENA/Indigoは、VPSで使えることや価格の安さに加えてAPIでの操作に対応している点がポイントです。1vCPU/1GB memory/20GB SSDスペックのエントリモデルの場合、1時間当たり0.55円・月額349円です。Linuxサーバーのチェック環境やテスト環境には便利です。
WebARENA / Indigoの特徴
- VPS
- 利用できるOS限定 ( CentOS7 / Ubuntu )
- Firewall機能あり
- スナップショット機能あり
- GUIはシンプル
- 現状の運用ゾーンは東京のみ
- データ転送量の制限あり
- サーバーにはグローバルIPが直接アサイン( IPは1個のみ )
- ネットワークインターフェース名 ifcfg-eth0
- RestAPIに対応
- 運用基盤KVM
- サポートなし
GUI
WebARENA サービス項目からアクションを選択
Indigoの画面
作業手順
- ネットワーク管理(Firewallの設定)
- SSHキーの作成
- インスタンスの作成
- APIキーの作成(必要に応じて)
Firewallを作成
インバウンド&アウトバウンドのポリシーを設定します
SSH鍵の作成
SSHキーは新規作成の他に、既存のSSHキーをインポートも出来ます
インスタンスの作成
- スペックを選択
- OSを選択(CentOS / ubuntu )
- SSH鍵を選択
- 運用するリージョンを選択
1分程度でインスタンスが作成されます
インスタンスのパワーオン
アクセス
例
- SSH鍵ファイル名 webarena-indigo-ssh
- IPアドレス 40.2.22.4
- インスタンス名 centos75-test
- centos のアカウント名 centos
- ubuntuのアカウント名 ubuntu
teraterm などを利用してCentOSのVPSへアクセス
centosのデフォルトユーザーは、centos です
- ユーザー名 centos を入力
- 秘密鍵の key file 指定 例 webarena-indigo-ssh
もしくは
Cygwinなどでのアクセス
SSH鍵ファイルのモードを適切に設定します
1 2 3 4 5 6 7 8 9 |
[root@remoto-client]# chmod 600 webarena-indigo-ssh [root@remoto-client]# ssh -i webarena-indigo-ssh 40.2.22.4 -l centos [centos@centos75-test]$ sudo su -l [root@centos75-test]# pwd /root [root@centos75-test]# |
コンソールからのログインやリモートログイン
外部のWAN側からサーバーにアクセス出来ない場合などでも、コンソールからログインを出来るようにしておくと、何らかの障害でWANからサーバーにアクセス出来ないケースでもコンソールからログイン出来ます。
root ログイン許可 / ssh でのパスワード認証許可の設定
cloud.init の設定変更
/etc/cloud/cloud.cfg ファイルの2か所を
1 2 |
disable_root: 0 ssh_pwauth: 1 |
へ変更
rootのパスワード設定
1 2 3 4 5 6 |
[root@centos75-test]# passwd Changing password for user root. New password: ← パスワードの入力 Retype new password: ← パスワードの再入力 passwd: all authentication tokens updated successfully. [root@centos75-test]# |
sshやリモートコンソールからのログイン
root ログイン許可 / ssh でのパスワード認証許可の例
/etc/ssh/sshd_config ファイルの以下の項目を設定
1 2 |
PermitRootLogin yes PasswordAuthentication yes |
へ変更
sshd の再起動
1 2 |
[root@centos75-test ~]# systemctl restart sshd [root@centos75-test ~]# |
VNC コンソールからのログイン
リモートからのログイン
1 2 3 4 |
[root@remoto-client]# ssh 40.2.22.4 -l root root@40.2.22.4’s password: ← パスワードの入力 Last login: Mon Nov 21 10:02:50 2019 [root@centos75-test]# |
SWAP追加
デフォルトのインスタンスではワンパーティションの為にメモリスワップは有りません。
メモリスワップはHDDを利用しますので、スワップのサイズなどは適宜調整ください。
/etc/rc.d/rc.local へ記述の例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
--- 標準ではスワップは設定されていません --- [root@centos75-test]# free total used free shared buff/cache available Mem: 1015396 83096 778440 13216 153860 765756 Swap: 0 0 0 --- スワップの設定例 --- [root@centos75-test]# cat /etc/rc.d/rc.local #!/bin/bash touch /var/lock/subsys/local # --- add swapfile 2GB --- SWAPFILE=/swapfile if [ -e $SWAPFILE ] ; then swapon $SWAPFILE else dd if=/dev/zero of=$SWAPFILE bs=1024K count=2048 chmod 600 $SWAPFILE mkswap $SWAPFILE swapon $SWAPFILE fi [root@centos75-test]# chmod 755 /etc/rc.d/rc.local [root@centos75-test]# reboot |
再起動後 swapが有効
1 2 3 4 5 |
[root@centos75-test]# free total used free shared buff/cache available Mem: 1016396 148620 202144 51448 665632 620504 Swap: 2097148 7952 2089196 [root@centos75-test]# |
APIキーの作成
RestAPIに対応しています
API秘密鍵を「カットアンドペースト」で自分の端末側のファイルとして保存
例 webarena-indigo-ssh.key
RestAPIの操作
accessTokenやインスタンスIDは事前に入手してしておきます
アクセストークンの入手 例
API鍵 clientidとAPI秘密鍵 clientsecret キーを入れて実行
アクセストークンを入手
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@remoto-client]# ./1st-start.sh | jq . + curl -X POST https://api.customer.jp/oauth/v1/accesstokens -H 'Content-Type: application/json' -d '{ "grantType": "client_credentials", "clientId": "<span style="background-color: #00ff00;">eawBwrlIGV9iPSAVDUPLgx1TR2g</span>", "clientSecret": "<span style="background-color: #00ff00;">TNB6n6bWvug</span>", "code": "" }' { "accessToken": "<span style="background-color: #ffff99;">AB2N13a5xrv3gGhpUACVZMXXb</span>", <<-- アクセストークン "tokenType": "BearerToken", "expiresIn": "3299", "scope": "READWRITE", "issuedAt": "1973555407312" } [root@remoto-client]# |
インスタンスの削除
上記で得られたアクセストークンを入れて実行
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@remoto-client]# ./delete-instance.sh | jq . + curl -X POST https://api.customer.jp/webarenaIndigo/v1/vm/instance/statusupdate -H 'Authorization: Bearer <span style="background-color: #ffff00;">AB2N13a5xrv3gGhpUACVZMXXb</span>' -H 'Content-Type: application/json' -d '{"instanceId":917, "status":"destroy"}' { "success": true, "message": "<span style="color: #000000; background-color: #00ff00;">Instance has been destroyed successfully</span>", "sucessCode": "I20010", "instanceStatus": "shutoff" } [root@remoto-client]# |
その他
network インターフェース名は ifcfg-eth0 です
アプリによっては、インターフェース名に依存するものがあります
1 2 3 4 5 6 7 |
[root@centos75-test]# pwd /etc/sysconfig/network-scripts [root@centos75-test]# ls -l ifcfg-eth0 -rw-r--r--. 1 root root 487 10月 30 16:39 ifcfg-eth0 [root@centos75-test]# |
現状では、WebARENA 「 Indigo」にはロードバランサー機能は提供されておりません。上位のサービスWebARENA 「 VPS」では、ロードバランサーを利用できます。