SoftLayerは高速で安定したPrivateネットワークが特長です。
どの程度ネットワークが高速なのかを、データセンター間でのWindowsファイル共有で計測する環境をセットアップするスクリプトを作ってみたので、やっつけですが共有します。
# しばらくPowerShellを書いてなくてすっかり忘れてしまっていたので、復習も兼ねて。
東京 - アムステルダム間でも 18MB/sec (144Mbps) 出るんですね。
SoftLayer CLIでWindows ServerをProvisioning
provserver.sh
#!/bin/sh
# 仮想サーバーを作成
for i in tok02 sng01 ams01 # ServerをProvisioningするデータセンター
do
# 2vCPU, 2GMメモリ、Windows Server 2012で時間課金の仮想サーバーを選択
sl vs create --datacenter=$i --hostname=TK-win$i --domain=example.com --cpu=2 --memory=2048 --hourly --os=WIN_2012-STD_64 --key=sshkey
done
# Provisioning完了まで待機
sleep 300
# Provisioningされたサーバーを表示
sl vs list | awk '{print $3}' | grep ^TK-win
各Windows Serverで共有フォルダを作成
PowerShellが実行できるように実行ポリシーを設定
PS C:\> Set-ExecutionPolicy RemoteSigned -Force
共有フォルダの作成
makeshare.ps1
$shareDrive = "C:\"
$shareDir = "SMBTEST"
$sharePath = $shareDrive + $shareDir
$shareName = "SMBTEST"
# Create SMB share if none
if (-not(Test-Path -Path $sharePath)) {mkdir $sharePath}
if (-not(Get-SmbShare | where Name -eq $shareName)) {
New-SmbShare -Name $shareName -Path $sharePath -FullAccess Administrator
}
Get-SmbShare | Select Name,Path | where Name -eq $shareDir | Format-Table -AutoSize
送信元のWindows Serverから複数のサーバーに順次ファイル送信を実行
転送するファイルは用意しておくこと
smbtest.ps1
# Data center and user credential
$TOK02 = "10.132.2.221"
$SNG01 = "10.64.234.85"
$AMS01 = "10.104.212.66"
$TOK02pass = "<passwd>"
$SNG01pass = "<passwd>"
$AMS01pass = "<passwd>"
$user = "Administrator"
# Shared folder config
$shareDrive = "C:\"
$shareDir = "SMBTEST"
$sharePath = $shareDrive + $shareDir
$shareName = "SMBTEST"
# File to be transferred
$fileName = "CentOS-7.0-1406-x86_64-DVD.iso"
# Run copy file to DCs each
$DCs = @('SNG01', 'AMS01', 'TOK02')
foreach ($DC in $DCs) {
"### TOK02 to $DC ###"
$sourceFile = "$sharePath\$filename"
$targetHost = Get-Variable $DC -ValueOnly
$targetPass = Get-Variable -Name ($DC + "pass") -ValueOnly
# Create PSCredential
$spass = ConvertTo-SecureString $targetPass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user, $spass)
# net use to create temporary network drive
New-PSDrive -Name $DC -PSProvider FileSystem -Root \\$targetHost\$shareDir -Credential $cred `
| Format-Table -AutoSize -HideTableHeaders
$targetFile = "\\$targetHost\$shareDir\$filename.target"
$command = "Copy-Item $sourceFile $targetFile"
$command
$size = [int]($(Get-ChildItem $sourceFile).Length / 1MB)
"File size: $size MB"
# Execute command
$time = [int]$(Measure-Command {Invoke-Expression $command}).TotalSeconds
if ($time -eq 0) {$throughput = "N/A"} else {$throughput = [int]($size /$time)}
"Time: $time seconds"
"Throughtput: $throughput MB/sec"
"`n"
# Clean temporary network drive
Remove-PSDrive -Name $DC
}
結果
PS C:\> C:\WinSMBSetup.ps1
### TOK02 to SNG01 ###
SNG01 FileSystem \\10.64.234.85\SMBTEST
Copy-Item C:\SMBTEST\CentOS-7.0-1406-x86_64-DVD.iso \\10.64.234.85\SMBTEST\CentOS-7.0-1406-x86_64-DVD.iso.target
File size: 3956 MB
Time: 218 seconds
Throughtput: 18 MB/sec
### TOK02 to AMS01 ###
AMS01 FileSystem \\10.104.212.66\SMBTEST
Copy-Item C:\SMBTEST\CentOS-7.0-1406-x86_64-DVD.iso \\10.104.212.66\SMBTEST\CentOS-7.0-1406-x86_64-DVD.iso.target
File size: 3956 MB
Time: 221 seconds
Throughtput: 18 MB/sec