8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBM Cloud上にWindows Serverの仮想サーバーを作成する

Last updated at Posted at 2023-08-15

はじめに

IBM CloudのVPC(Virtual Private Cloud)にWindows Serverの仮想サーバーを作成してみたときのログです。
IBM Cloud上に作成したWindows Serverに対して、作業用のWindows PCからリモートデスクトップで接続するところまでを試してみます。

環境情報

作業用のPC: Windows11
IBM Cloud上に作成するWindows Server: Windows Server 2022

事前準備

作業用PC上の設定

参考: Windows インスタンスへの接続

仮想サーバーを作成する際、Administratorのパスワードが動的に割り当てられるようですが、それを確認するためにIBM CloudのCLI(Command Level Interface)を使えるようにしておく必要があるようです。
そのため、IBM Cloud CLIをセットアップしておきます。

IBM Cloud CLI

参考: API 環境と CLI 環境のセットアップ

PowerShellを管理者として実行

PS C:\> iex (New-Object Net.WebClient).DownloadString('https://clis.cloud.ibm.com/install/powershell')
Current platform is Win64. Downloading corresponding IBM Cloud CLI...
Download complete. Executing installer...
Install complete. Please restart to make the modification effective.
プラグインの確認
PS C:\> ibmcloud plugin repo-plugins
すべてのリポジトリーからプラグインを取得しています...

リポジトリー: IBM Cloud
状況                 名前                                            バージョン                     説明
更新が使用可能です   container-registry[cr]                          1.1.0, 1.0.11, 1.0.10...       Manage IBM Cloud Container Registry content and configuration.
未インストール       container-service[kubernetes-service/ks]        1.0.532, 1.0.531, 1.0.528...   Manage IBM Cloud Kubernetes Service clusters
未インストール       cloud-functions[wsk/functions/fn]               1.0.69, 1.0.68, 1.0.67...      Manage Cloud Functions
未インストール       cloud-internet-services[cis]                    1.15.2, 1.14.11, 1.14.9...     Manage Cloud Internet Service
未インストール       dbaas-cli[dbaas]                                2.2.4, 2.2.2, 2.2.1...         Manage Hyper Protect DBaaS clusters
未インストール       cloud-databases[cdb]                            0.16.2, 0.16.1, 0.16.0...      Manage Cloud databases
未インストール       key-protect[kp]                                 0.8.0, 0.7.0, 0.6.12...        Manage encryption keys on IBM Cloud
未インストール       doi[doi]                                        0.4.3, 0.4.2, 0.4.1...         Integrate with DevOps Insights service
未インストール       tke                                             1.3.1, 1.3.0, 1.2.3...         Manage the master key of Cloud HSMs from Hyper Protect Crypto service
未インストール       cloud-object-storage                            1.7.0, 1.6.0, 1.5.0...         Manage Cloud Object Storage service
未インストール       event-streams[es]                               2.4.0, 2.3.2, 2.3.1...         Manage Event Streams service
未インストール       power-iaas[pi]                                  0.4.8, 0.4.6, 0.4.4...         Manage Power Virtual Servers
未インストール       vpc-infrastructure[infrastructure-service/is]   6.16.0, 6.15.0, 6.14.1...      Manage Virtual Private Cloud infrastructure service
未インストール       schematics[sch]                                 1.12.10, 1.12.9, 1.12.8...     Managing IBM Cloud resources with Terraform
未インストール       cloud-dns-services[dns]                         0.7.3, 0.7.2, 0.7.1...         Manage IBM Cloud DNS Services
未インストール       dl-cli[dl]                                      0.5.8, 0.5.7, 0.5.4...         Manage Direct Link
未インストール       watson                                          0.0.11, 0.0.10, 0.0.9...       Manage Watson services
未インストール       catalogs-management                             2.3.5, 2.3.2, 2.3.0...         Manage personal catalogs and offerings
未インストール       tg-cli[tg]                                      0.8.10, 0.8.2, 0.7.1...        Manage Transit Gateway service
未インストール       observe-service                                 1.0.82, 1.0.61, 1.0.54...      Manage logging and monitoring configurations for IBM Cloud Kubernetes Service clusters
未インストール       code-engine[ce]                                 1.45.1, 1.45.0, 1.44.0...      Manage Code Engine components
未インストール       hpvs                                            1.4.24, 1.4.23, 1.4.22...      Manage Hyper Protect Virtual Server service
未インストール       secrets-manager[sm]                             2.0.1, 2.0.0, 0.1.25...        Manage IBM Cloud Secrets Manager secrets and secret groups.
未インストール       app-configuration[ac]                           1.0.12, 1.0.11, 1.0.10...      Interact with IBM Cloud App Configuration service instance
未インストール       monitoring                                      0.2.14, 0.2.13, 0.2.12...      Manage IBM Cloud monitoring
未インストール       logging                                         0.0.8, 0.0.7, 0.0.6...         Manage IBM Cloud logging
未インストール       cloudant[cl]                                    0.0.9, 0.0.8, 0.0.7...         Manage Cloudant service
未インストール       hpcs-cert-mgr[hpcs-cert-mgr]                    1.0.0                          Manage the client certificates for IBM Cloud Hyper Protect Crypto Services
未インストール       atracker[at]                                    0.3.6, 0.3.4, 0.3.3...         Manage IBM Cloud Activity Tracker Event Routing
未インストール       analytics-engine-v3[ae-v3]                      2.4.0, 2.3.0, 2.2.0...         Manage serverless Spark instances and run applications
未インストール       cra[cra]                                        1.3.7, 1.3.6, 1.3.5...         Integrate with Code Risk Analyzer
未インストール       event-notifications[en]                         1.0.1, 1.0.0, 0.2.1...         IBM Cloud Event Notifications.
未インストール       dvaas[watson-query]                             1.0.2                          Manage data virtualization as a service
未インストール       hpnet                                           1.0.2, 1.0.1                   Manage Hyper Protect Secure Network
未インストール       qiskit-runtime[qr]                              0.1.5                          [Beta] Manage Qiskit Runtime
未インストール       hpcs                                            0.0.1                          Manage Hyper Protect Crypto Services Instances
未インストール       cbr                                             1.3.0, 1.2.0, 1.1.0...         Manage Context Based Restrictions
未インストール       privileged-access-gateway[pag]                  1.2.9, 1.2.8, 1.2.6...         Manage Privileged Access Gateway
未インストール       project                                         0.0.11, 0.0.9, 0.0.8...        Manage Infrastructure as Code in IBM Cloud.
未インストール       metrics-router[mr]                              0.0.33, 0.0.31, 0.0.30         Manage IBM Cloud Metrics Routing

