カピバラ好きなエンジニアブログ

興味ある技術とか検証した内容を赴くままに書いていきます。カピバラの可愛さこそ至高。

CloudBerry Driveをコマンドラインでインストールと設定してみた

経緯

色々調べていくとCloudBerry Driveにはコマンドラインインターフェースがあることを知りました。
なので今回は、コマンドを使用したインストールと実際にS3のマウント設定までやっていきたいと思います。

公式はこちら
www.cloudberrylab.com

実施内容

  • 事前準備
  • CloudBerry Driveインストール
  • アクティベート
  • ストレージアカウントの登録
  • ドライブのマウント
  • CloudBerry Drive Serviceの開始

実施作業

事前準備

はじめにWindows ServerとCloudBerryDriveのEXEファイルを準備します。

Windows Serverは無料枠のAMIを使用して構築、EXEファイルは以下からダウンロードしてください。
※今回はトライアル版で十分です。
www.cloudberrylab.com

どちらともできたら、RDPでWindows Serverにログインして、EXEファイルを配置します。
今回はEXEファイルはCドライブ配下のworkspaceに置きました。
f:id:live-your-life-dd18:20191122133404p:plain

CloudBerry Driveインストール

まずはインストールからいっていきます。
コマンドプロンプトを立ち上げて、EXEファイルを配置したフォルダまでcdコマンドで移動します。

その後に以下のオプションを付けてEXEファイルを実行します。
CloudBerryDriveSetup_v3.0.1.5_c689418.exe /S

エラーが出力されなければ成功です。
f:id:live-your-life-dd18:20191122133914p:plain

特にインストールに成功したとは出ないので、コントロールパネルのプログラムと機能からインストールを確認します。
f:id:live-your-life-dd18:20191122133936p:plain

この後のアクティベートのために、CloudBerry Driveのインストールファイルがあるフォルダを確認しておきます。 f:id:live-your-life-dd18:20191122134219p:plain

アクティベート

アクティベートのために、先ほど確認したインストールファイルがあるフォルダに移動します。
f:id:live-your-life-dd18:20191122134407p:plain

アクティベートは以下のコマンドで実施します。
cbd.exe /activatelicense -e "<ダウンロードするときに指定したメールアドレス>" -t

『Your trial license has been activated.』と出力されればトライアルのアクティベートは成功です。
同時にCloudBerryのWebサイトが開きますが、それは×で閉じてください。
f:id:live-your-life-dd18:20191122134807p:plain

ストレージアカウントの登録

次にストレージアカウントの登録です。
既にGUIで設定したことある人はわかるかもしれませんが、GUIだと以下の画面で設定した内容を、コマンドラインで設定していきます。
簡単に言うと、CloudBerry Driveの接続先とそのアクセス方法についての設定です。
f:id:live-your-life-dd18:20191122135417p:plain

アカウントを登録するコマンドは以下。

cbd.exe addAccount -d account_display_name -st S3 -ir -ssl yes

・各オプションの説明

オプション 説明
-d アカウント表示名
-st 接続先ストレージ
-ir ローカルポリシーを使用※S3のみ
-ssl SSLの有効無効設定



他のオプションはcbd.exe addAccount -?のコマンドで確認できます。

・実行結果

Usage for add account command:

addAccount -d displayName -st storageType -ac [accessKey | account | queryID | userName] -sk [secretKey | sharedKey | apiKey] [-sp servicePoint] [-ssl [yes | no]]


    -d displayName : Display name for account
    -st storageType : Type of storage account. Possible values: S3, Azure, Google, Scality, Dunkel, Tiscali,
HostEurope, DreamObjects, Seeweb, Connectria, Walrus, OpenStack, RackSpace, Clodo, HPCloud, GreenQloud, IDCF
rontier, Verizon, VMwareVCloudAir, VMwareVCloudAirGoogle, CenturyLink
    -ac [accessKey | account | queryID | userName] : Access Key or 'Account' for Azure storage or 'Query ID' for Walrus
