12. (略)
describe 'Ubuntu 12.04 stemcell', stemcell_image: true do
context 'installed by image_install_grub' do
describe file('/boot/grub/grub.conf') do
it { should be_file }
it { should contain 'default=0' }
it { should contain 'timeout=1' }
it { should contain 'title Ubuntu 12.04.5 LTS (3.2.0-68-virtual)' }
it { should contain ' root (hd0,0)' }
it { should contain ' kernel /boot/vmlinuz-3.2.0-68-virtual ro root=UUID=' }
it { should contain ' selinux=0' }
it { should contain ' initrd /boot/initrd.img-3.2.0-68-virtual' }
end
(略)
↓ 以下のように修正
(略)
describe 'Ubuntu 12.04 stemcell', stemcell_image: true do
context 'installed by image_install_grub' do
describe file('/boot/grub/grub.conf') do
it { should be_file }
it { should contain 'default=0' }
it { should contain 'timeout=1' }
it { should contain 'title Ubuntu 12.04.5 LTS (3.2.0-70-virtual)' }
it { should contain ' root (hd0,0)' }
it { should contain ' kernel /boot/vmlinuz-3.2.0-70-virtual ro root=UUID=' }
it { should contain ' selinux=0' }
it { should contain ' initrd /boot/initrd.img-3.2.0-70-virtual' }
end
(略)
(3) stemcell イメージの作成
以下のコマンドを実行し、(1)で作成したベースイメージから stemcell イメージを生成する。
# bundle exec rake stemcell:build_with_local_os_image[cloudstack,ubuntu,precise,ruby,/tmp/ubuntu_base_image.tgz]
7
COPYRIGHT FUJITSU LIMITED 2014
13. 3.1.4. Proxy サーバの非参照設定
内部のローカルアドレス(インセプションサーバやインセプションサーバから起動される Firstbosh
サーバ)を Proxy サーバなしで参照するように「no_proxy」環境変数を指定する。
# export no_proxy=172.16.10.224,172.16.10.227,172.16.10.228
※管理サーバの IP、ルータ VM の IP とインセプションサーバ自身の IP を除外対象に指定
3.1.5. キーペアファイルの作成
(1) スクリプトファイル作成
Cloudstack の API を使用して SSH キーペアファイルを作成するため、以下のスクリプトファイルを
作成する。
# cat kick_api.sh
-----------------------------------------
#!/bin/bash
#
# kick_api.sh
#
# please set your host
address="http://172.16.10.224:8080" # Cloudstack 管理サーバの URL
# please set your api key (CloudStackGUI であらかじめ作成しておく)
api_key="QBbqiA_mGMp23w8lX1zadH_PCruxaqj55iTtQgCQst5Pd5aJ1TrXKErTX3UKIvmx4Ok5WaJZNPwY0o
1Y_ORP2A"
# please set your secret key(CloudStackGUI であらかじめ作成しておく)
secret_key="oN5z4NafX9OrwknE39f9sT_rhSrfdCa1CRuoCjO3iD214wzM4JGLIT2TjwmvBerWLuM9OOdnCEtyV
pPy02rOkg"
api_path="/client/api?"
if [ $# -lt 1 ]; then
echo "usage: $0 command=... paramter=... parameter=..."; exit;
elif [[ $1 != "command=" ]]; then*
echo "usage: $0 command=... paramter=... parameter=..."; exit;
elif [ $1 == "command=" ]; then
echo "usage: $0 command=... paramter=... parameter=..."; exit;
fi
data_array=("$@" "apikey=${api_key}")
temp1=$(echo -n ${data_array[@]} |
tr " " "n" | sort -fd -t'=' |
8
COPYRIGHT FUJITSU LIMITED 2014
16. 以下の内容で作成します。
name: firstbosh
logging:
level: DEBUG
network:
type: dynamic
ip: 172.16.10.227
#インセプションサーバの IP アドレス
resources:
persistent_disk: 20512
cloud_properties:
instance_type: m1.large2
# VM タイプ(コンピュータオファリング)
cloud:
plugin: cloudstack
properties:
cloudstack:
endpoint: http://172.16.10.224:8080/client/api
# Cloudstack の管理サーバのアドレスに、/client/api を付与したものを指定
api_key:
QBbqiA_mGMp23w8lX1zadH_PCruxaqj55iTtQgCQst5Pd5aJ1TrXKErTX3UKIvmx4Ok5WaJZNPwY0o1Y_ORP2
A
# キーペア作成時に指定したもの
secret_access_key:
oN5z4NafX9OrwknE39f9sT_rhSrfdCa1CRuoCjO3iD214wzM4JGLIT2TjwmvBerWLuM9OOdnCEtyVpPy02rOkg
# キーペア作成時に指定したもの
default_key_name: cfmykey
# キーペア作成時に指定したキーペア名
private_key: /root/cfmykey # キーペア作成時に出力内容を保存したキーファイル名
state_timeout: 600
state_timeout_volume: 1200
stemcell_public_visibility: true
default_zone: zone01 # Zone name of your instaption server
11
COPYRIGHT FUJITSU LIMITED 2014
17. # Only for Basic Zone users. Delete these lines on Advanced Zone
default_security_groups: ["default"]
# TCP、UDP での全ての通信が可能なセキュリティグループ名を[""]で括って指定
registry:
endpoint: http://admin:admin@172.16.10.227:25889
# インセプションサーバの IP を指定
user: admin
password: admin
3.1.7. ソースコードの修正
(1) デバイスアタッチ処理関連
デバイスアタッチの不具合対応として、以下のソースコードの修正を行っておく。
ファイル名:~/bosh/bosh_cloudstack_cpi/lib/cloud/cloudstack/cloud.rb
コード最下部の以下の部分を修正
-----------------------------------------
def volume_device_name(device_id)
# assumes device name begins with "dev/sd" and volume_name is numeric
cloud_error("Unkown device id given") if device_id.nil?
suffix = ('a'..'z').to_a[device_id]
cloud_error("too many disks attached") if suffix.nil?
"/dev/sd#{suffix}"
end
-----------------------------------------
↓以下に修正
-----------------------------------------
def volume_device_name(device_id)
# assumes device name begins with "dev/sd" and volume_name is numeric
cloud_error("Unkown device id given") if device_id.nil?
suffix = ('a'..'z').to_a[device_id-1]
cloud_error("too many disks attached") if suffix.nil?
12
COPYRIGHT FUJITSU LIMITED 2014
19. 3.1.8. マイクロボッシュのデプロイ
(1) Proxy サーバの無効化
デプロイ処理のため、proxy の設定を一度無効にしておく。
# unset http_proxy
# unset https_proxy
(2) Micro BOSH によるデプロイ
以下のコマンドを例に、デプロイを実行する。
# cd ~/deployments
# BUNDLE_GEMFILE=~/bosh/Gemfile bundle exec bosh micro deployment firstbosh
# BUNDLE_GEMFILE=~/bosh/Gemfile bundle exec bosh micro deploy /tmp/<3.1.3.(3)で作成した stemcell ファイ
ル名>
(3) firstbosh のアドレスの確認
デプロイが正常に行われると、デプロイ実行用の最初のインスタンス(firstbosh)が起動される。
インスタンスの IP アドレスを /root/deployments/firstbosh/bosh_micro_deploy.log ファイルの target への接続
ログから確認する。
(4) ターゲットの指定
上記で確認した IP を使用して、新たに起動されたインスタンスをターゲットとして指定する
# BUNDLE_GEMFILE=~/bosh/Gemfile bundle exec bosh target https://172.16.10.229:25555
※ ユーザー名/パスワードは admin/admin
※ ログインし直す場合は、
# BUNDLE_GEMFILE=~/bosh/Gemfile bundle exec bosh login
でログインする
(5) ステータスの確認
上記でデプロイした bosh 環境の状況を以下のコマンドで確認する。
14
COPYRIGHT FUJITSU LIMITED 2014
20. # BUNDLE_GEMFILE=~/bosh/Gemfile bundle exec bosh status
-----------------------------------------
Config
/root/.bosh_config
Director
Name firstbosh
URL https://172.16.10.230:25555
Version 1.2063.0 (release:c8e032de bosh:c8e032de)
User admin
UUID f90c0235-6a22-401a-a0b0-2e619fb8f31a
CPI cloudstack
dns enabled (domain_name: microbosh)
compiled_package_cache disabled
snapshots disabled
Deployment
not set
3.2. BOSH デプロイの準備
3.2.1. Proxy サーバの設定
環境変数へ proxy の再設定を行い、Cloudstack 管理サーバ、インセプションサーバ、
Firstbosh(ターゲット)の各 IP アドレスを no_proxy 環境変数へ追加して設定する
# export no_proxy=172.16.10.224,172.16.10.227,172.16.10.228,172.16.10.230,172.16.10.229,192.168.3.224
3.2.2. 不足領域の追加
次項の bosh upload release を行う際に、Firstbosh の VM で領域不足エラー「Error 500001: Uploading release
archive failed. Insufficient space on BOSH director in /var/vcap/data/tmp/director/release20140910-2239-1mz1yey」が発
生するため、FirstboshVM へログインして対象ディレクトリに追加ディスクをマウントして領域の確
保を行う。
(1) 追加ストレージの準備
CloudstackGUI で追加用のボリューム(disk20gb)を作成し、FirstboshVM にアタッチしておく
15
COPYRIGHT FUJITSU LIMITED 2014
21. (2) FirstboshVM へのログイン
キーファイルを使用して FirstboshVM へのログインを行う。
# ssh -i cfmyke vcap@172.16.10.xxx
password:c1oudc0w
(3.1.5.で作成したキーペアを指定する)
(3)ストレージ領域の作成とマウント
以下のコマンドを例に、FirstboshVM 内からアタッチしたボリュームのマウントを行う。
○マウント実行例
$ ls /dev/vd*
/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdc
$ sudo mkfs -t ext4 /dev/vdc
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
(略)
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
$ sudo ls /mnt
$ sudo mount /dev/vdc /mnt
$ sudo cp -r /var/vcap/data/tmp/ /mnt*
$ ls /mnt
director lost+found
$ ls tmp/
director
$ sudo umount /mnt
$ sudo mount /dev/vdc /var/vcap/data/tmp
$ ls /var/vcap/data/tmp
director lost+found
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 5.1G 4.5G 54% /
16
COPYRIGHT FUJITSU LIMITED 2014
27. 4.1.2. デプロイ用マニフェストの作成
以下の内容でデプロイ用のマニフェストファイル(cf.yml)を作成する。
※以下の内容はデフォルト値。追加の修正内容は以降に記載
name: cf
director_uuid: 884aab78-3b73-494c-aa6f-b7fe9b2d7e1b # UUID shown by the bosh status command ●●確認して記
述●●
releases:
- name: cf
version: 147 # Verison number of the uploded release ●●現環境で使用しているのは 183 ●●
networks:
- name: default
type: dynamic
cloud_properties:
# Only for Basic Zone users
security_groups:
## - bosh # Securiy group which opens all TCP and UDP ports
- default # default● で全 port 開けているのでそのまま指定●
## # Only for Advanced Zone users
## network_name: <network_name> # subnetwork ●無効化●
# Only for Advanced Zone users
# Network with floating IP addresses
- name: floating
type: vip
cloud_properties: {}
compilation:
22
COPYRIGHT FUJITSU LIMITED 2014
28. workers: 6
network: default
reuse_compilation_vms: true
cloud_properties:
instance_type: m1.medium # VM type
ephemeral_volume: Datadisk 40GB # Data disk offering name of additonal disk
update:
canaries: 1
canary_watch_time: 30000-60000
update_watch_time: 30000-60000
max_in_flight: 4
resource_pools:
- name: small
network: default
size: 8
stemcell:
name: bosh-cloudstack-kvm-ubuntu
version: latest
cloud_properties:
instance_type: m1.small # VM type
ephemeral_volume: Datadisk 40GB # Data disk offering name of additonal disk
- name: large
network: default
size: 1
stemcell:
name: bosh-cloudstack-kvm-ubuntu
version: latest
cloud_properties:
instance_type: m1.large # VM type
ephemeral_volume: Datadisk 40GB # Data disk offering name of additional disk
jobs:
- name: nats
release: cf
template:
23
COPYRIGHT FUJITSU LIMITED 2014