C:\Program Files\IBM\Cloud\bin\ibmcloud.exe plugin update PLUGIN_NAME -r REPO_NAME を使用して、リポジトリーからプラグインを更新します。
C:\Program Files\IBM\Cloud\bin\ibmcloud.exe plugin update --all -r REPO_NAME を使用して、リポジトリーからすべての使用可能なプラグインをアップグレードします。

VPC CLI プラグイン(vpc-infrastructure)をインストール

PS C:\> ibmcloud plugin install vpc-infrastructure
リポジトリー 'IBM Cloud' から 'vpc-infrastructure' を検索しています...
プラグイン 'vpc-infrastructure[infrastructure-service/is] 6.16.0' がリポジトリー 'IBM Cloud' 内で見つかりました
バイナリー・ファイルをダウンロードしようとしています...
 21.69 MiB / 21.69 MiB [======================================================================================================================================================] 100.00% 12s
22744064 バイトがダウンロードされました
バイナリーをインストールしています...
OK
プラグイン 'vpc-infrastructure 6.16.0' は C:\Users\A00527JP6\.bluemix\plugins\vpc-infrastructure に正常にインストールされました。 'C:\Program Files\IBM\Cloud\bin\ibmcloud.exe plugin show vpc-infrastructure' を使用して詳細を表示してください。

IBM Cloud上の設定

リソース・グループ

参考: リソースを編成してアクセス権限を割り当てるためのベスト・プラクティス

VPC上に仮想サーバーやストレージなどを構成する際、それら構成されたリソースに対してアクセス制御を容易に行うために、用途の同じリソースをグループ化して管理することができます。そのグループ化の単位をリソース・グループと呼んでいます。
事前にリソース・グループを作成しておきます。(ここでは詳細は割愛)

VPC, サブネット

参考: VPC概要

IBM Cloudには仮想的なプライベート・クラウド環境を提供するVPC(Virtual Private Cloud)と呼ばれる概念があります。これによにサーバー、ストレージなどを論理的に独立した仮想的なサブネット上に構成することができます。
事前にVPC, サブネットを作成しておきます。(ここでは詳細は割愛)

SSH Key

公開鍵認証のためにキーペアを作成します。

