softlayer-api-ruby-client で iSCSI ストレージを追加する #softlayer
この記事は1年以上前に投稿されました。情報が古い可能性がありますので、ご注意ください。
iSCSI (Internet Small Computer System Interface) とは
SoftLayer のストレージにはさまざまな種類がありますが、本記事では iSCSI ストレージを取り扱います。
以前の記事 でも触れましたが、iSCSI (Internet Small Computer System Interface) とは TCP/IP のネットワーク経由で SCSI プロトコルを利用する規格で、もっぱらネットワーク経由で利用可能なストレージを構成するのに用います。SoftLayer では iSCSI ストレージを SAN として扱うことができます。
softlayer-api-ruby-client で iSCSI ストレージを注文する
iSCSI ストレージも softlayer-api-ruby-client を用いて注文が可能です。SoftLayer_Product_Order::placeOrder を用いますが、やはりマジックナンバーが必要です。先の記事のプログラムで iSCSI ストレージの Package ID を調べてみました。
:
(中略)
:
{"firstOrderStepId"=>1,
"id"=>218,
"isActive"=>1,
"name"=>"iSCSI Storage",
"unitSize"=>nil}]
iSCSI ストレージの Package ID は 218 とわかりました。
次に iSCSI ストレージの Price ID を確認しましょう。これも 先の記事のプログラムのように確認します。
Optional Category "iSCSI" -- 51: 1175 -- 450 GB iSCSI SAN Storage 22491 -- 1000 GB iSCSI SAN Storage 22492 -- 120 GB iSCSI SAN Storage 22494 -- 700 GB iSCSI SAN Storage 22487 -- 80 GB iSCSI SAN Storage 1174 -- 430 GB iSCSI SAN Storage 2152 -- 1 GB iSCSI SAN Storage 22490 -- 500 GB iSCSI SAN Storage 22502 -- 3000 GB iSCSI SAN Storage 1472 -- 1500 GB iSCSI SAN Storage 1080 -- 120 GB iSCSI SAN Storage 22499 -- 2000 GB iSCSI SAN Storage 22495 -- 200 GB iSCSI SAN Storage 1173 -- 200 GB iSCSI SAN Storage 1178 -- 350 GB iSCSI SAN Storage 1039 -- 1000 GB iSCSI SAN Storage 22488 -- 100 GB iSCSI SAN Storage 22441 -- 1 GB iSCSI SAN Storage 1185 -- 2000 GB iSCSI SAN Storage 1034 -- 40 GB iSCSI SAN Storage 1033 -- 20 GB iSCSI SAN Storage 1035 -- 80 GB iSCSI SAN Storage 2199 -- 3000 GB iSCSI SAN Storage 22501 -- 1 GB iSCSI SAN Storage 22500 -- 1500 GB iSCSI SAN Storage 22493 -- 300 GB iSCSI SAN Storage 1036 -- 100 GB iSCSI SAN Storage 1037 -- 250 GB iSCSI SAN Storage 1038 -- 500 GB iSCSI SAN Storage 1172 -- 700 GB iSCSI SAN Storage 22489 -- 250 GB iSCSI SAN Storage 22498 -- 350 GB iSCSI SAN Storage 1154 -- 300 GB iSCSI SAN Storage 22496 -- 430 GB iSCSI SAN Storage 22485 -- 20 GB iSCSI SAN Storage 22486 -- 40 GB iSCSI SAN Storage 22497 -- 450 GB iSCSI SAN Storage Optional Category "iSCSI Replication" -- 65: 1377 -- 250 GB iSCSI SAN Replication 1382 -- 500 GB iSCSI SAN Replication 1372 -- 60 GB iSCSI SAN Replication 1375 -- 120 GB iSCSI SAN Replication 1380 -- 430 GB iSCSI SAN Replication 1384 -- 700 GB iSCSI SAN Replication 36558 -- 3000 GB iSCSI SAN Replication 36918 -- 1 GB iSCSI SAN Replication 1374 -- 100 GB iSCSI SAN Replication 1371 -- 40 GB iSCSI SAN Replication 36902 -- 6500 GB iSCSI SAN Replication 36912 -- 10000 GB iSCSI SAN Replication 1370 -- 20 GB iSCSI SAN Replication 1385 -- 1000 GB iSCSI SAN Replication 1386 -- 2000 GB iSCSI SAN Replication 1379 -- 350 GB iSCSI SAN Replication 36398 -- 1500 GB iSCSI SAN Replication 36904 -- 20000 GB iSCSI SAN Replication 36906 -- 20000 GB iSCSI SAN Replication 36930 -- 1 GB iSCSI SAN Replication 36932 -- 15000 GB iSCSI SAN Replication 1373 -- 80 GB iSCSI SAN Replication 1381 -- 450 GB iSCSI SAN Replication 1383 -- 600 GB iSCSI SAN Replication 36566 -- 3000 GB iSCSI SAN Replication 36910 -- 10000 GB iSCSI SAN Replication 1376 -- 200 GB iSCSI SAN Replication 1378 -- 300 GB iSCSI SAN Replication 36900 -- 6500 GB iSCSI SAN Replication 36908 -- 4000 GB iSCSI SAN Replication 36914 -- 1 GB iSCSI SAN Replication Optional Category "iSCSI Snapshot Space" -- 63: 1364 -- 450 GB iSCSI SAN Snapshot Space 1354 -- 40 GB iSCSI SAN Snapshot Space 1361 -- 300 GB iSCSI SAN Snapshot Space 1355 -- 60 GB iSCSI SAN Snapshot Space 1359 -- 200 GB iSCSI SAN Snapshot Space 1356 -- 80 GB iSCSI SAN Snapshot Space 1360 -- 250 GB iSCSI SAN Snapshot Space 1366 -- 600 GB iSCSI SAN Snapshot Space 1368 -- 1000 GB iSCSI SAN Snapshot Space 1369 -- 2000 GB iSCSI SAN Snapshot Space 1353 -- 20 GB iSCSI SAN Snapshot Space 1357 -- 100 GB iSCSI SAN Snapshot Space 1367 -- 700 GB iSCSI SAN Snapshot Space 1358 -- 120 GB iSCSI SAN Snapshot Space 1362 -- 350 GB iSCSI SAN Snapshot Space 1365 -- 500 GB iSCSI SAN Snapshot Space 1363 -- 430 GB iSCSI SAN Snapshot Space
通常の iSCSI ストレージ以外に、レプリケーションとスナップショットに用いる iSCSI 領域も表示されていますが、本記事では利用しません。
これで iSCSI ストレージを注文するために必要な ID が揃いました。
softlayer-api-ruby-client で iSCSI ストレージの注文内容を検証する
iSCSI の注文内容は SoftLayer_Container_Product_Order データタイプで構成されています。次のような形になるでしょう。
product_order = {
'complexType' => 'SoftLayer_Container_Product_Order',
'quantity' => 1,
'location' => 168642, # NOTE: 168642 is 'sjc01' location ID
'packageId' => 218, # NOTE: 218 is 'iSCSI Storage' package ID
'useHourlyPricing' => false,
'prices' => [
{ 'id' => 22441 }, # "1 GB iSCSI SAN Storage"
]
}
先の記事と同様に、SoftLayer_Product_Order::verifyOrder で注文内容を検証しましょう。
#!/usr/bin/ruby
require 'softlayer_api'
require 'pp'
#
# fill your SoftLayer API username and API key
#
api_username = ENV['SOFTLAYER_API_USERNAME'] || 'YOUR_SOFTLAYER_API_USERNAME'
api_key = ENV['SOFTLAYER_API_KEY'] || 'YOUR_SOFTLAYER_API_KEY'
#
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
#
product_order = {
'complexType' => 'SoftLayer_Container_Product_Order',
'quantity' => 1,
'location' => 168642, # NOTE: 168642 is 'sjc01' location ID
'packageId' => 218, # NOTE: 218 is 'iSCSI Storage' package ID
'useHourlyPricing' => false,
'prices' => [
{ 'id' => 22441 }, # "1 GB iSCSI SAN Storage"
]
}
#
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order
#
product_order_service = SoftLayer::Service.new( 'SoftLayer_Product_Order',
:username => api_username,
:api_key => api_key,
)
#
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
#
begin
result = product_order_service.verifyOrder( product_order )
pp result
puts "The order was verified successfully"
rescue => error_reason
puts "The order could not be verified by the server: #{error_reason}"
exit
end
exit
__END__
これを実行すると次の結果が得られます。
{"bigDataOrderFlag"=>false,
"billingOrderItemId"=>nil,
"containerSplHash"=>"00000000417cde2d00007fab47e97d7f",
"containerSplHash"=>"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyShortName"=>"USD",
"extendedHardwareTesting"=>nil,
"imageTemplateId"=>nil,
"isManagedOrder"=>0,
"location"=>"168642",
"locationObject"=>
{"id"=>168642,
"longName"=>"San Jose 1",
"name"=>"sjc01",
"activePresaleEvents"=>[]},
"packageId"=>218,
"postTaxRecurring"=>"15",
"postTaxRecurringHourly"=>"0",
"postTaxRecurringMonthly"=>"15",
"postTaxSetup"=>"0",
"preTaxRecurring"=>"15",
"preTaxRecurringHourly"=>"0",
"preTaxRecurringMonthly"=>"15",
"preTaxSetup"=>"0",
"presetId"=>nil,
"prices"=>
[{"currentPriceFlag"=>nil,
"id"=>22441,
"itemId"=>1150,
"laborFee"=>"0",
"onSaleFlag"=>nil,
"oneTimeFee"=>"0",
"oneTimeFeeTax"=>"0",
"proratedRecurringFee"=>"5",
"proratedRecurringFeeTax"=>"0",
"quantity"=>nil,
"recurringFee"=>"15",
"recurringFeeTax"=>"0",
"setupFee"=>"0",
"sort"=>1,
"categories"=>
[{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0}],
"item"=>
{"capacity"=>"1",
"description"=>"1 GB iSCSI SAN Storage",
"id"=>1150,
"softwareDescriptionId"=>nil,
"units"=>"GB",
"upgradeItemId"=>548,
"bundle"=>[],
"itemCategory"=>
{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0}}}],
"primaryDiskPartitionId"=>nil,
"privateCloudOrderFlag"=>false,
"proratedInitialCharge"=>"0",
"proratedOrderTotal"=>"5",
"quantity"=>1,
"resourceGroupId"=>nil,
"resourceGroupTemplateId"=>nil,
"sendQuoteEmailFlag"=>nil,
"serverCoreCount"=>nil,
"sourceVirtualGuestId"=>nil,
"sshKeys"=>[],
"stepId"=>nil,
"storageGroups"=>[],
"totalRecurringTax"=>"0",
"totalSetupTax"=>"0",
"useHourlyPricing"=>false}
The order was verified successfully
注文内容が問題ないことがわかります。
softlayer-api-ruby-client で iSCSI ストレージを注文する
では、検証した注文内容を実際に注文してみましょう。
次のプログラムになります。
#!/usr/bin/ruby
require 'softlayer_api'
require 'pp'
#
# fill your SoftLayer API username and API key
#
api_username = ENV['SOFTLAYER_API_USERNAME'] || 'YOUR_SOFTLAYER_API_USERNAME'
api_key = ENV['SOFTLAYER_API_KEY'] || 'YOUR_SOFTLAYER_API_KEY'
#
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
#
product_order = {
'complexType' => 'SoftLayer_Container_Product_Order',
'quantity' => 1,
'location' => 168642, # NOTE: 168642 is 'sjc01' location ID
'packageId' => 218, # NOTE: 218 is 'iSCSI Storage' package ID
'useHourlyPricing' => false,
'prices' => [
{ 'id' => 22441 }, # "1 GB iSCSI SAN Storage"
]
}
#
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order
#
product_order_service = SoftLayer::Service.new( 'SoftLayer_Product_Order',
:username => api_username,
:api_key => api_key,
)
#
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
#
begin
result = product_order_service.verifyOrder( product_order )
puts "The order was verified successfully"
rescue => error_reason
puts "The order could not be verified by the server: #{error_reason}"
exit
end
#
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
#
begin
result = product_order_service.placeOrder( product_order )
puts "The order was placed successfully"
pp result
rescue => error_reason
puts "The order could not be placed by the server: #{error_reason}"
exit
end
exit
__END__
これを実行すると次の結果が得られます。
The order was verified successfully
The order was placed successfully
{"orderDate"=>"2014-06-18T12:55:46+09:00",
"orderDetails"=>
{"bigDataOrderFlag"=>false,
:
(中略)
:
"billingOrderItemId"=>nil,
"containerSplHash"=>"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyShortName"=>"USD",
"extendedHardwareTesting"=>nil,
"imageTemplateId"=>nil,
"isManagedOrder"=>0,
"itemCategoryQuestionAnswers"=>[],
"location"=>"168642",
"locationObject"=>
{"id"=>168642,
"longName"=>"San Jose 1",
"name"=>"sjc01",
"activePresaleEvents"=>[]},
"packageId"=>218,
"paymentType"=>"ADD_TO_BALANCE",
"postTaxRecurring"=>"15",
"postTaxRecurringHourly"=>"0",
"postTaxRecurringMonthly"=>"15",
"postTaxSetup"=>"0",
"preTaxRecurring"=>"15",
"preTaxRecurringHourly"=>"0",
"preTaxRecurringMonthly"=>"15",
"preTaxSetup"=>"0",
"presetId"=>nil,
"prices"=>
[{"currentPriceFlag"=>nil,
"id"=>22441,
"itemId"=>1150,
"laborFee"=>"0",
"onSaleFlag"=>nil,
"oneTimeFee"=>"0",
"oneTimeFeeTax"=>"0",
"proratedRecurringFee"=>"5",
"proratedRecurringFeeTax"=>"0",
"quantity"=>nil,
"recurringFee"=>"15",
"recurringFeeTax"=>"0",
"setupFee"=>"0",
"sort"=>1,
"categories"=>
[{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0}],
"item"=>
{"capacity"=>"1",
"description"=>"1 GB iSCSI SAN Storage",
"id"=>1150,
"softwareDescriptionId"=>nil,
"units"=>"GB",
"upgradeItemId"=>548,
"bundle"=>[],
"itemCategory"=>
{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0}}}],
"primaryDiskPartitionId"=>nil,
"privateCloudOrderFlag"=>false,
"properties"=>[],
"proratedInitialCharge"=>"0",
"proratedOrderTotal"=>"5",
"quantity"=>1,
"resourceGroupId"=>nil,
"resourceGroupTemplateId"=>nil,
"sendQuoteEmailFlag"=>nil,
"serverCoreCount"=>nil,
"sourceVirtualGuestId"=>nil,
"sshKeys"=>[],
"stepId"=>nil,
"storageGroups"=>[],
"totalRecurringTax"=>"0",
"totalSetupTax"=>"0",
"useHourlyPricing"=>false},
"orderId"=>XXXXX40,
"placedOrder"=>
{"accountId"=>XXXX78,
"createDate"=>"2014-06-18T12:55:46+09:00",
"id"=>XXXXX40,
"impersonatingUserRecordId"=>nil,
"modifyDate"=>nil,
"orderQuoteId"=>nil,
"orderTypeId"=>4,
"presaleEventId"=>nil,
"privateCloudOrderFlag"=>false,
"status"=>"PENDING_AUTO_APPROVAL",
"userRecordId"=>XXXX42,
"account"=>
:
(中略)
:
"items"=>
[{"categoryCode"=>"iscsi",
"description"=>"1 GB iSCSI SAN Storage",
"id"=>XXXXXX42,
"itemId"=>1150,
"itemPriceId"=>"22441",
"laborFee"=>"0",
"laborFeeTaxRate"=>"0",
"oneTimeFee"=>"0",
"oneTimeFeeTaxRate"=>"0",
"parentId"=>nil,
"promoCodeId"=>nil,
"quantity"=>nil,
"recurringFee"=>"15",
"setupFee"=>"0",
"setupFeeDeferralMonths"=>12,
"setupFeeTaxRate"=>"0",
"bundledItems"=>[],
"category"=>
{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0},
"children"=>[],
"location"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"},
"order"=>nil,
"storageGroups"=>[]}],
"orderTopLevelItems"=>
[{"categoryCode"=>"iscsi",
"description"=>"1 GB iSCSI SAN Storage",
"id"=>37101642,
"itemId"=>1150,
"itemPriceId"=>"22441",
"laborFee"=>"0",
"laborFeeTaxRate"=>"0",
"oneTimeFee"=>"0",
"oneTimeFeeTaxRate"=>"0",
"parentId"=>nil,
"promoCodeId"=>nil,
"quantity"=>nil,
"recurringFee"=>"15",
"setupFee"=>"0",
"setupFeeDeferralMonths"=>12,
"setupFeeTaxRate"=>"0",
"bundledItems"=>[],
"category"=>
{"categoryCode"=>"iscsi",
"id"=>51,
"name"=>"iSCSI",
"quantityLimit"=>0},
"children"=>[],
"location"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"},
"order"=>nil,
"storageGroups"=>[]}],
:
(中略)
:
このように 1GB iSCSI ストレージが注文できました。
softlayer-api-ruby-client で iSCSI ストレージを確認する
ポータルの iSCSI から確認することもできますが、softlayer-api-ruby-client からも確認してみましょう。
SoftLayer_Account サービスの SoftLayer_Account::getIscsiNetworkStorage で iSCSI ストレージの一覧が確認できます。
#!/usr/bin/ruby require 'softlayer_api' require 'pp' # # fill your SoftLayer API username and API key # api_username = ENV['SOFTLAYER_API_USERNAME'] || 'YOUR_SOFTLAYER_API_USERNAME' api_key = ENV['SOFTLAYER_API_KEY'] || 'YOUR_SOFTLAYER_API_KEY' # # http://sldn.softlayer.com/reference/services/SoftLayer_Account # account_service = SoftLayer::Service.new( 'SoftLayer_Account', :username => api_username, :api_key => api_key, ) # # result # pp account_service.getIscsiNetworkStorage __END__
このプログラムを実行すると、次のように先に注文した iSCSI ストレージの内容が取得できます。
[{"accountId"=>XXXXX78,
"capacityGb"=>1,
"createDate"=>"2014-06-18T12:55:49+09:00",
"guestId"=>nil,
"hardwareId"=>nil,
"hostId"=>nil,
"id"=>XXXXX94,
"nasType"=>"ISCSI",
"password"=>"XXXXXXXXXXXXXXXX",
"serviceProviderId"=>1,
"upgradableFlag"=>true,
"username"=>"SLIXXXX78-4",
"serviceResourceBackendIpAddress"=>"10.XXX.XXX.21",
"serviceResourceName"=>"storage501"}]
iSCSI ストレージを Virtual Server から利用する
ここからは特に softlayer-api-ruby-client は利用しませんので、詳細は以前の記事に譲り、簡単に手順を見ていきます。また、Connect to an iSCSI LUN in Linux with Open-iSCSI も参考にしてください。
本記事では Virtual Server に Ubuntu 12.04 LTS を用います。
まず iSCSI イニシエータの open-iscsi をインストールします。
root@test-20140610171516:~# apt-get install open-iscsi Reading package lists... Done Building dependency tree Reading state information... Done open-iscsi is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 21 not upgraded. root@test-20140610171516:~#
既にインストール済でした。
設定ファイルを修正します。
iSCSI ターゲットホストのユーザ名とパスワードはポータルや先程のプログラムで取得したものを指定してください。
root@test-20140610171516:~# cp -a /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.2014-0618 root@test-20140610171516:~# vi /etc/iscsi/iscsid.conf : root@test-20140610171516:~#
root@test-20140610171516:~# diff -u /etc/iscsi/iscsid.conf.2014-0618 /etc/iscsi/iscsid.conf --- /etc/iscsi/iscsid.conf.2014-0618 2014-02-26 09:10:02.000000000 -0600 +++ /etc/iscsi/iscsid.conf 2014-06-18 00:40:56.827300403 -0500 @@ -34,10 +34,14 @@ #***************** # To request that the iscsi initd scripts startup a session set to "automatic". -# node.startup = automatic +# 2014/06/18 start +node.startup = automatic +# # # To manually startup the session set to "manual". The default is manual. -node.startup = manual +# 2014/06/18 stop +#node.startup = manual +# # For "automatic" startup nodes, setting this to "Yes" will try logins on each # available iface until one succeeds, and then stop. The default "No" will try @@ -56,6 +60,10 @@ # authentication by the target(s), uncomment the following lines: #node.session.auth.username = username #node.session.auth.password = password +# 2014/06/18 add +node.session.auth.username = SLIXXXX78-4 +node.session.auth.password = XXXXXXXXXXXXXXXX +# # To set a CHAP username and password for target(s) # authentication by the initiator, uncomment the following lines: @@ -70,6 +78,10 @@ # authentication by the target(s), uncomment the following lines: #discovery.sendtargets.auth.username = username #discovery.sendtargets.auth.password = password +# 2014/06/18 add +discovery.sendtargets.auth.username = SLIXXXX78-4 +discovery.sendtargets.auth.password = XXXXXXXXXXXXXXXX +# # To set a discovery session CHAP username and password for target(s) # authentication by the initiator, uncomment the following lines: root@test-20140610171516:~#
iSCSI イニシエータサービスを再起動します。
root@test-20140610171516:~# /etc/init.d/open-iscsi restart * Unmounting iscsi-backed filesystems [ OK ] * Disconnecting iSCSI targets iscsiadm: No matching sessions found [ OK ] * Stopping iSCSI initiator service [ OK ] * Starting iSCSI initiator service iscsid [ OK ] * Setting up iSCSI targets iscsiadm: No records found [ OK ] * Mounting network filesystems [ OK ] root@test-20140610171516:~#
iscsiadm コマンドを用いて iSCSI ターゲットホストを探索します。
iSCSI ターゲットホストの IP アドレスはポータルや先程のプログラムで取得したものを指定してください。
root@test-20140610171516:~# iscsiadm -m discovery -t sendtargets -p 10.XXX.XXX.21 10.XXX.XXX.21:3260,1 iqn.2001-05.com.equallogic:X-XXXXXX-XXXXXXXXX-XXXXXXXXXXXXXXXX-sliXXXX78-4 root@test-20140610171516:~#
もう一度 iSCSI イニシエータサービスを再起動します。
root@test-20140610171516:~# /etc/init.d/open-iscsi restart * Unmounting iscsi-backed filesystems [ OK ] * Disconnecting iSCSI targets iscsiadm: No matching sessions found [ OK ] * Stopping iSCSI initiator service [ OK ] * Starting iSCSI initiator service iscsid [ OK ] * Setting up iSCSI targets Logging in to [iface: default, target: iqn.2001-05.com.equallogic:X-XXXXXX-XXXXXXXXX-XXXXXXXXXXXXXXXX-sliXXXX78-4, portal: 10.XXX.XXX.21,3260] (multiple) Login to [iface: default, target: iqn.2001-05.com.equallogic:X-XXXXXX-XXXXXXXXX-XXXXXXXXXXXXXXXX-sliXXXX78-4, portal: 10.XXX.XXX.21,3260] successful. [ OK ] * Mounting network filesystems [ OK ] root@test-20140610171516:~#
次のコマンドを実行し、iSCSI でマウントしたブロックデバイスを探します。
root@test-20140610171516:~# find /sys/devices/platform/host* -name block\* -exec ls -la '{}' \; | sed s#^.*../block/#/dev/#g
total 0
drwxr-xr-x 3 root root 0 Jun 18 00:45 .
drwxr-xr-x 8 root root 0 Jun 18 00:45 ..
drwxr-xr-x 7 root root 0 Jun 18 00:45 sda
root@test-20140610171516:~#
sda であることがわかりました。
dmesg コマンドでも確認してみましょう。
root@test-20140610171516:~# dmesg | tail -15 [ 5104.671942] waiting module removal not supported: please upgrade [ 5104.675838] waiting module removal not supported: please upgradewaiting module removal not supported: please upgrade [ 5104.678174] waiting module removal not supported: please upgrade<6>[ 5104.727365] Loading iSCSI transport class v2.0-870. [ 5104.744001] iscsi: registered transport (tcp) [ 5105.038333] scsi0 : iSCSI Initiator over TCP/IP [ 5106.328852] connection1:0: detected conn error (1020) [ 5107.918309] scsi 0:0:0:0: Direct-Access EQLOGIC 100E-00 6.0 PQ: 0 ANSI: 5 [ 5107.923995] sd 0:0:0:0: Attached scsi generic sg0 type 0 [ 5107.928405] sd 0:0:0:0: [sda] 2119680 512-byte logical blocks: (1.08 GB/1.01 GiB) [ 5107.935708] sd 0:0:0:0: [sda] Write Protect is off [ 5107.935713] sd 0:0:0:0: [sda] Mode Sense: 81 00 00 00 [ 5107.936236] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 5107.970160] sda: unknown partition table [ 5107.977267] sd 0:0:0:0: [sda] Attached SCSI disk [ 5123.390350] connection1:0: detected conn error (1020)
fdisk コマンドでパーティションを作成します。
root@test-20140610171516:~# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x39f65526.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sda: 1085 MB, 1085276160 bytes
34 heads, 61 sectors/track, 1022 cylinders, total 2119680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x39f65526
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Partition number (1-4, default 1):
First sector (2048-2119679, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2119679, default 2119679):
Using default value 2119679
Command (m for help): p
Disk /dev/sda: 1085 MB, 1085276160 bytes
34 heads, 61 sectors/track, 1022 cylinders, total 2119680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x39f65526
Device Boot Start End Blocks Id System
/dev/sda1 2048 2119679 1058816 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@test-20140610171516:~#
mkfs.ext4 コマンドでファイルシステムを作成します。
root@test-20140610171516:~# mkfs.ext4 /dev/sda1 mke2fs 1.42.9 (4-Feb-2014) Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 66240 inodes, 264704 blocks 13235 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=272629760 9 block groups 32768 blocks per group, 32768 fragments per group 7360 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done root@test-20140610171516:~#
マウントします。
root@test-20140610171516:~# mount /dev/sda1 /mnt root@test-20140610171516:~#
マウントできたことを確認します。
root@test-20140610171516:~# df -h /mnt Filesystem Size Used Avail Use% Mounted on /dev/sda1 986M 1.3M 917M 1% /mnt root@test-20140610171516:~#
root@test-20140610171516:~# ls -la /mnt total 24 drwxr-xr-x 3 root root 4096 Jun 18 00:50 . drwxr-xr-x 22 root root 4096 Jun 10 08:31 .. drwx------ 2 root root 16384 Jun 18 00:50 lost+found root@test-20140610171516:~#
アンマウントします。
root@test-20140610171516:~# umount /mnt root@test-20140610171516:~#
アンマウントできたことを確認します。
root@test-20140610171516:~# df -h /mnt Filesystem Size Used Avail Use% Mounted on /dev/xvda2 25G 887M 23G 4% / root@test-20140610171516:~#
まとめ
iSCSI ストレージは高いパフォーマンスを持ち、さまざまな用途に対応できるブロックデバイスです。iSCSI ストレージのデータ転送はプライベートネットワークが用いられるため、転送量もかかりません。是非活用してみてください。