storage or 'User Name' for OpenStack, Rackspace, Clodo, HPCloud storage
    -sk [secretKey | sharedKey | apiKey] : Secret key or 'Shared key' for Azure storage or 'Api Key' for OpenStack,
Rackspace, Clodo, HPCloud storage
    -sp [servicePoint] : Service point for account (optional). Not used for AmazonS3, Google, Azure, OpenStack,
Rackspace, Clodo and HPCloud
    -ir [useAwsIamRole] : Use AWS IAM Role policy. Used only for S3 storage.
    -as [authService] : Authentication Service. Used only for OpenStack storage.
    -at [accountType] : Account Type. Used only for Rackspace storage. Possible values: UK, US
    -ssl [yes | no] : Use SSL
    -? Show help on add account command



アカウントを登録するコマンドを実行して、アカウントIDが表示されれば登録は完了です。
f:id:live-your-life-dd18:20191122141122p:plain

ちなみに、、、

cbd.exe deleteAccount <accountName>

cbd.exe editAccount -d account_display_name -n new_display_name -st S3 -ir -ssl yes

で、作成したアカウントの削除や編集ができたりします。
今はスキップして次にいきます。

ドライブのマウント

S3にアクセスする用の設定ができたらドライブのマウントを行います。
ドライブのマウントをするコマンドは以下。

cbd.exe addDrive -d DriveLetter -an AccountName -path container/folder -label VolumeLabel

・各オプションの説明

オプション 説明
-d マウントドライブ名
-an 登録済みアカウント名
-path 接続先パス
-label ドライブラベル名


他のオプションはcbd.exe addDrive -?のコマンドで確認できます。

・実行結果

Usage for add mapped drive command:

addDrive -d DriveLetter -an accountName -path "bucket/folder/subfolder" [-as [removable | network]] [-label “volume label”] [-ss [yes | no]] [-ro [yes | no]] [-rrs [yes | no]] [-ia [yes | no]] [-sse [yes | no]]


    -d Drive letter: Z for example
    -an Account name: name of registered cloud storage account
    -path bucket/folder/subfolder
    -as Mount Drive as Removable Disk or as Network mapped drive (default). Possible values: removable, network
    -label volume label
    -ss Mount drive at system startup [yes | no] (yes by default)
    -ro Mount drive for read-only access [yes | no] (no by default)
    -rrs Use Reduced Redundancy Storage [yes | no] (no by default)
    -ia Use Standart-IA [yes | no] (no by default)
    -sse Use Server Side Encryption [yes | no] (no by default)
    -revup Use S3 Accelerate [yes | no] (no by default)
    -? Show help on add account command



コマンドを実行して、ドライブIDが出力されれば成功です。
f:id:live-your-life-dd18:20191122151320p:plain

CloudBerry Drive Serviceの開始

ここまでできたら必要な設定は完了しているので、実際にCloudBerry Driveのサービスを有効化していきます。

サービスの有効化は以下のコマンドを実行します。
cbd.exe /startservice

エラーが出なければ成功です。
f:id:live-your-life-dd18:20191122151814p:plain


最後にサーバを再起動し、再度RDPでログイン後エクスプローラでマウントされていることを確認します。
f:id:live-your-life-dd18:20191122153259p:plain


ちゃんとマウントした先も見ることができます。
f:id:live-your-life-dd18:20191122153331p:plain


GUIで設定を確認しても、想定通り設定されていました。
※明示的に設定していない箇所はデフォルト値が設定されています。
f:id:live-your-life-dd18:20191122153424p:plain f:id:live-your-life-dd18:20191122153448p:plain

感想及び所感

CloudBerry Driveの設定はインストールからGUIでやると結構手順が多くて面倒なんですけど、このCLIを使用してバッチ化しておけば、比較的楽に設定することができそうです。
今回はそこまで細かく設定していなかったですが、オプションも思ったよりも種類が多くてGUIで設定することは大体可能だと思います。