C:\temp>ssh-keygen -t rsa -b 4096 -f .\id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .\id_rsa
Your public key has been saved in .\id_rsa.pub
The key fingerprint is:
SHA256:0hrw7wa2YlK/ZexulFlGVP7L+4FquP2FTCPGYjErnU4 gmx\a00527jp6@IBM-PF3ALW3Q
The key's randomart image is:
+---[RSA 4096]----+
|         ....    |
...
+----[SHA256]-----+

秘密鍵: id_rsa, 公開鍵: id_rsa.pub が生成されます。

ネットワーク構成

作業用PCからIBM Cloud上のVPCへのアクセス方法を決め、それに応じた構成を行います。例えば浮動IPを各仮想サーバーに割り当てて、セキュリティー・グループのルールでアクセス制御をかけるというのが手っ取り早い方法だと思います。(きちんとやるにはVPNの構成やDirect Linkの構成を行うなど適宜要件に応じて考慮してください)

参考:ネットワーキングについて

ここでは浮動IPを割り当てる想定とします。

仮想サーバー作成

さて、実際に仮想サーバー(Windows Server)を作成していきます。

SSH鍵作成

先に作成したおいたSSH Key(公開鍵)を登録しておきます。

IBM Cloudコンソールに入り、VPCインフラストラクチャー - SSH鍵のメニューを選び、「作成」をクリックします。
image.png

上で生成したキーペアのうち公開鍵をアップロードします。
image.png

仮想サーバー・インスタンス作成

仮想サーバー・インスタンスの画面から「作成」をクリック
image.png

オペレーティング・システムとしてWindows Serverを選択し、適当なバージョンを選択します(ここではWindows Server 2022)。その他マシンのプロファイルやストレージなど適宜選択していきます。最終的に右側の「仮想サーバーの作成」をクリックします。
image.png

これで仮想サーバーが作成されました。
image.png

浮動IPの付与

作成された仮想サーバーのネットワーク・インターフェースの編集アイコンをクリック
image.png

新規の浮動IPを予約し、適当なセキュリティー・グループに紐づける。
image.png

※リモート・デスクトップ接続する場合、3389番ポートが使用されるため、セキュリティー・グループでインバウンドのポート制御を行う場合、3389番ポートを通すように設定しておく必要があります。
参考: Windows インスタンスへの接続

浮動IPがアサインされました。

image.png

作業用PCからリモートデスクトップでのアクセス

パスワードの入手

リモート・デスクトップで接続する際に必要な、Administratorのパスワードを入手します。
作業用Windows PCのコマンドプロンプトから、ibmcloudでログインしておきます。
(以下はシングル・サインオンの例)

C:\> ibmcloud login -sso
API エンドポイント: https://cloud.ibm.com
リージョン: jp-tok

https://identity-2.ap-north.iam.cloud.ibm.com/identity/passcode からワンタイム・コードを取得して、続行します。
デフォルトのブラウザーで URL を開きますか? [Y/n] > y
ワンタイム・コード >
認証中です...
OK

アカウントを選択:
1. xxxxxx <-> nnnnnnn
2. xxxxxx <-> nnnnnnn
3. xxxxxx <-> nnnnnnn
4. xxxxxx <-> nnnnnnn
5. xxxxxx <-> nnnnnnn
6. xxxxxx <-> nnnnnnn
7. xxxxxx <-> nnnnnnn
数値を入力してください> 4
ターゲットのアカウント xxxxxx <-> nnnnnnn

After 15 September 2023, the CLI will no longer pre-install SoftLayer(sl) commands. To use ibmcloud sl commands, you will need to install the plug-in with 'ibmcloud plugin install sl'. For more information on plug-ins, see https://cloud.ibm.com/docs/cli?topic=cli-plug-ins

API エンドポイント:      https://cloud.ibm.com
Region:                  jp-tok
ユーザー:                xxx@xxx
アカウント:              Ixxxxxx <-> nnnnnnn
リソース・グループ:      リソース・グループがターゲットになっていません。'C:\Program Files\IBM\Cloud\bin\ibmcloud.exe target -g RESOURCE_GROUP' を使用してください
CF API エンドポイント:
組織:
スペース:

仮想サーバー・インスタンス情報確認

C:\> ibmcloud is instance ezdanalysis01
ユーザー xxx としてアカウント xxxxx の下でインスタンス ezdanalysis01 を取得しています...

ID                               02f7_890a3fd6-2717-4685-80d1-6f34f8f4fe5d
名前                             ezdanalysis01
CRN                              xxx
状況                             running
ホスト障害時の可用性ポリシー     restart
開始可能                         true
プロファイル                     mx2-8x64
アーキテクチャー                 amd64
vCPU メーカー                    intel
vCPU                             8
メモリー (GiB)                   64
帯域幅 (Mbps)                    16000
ボリューム帯域幅 (Mbps)          4000
ネットワーク帯域幅 (Mbps)        12000
ライフサイクルの理由             コード   メッセージ
                                 -        -

ライフサイクルの状態             stable
メタデータ・サービス             有効    プロトコル   応答ホップ限界
                                 false   http         1

イメージ                         ID                                          名前
                                 r022-2a5ae604-c2d6-4450-865c-1571ae7ee889   ibm-windows-server-2022-full-standard-amd64-8

VPC                              ID                                          名前
                                 r022-a9e1fd5d-3911-4cd4-bfb0-032298831d34   vpc01

ゾーン                           jp-tok-2
リソース・グループ               ID                                 名前
                                 07c38a522f014e74aa065dfe2ab7f9af   ISEI20230707-1626-nervous

作成日時                         2023-07-18T14:40:20+09:00
ネットワーク・インターフェース   インターフェース   名前   ID                                          サブネット       サブネット ID                               浮動 IP            セキュリティー・グループ   ソース IP スプーフィングを許可   予約済み IP
                                 1 次               eth0   02f7-8c7fee21-f5f4-4752-b5e2-3f9a94bb0300   sn-20230715-02   02f7-e9aecd6a-ed96-4f1d-9a14-1e3ca1863d74   xxx.xxx.xxx.xxx   secgrp-analysis            false                            xxx.xxx.xxx.xxx

ブート・ボリューム               ID                                          名前                               接続 ID                                     接続名
                                 r022-7bf40953-5442-47cf-95aa-0d021ad03733   ezdanalysis01-boot-1689658631000   02f7-27122b02-17b8-4270-a9d7-831021ab4552   thread-sized-impatient-thicken

パスワード取得(上で作成した秘密鍵を指定しています)

C:\temp>ibmcloud is instance-initialization-values ezdanalysis01 --private-key @.\id_rsa
ユーザー xxx としてアカウント xxx の下でインスタンス ezdanalysis01 のインスタンス初期設定値を取得しています...

鍵                       ID                                          名前            指紋
                         r022-f19ceab3-884f-4de2-a43f-aefa1b0049ef   ezdanalysis01   SHA256:xxx

暗号化されたパスワード   xxxxxxxxxxxxxxxxxxxx....
暗号鍵 CRN               SHA256:xxxxx....
パスワード               XXXXXXXXXXXXXXXXXX

上の最終行の"パスワード"の欄に表示される値がAdministratorのパスワードです。(上の例では大文字の"X"に置き換えています)

リモート・デスクトップ接続

作業用Windows PCからリモートデスクトップで、VPC上の仮想サーバーに接続してみます。

リモート・デスクトップを開いて、上で割り当てた浮動IPを指定(ここでは、hostsにホスト名設定しているので対応するホスト名を指定しています)。
image.png

接続
image.png

"別のアカウントを使用する"を選択
image.png

以下を指定してOK
ユーザー名: ".\Administrator" (先頭に.\を指定)
パスワード: 上で取得したパスワード
image.png

"はい"を選択
image.png

これでリモートデスクトップ経由で仮想サーバー(Windows Server)に接続できるようになります。

Windows Server 2022の日本語化

デフォルトではWindows SErverは英語環境で稼働しています。日本語を扱いたい場合は色々と不便なので日本語化の手順を記載しておきます。

日本語フィーチャーのインストール

Administratorでリモートデスクトップ接続し、Settingから "Time & Language"を選択
image.png

languageの画面から "Add a language"をクリック
image.png

日本語を選択して"Next"
image.png

"Install"
image.png

インストールが完了すると、以下のように一旦サインアウトが促されるので、"Yes, sign out now"をクリックしてサインアウトします。
image.png

再度リモートデスクトップ接続すると、メニューが日本語になっています。
image.png

地域の変更

設定から"時刻と言語"を選択
image.png

地域の画面で"日本"を選択
image.png

日付と時刻

日付と時刻の画面で、タイムゾーンとして"(UTC+09:00 大阪、札幌、東京"を選択
image.png

システム・ロケールの設定

言語の画面で、"管理用の言語の設定"をクリック
image.png

"システム・ロケールの変更"をクリック
image.png

"日本語"を選択してOK
image.png

Windowsの再起動が促されるので、"今すぐ再起動"をクリックして再起動します。
image.png

これで一通り日本語の設定が完了しました。

8
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?