13. 第2日 ハンズオンガイド No.1
仮想マシン#1の作成 (5)
- 全てのパッケージを最新にアップデートして、仮想マシンを再起動します。
# yum -y update
# mv -f /etc/yum.repos.d/fedora-updates* ~/work/
# reboot
●
パッケージをアップデートすると、YUMリポジトリの設定ファイルが追加されますが、演習環境では不要なた
め、mvコマンドで取り除いています。
13
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
14. 第2日 ハンズオンガイド No.1
RDOのインストール (1)
■
quickrdoを利用して、コントローラーノードにRDOをインストールします。
- ホストLinuxから仮想マシン#1(OPST1-□)にログインします。
$ ssh root@172.16.□.11
- GitHubからquickrdoを取得します。
# yum -y install git
# cd ~
# git clone https://github.com/enakai00/quickrdo
# cd quickrdo
# git checkout f18-grizzly-mn
Branch f18-grizzly-mn set up to track remote branch f18-grizzly-mn from origin.
Switched to a new branch 'f18-grizzly-mn'
●
チェックアウトするブランチは「f18-grizzly-mn」です。最後に「Switched to a new branch 'f18-grizzlymn'」と表示されることを確認します。
- 演習環境に事前に用意したリポジトリからインストールするように、設定を変更します。(イン
ターネット上のリポジトリを使用する場合は、これらの作業は不要です。)
スクリプト「setup.sh」を開いて、19行目(下記の矢印の行)を「#」でコメントアウトします。
~/quickrdo/setup.shのコメントアウト部分
●
この行
function rdo_install {
#
yum install -y http://rdo.fedorapeople.org/openstack/openstack-grizzly/rdo-release-grizzly.rpm
yum install -y openstack-packstack-2013.1.1-0.20.dev642.fc19.noarch
●
続いて、RDOのリポジトリ設定ファイルをダウンロードします。
# curl http://reposerver/files/rdo.repo > /etc/yum.repos.d/rdo.repo
14
●
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
15. 第2日 ハンズオンガイド No.1
RDOのインストール (2)
# yum repolist
(中略)
リポジトリー ID
fedora
openstack-grizzly
updates
repolist: 52,502
●
リポジトリー名
Fedora 18 - x86_64
OpenStack Grizzly Repository
Fedora 18 - x86_64 - Updates
状態
33,827
312
18,363
「yum repolist」で、「openstack-grizzly」のリポジトリが表示されることを確認します。
- インストールスクリプト「setup.sh」を実行します。
# ./setup.sh
●
途中で次のメッセージが出たら、rootパスワード(edubase)を入力します。
Setting up ssh keys...root@172.16.□.11's password:
●
この後、インストールが完了するまでしばらく時間がかかります。
- インストールが完了すると、「Done. Now, you need to reboot the server.」というメッセージ
がでます。
●
その他のメッセージで終了した場合は、インストールに失敗しています。この後のページを参考にして、再
度、インストールを行って下さい。
15
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
16. 第2日 ハンズオンガイド No.1
演習環境に固有の設定
■
演習環境に固有の設定を追加します。
- 次のコマンドで、ブロックボリューム削除の際のゼロクリア処理を無効化します。
●
2つ目のコマンドで「none」と表示されることを確認してください。
# openstack-config --set /etc/cinder/cinder.conf DEFAULT volume_clear none
# openstack-config --get /etc/cinder/cinder.conf DEFAULT volume_clear
none
- ここで、一度、仮想マシンを再起動します。
# reboot
16
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
17. 第2日 ハンズオンガイド No.1
RDOのインストールに失敗した場合の対応
■
注意
- インストールが途中で失敗した場合は、次のコマンドを実行するとインストール前の状態に戻り
ます。再度、「setup.sh」を実行してください。
# cd ~/quickrdo
# ./cleanup.sh
This will completely uninstall all openstack-related components.
Are you really sure? (yes/no) yes
「yes」を入力
# vgcreate cinder-volumes /dev/vda2
# reboot
17
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
18. 第2日 ハンズオンガイド No.1
OpenStackの稼働確認 (1)
■
OpenStackの稼動状態を確認します。
- ホストLinuxから仮想マシン#1(OPST1-□)にログインします。
$ ssh root@172.16.□.11
- OpenStackに関連するサービスの稼動状態を確認します。
# . ~/keystonerc_admin
# openstack-status
== Nova services ==
openstack-nova-api:
openstack-nova-cert:
openstack-nova-compute:
openstack-nova-network:
openstack-nova-scheduler:
openstack-nova-volume:
openstack-nova-conductor:
== Glance services ==
openstack-glance-api:
openstack-glance-registry:
== Keystone service ==
openstack-keystone:
== Horizon service ==
openstack-dashboard:
(以下省略)
●
active
active
active
inactive (disabled on boot)
active
inactive (disabled on boot)
active
active
active
active
active
すべてのサービスの状態が「active」もしくは「inactive (disabled on boot)」であることを確認します。
18
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
19. 第2日 ハンズオンガイド No.1
OpenStackの稼働確認 (2)
- メッセージキューとの接続状態をログファイルから確認します。
# grep AMQP /var/log/nova/scheduler.log | tail -5
2013-12-12 21:23:03.288 ERROR nova.openstack.common.rpc.impl_qpid [req-f3e997c2-6ba3-4290-a8f4ea9f4a04ab75 None None] Unable to connect to AMQP server: connection-forced: Authentication
failed(320). Sleeping 32 seconds
2013-12-12 21:23:35.297 ERROR nova.openstack.common.rpc.impl_qpid [req-f3e997c2-6ba3-4290-a8f4ea9f4a04ab75 None None] Unable to connect to AMQP server: connection-forced: Authentication
failed(320). Sleeping 60 seconds
2013-12-12 21:24:35.322 ERROR nova.openstack.common.rpc.impl_qpid [req-f3e997c2-6ba3-4290-a8f4ea9f4a04ab75 None None] Unable to connect to AMQP server: connection-forced: Authentication
failed(320). Sleeping 60 seconds
2013-12-12 21:25:10.161 INFO nova.openstack.common.rpc.impl_qpid [req-c2ccc03f-79c3-45a1-ad574c91cf5afcf3 None None] Connected to AMQP server on 172.16.1.11:5672
2013-12-12 21:25:10.256 INFO nova.openstack.common.rpc.impl_qpid [req-c2ccc03f-79c3-45a1-ad574c91cf5afcf3 None None] Connected to AMQP server on 172.16.1.11:5672
●
最初の方は、ERRORが表示されていますが、最後に「Connected to AMQP server」というメッセージが出て
いれば問題ありません。最後までERRORの場合は、qpidd.serviceを再起動して、再度、先のログファイルを
確認してください。
# systemctl restart qpidd.service
19
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
20. 第2日 ハンズオンガイド No.1
プロジェクト環境の初期設定 (1)
■
サンプルプロジェクトを構成して、利用開始に必要な初期設定を行います。
- ここでは、quickrdoの初期設定スクリプト「config.sh」を利用して、次の設定を行います。
●
●
サンプルプロジェクト「demo」の作成
OpenStack利用ユーザ「demo_user」と管理ユーザ「demo_admin」の作成(パスワードはどちらも
「passw0rd」)
●
プロジェクト「demo」用の仮想ルータと仮想ネットワーク「private01」「private02」の作成
●
セキュリティグループ「default」の設定(SSH接続とpingの許可)
●
SSHログイン認証用のキーペア「mykey」の作成と登録
●
マシンイメージ「Fedora19」の登録
- 初期設定スクリプト「~/quickrdo/config.sh」をviエディタで開き、冒頭の変数を下図のように
変更します。
●
□は、ユーザ番号(1〜7)を入れてください。
~/quickrdo/config.shの変更部分
public="172.16.0.0/16"
gateway="172.16.0.1"
nameserver="172.16.0.1"
pool=("172.16.□.100" "172.16.□.199")
private=("192.168.101.0/24" "192.168.102.0/24")
サブネットマスク「16」と「24」の違いに注意
20
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
21. 第2日 ハンズオンガイド No.1
プロジェクト環境の初期設定 (2)
- 同じく、22行目の「--copy-from」オプションのURLを下記に変更します。
if ! glance image-show "Fedora19" >/dev/null 2>&1; then
glance image-create --name "Fedora19"
--disk-format qcow2 --container-format bare --is-public true
--copy-from http://reposerver/files/fedora-19.x86_64.qcow2
fi
この行
- 初期設定スクリプトを実行します。
# cd ~/quickrdo
# ./config.sh
External NIC: eth1
Private NIC: eth2
「eth1」を入力
「eth2」を入力
- 上記のように「External NIC:」「Private NIC:」という表示がでるので、仮想マシンインスタン
スがアクセスするNIC(パブリック側「eth1」とプライベート側「eth2」)を入力します。
- 最後に「Configuration finished.」と表示されれば完了です。
●
■
上記のメッセージがでないで終了した場合は、初期設定に失敗しています。失敗した原因を取り除いた後に、
「./config.sh」を再度実行すると、以前の設定を削除して、新しく設定が行われます。
この後、コンピュートノードを追加することで、実際に仮想マシンインスタンスが起動
できるようになります。
- コンピュートノードは、運用中に任意のタイミングで自由に追加することができます。
21
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
30. 第2日 ハンズオンガイド No.1
RDOのインストール (1)
■
quickrdoを利用して、コンピュートノードにRDOをインストールします。
- この作業はコントローラノード(OPST1-□)から実施します。
- ホストLinuxから仮想マシン#1(OPST1-□)にログインします。
$ ssh root@172.16.□.11
- 演習環境に事前に用意したリポジトリからインストールするように、設定を変更します。(イン
ターネット上のリポジトリを使用する場合は、これらの作業は不要です。)
●
スクリプト「~/quickrdo/lib/prep_compute.sh」を開いて、下記のように、8行目を「#」でコメントアウト
して、curlコマンドの行を追加します。
lib/prep_compute.shの変更部分
function pre_install {
setenforce 0
sed -i.bak 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
#
yum update -y
yum install -y http://rdo.fedorapeople.org/openstack/openstack-grizzly/rdo-release-grizzly.rpm
curl http://reposerver/files/rdo.repo > /etc/yum.repos.d/rdo.repo
yum install -y patch iptables-services
この行を追加
この行をコメントアウト
30
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
31. 第2日 ハンズオンガイド No.1
RDOのインストール (2)
- quickrdoの「add_compute.sh」を実行します。
# cd ~/quickrdo
# ./add_compute.sh 172.16.□.12
Private NIC: eth1
Doing preparations...
インストール対象のコンピュートノードのIPアドレスを指定
コンピュートノードのプライベートネットワーク側のNIC(eth1)を入力
The authenticity of host '172.16.□.12 (172.16.□.12)' can't be established.
RSA key fingerprint is 26:ea:40:c7:1d:f3:83:9b:78:f5:f2:d4:64:55:c6:37.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.□.12' (RSA) to the list of known hosts.
root@172.16.□.12's password:
「yes」を入力
コンピュートノードのrootパスワード(edubase)を入力
- この後、RDOのインストールが自動で進みます。途中でインストール中のコンピュートノードが
再起動しますが、そのまま待ちます。下記のように、最後に「Done.」と表示されてスクリプト
が終了すればインストール完了です。
Done. Now, rebooting the server...
Connection to 172.16.1.13 closed by remote host.
ssh: connect to host 172.16.1.13 port 22: Connection refused
Network default destroyed
Network default unmarked as autostarted
Done.
●
「All-in-one構成」での導入時に実施した、仮想化ハイパーバイザにKVMを指定する作業は、
「add_compute.sh」の中で自動で行われています。
31
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
32. 第2日 ハンズオンガイド No.1
RDOのインストール (3)
- コンピュートノードが起動したら、コントローラノードで、次のコマンドにより、コンピュート
ノードが認識されていることを確認します。
# . ~/keystonerc_admin
# nova hypervisor-list
+----+---------------------+
| ID | Hypervisor hostname |
+----+---------------------+
| 1 | opst2-1
|
+----+---------------------+
- 同様にして、仮想マシン#3(OPST3-□)を作成して、コンピュートノードとして追加します。
(具体的な手順は次ページを参照)
■
注意:コンピュートノードへのRDOのインストールに失敗した場合の対応
- 演習環境では、仮想マシンの負荷が高すぎると下記のエラーでインストールに失敗する場合があ
ります。この場合は、インストール対象のコンピュートノードの仮想マシンを再起動して、再
度、コントローラーノードから、「add_compute.sh」を実行してください。
ERROR : Error during puppet run : Error: /usr/sbin/tuned-adm profile virtual-host returned 2
instead of one of [0]
Please check log file /var/tmp/packstack/20131231-072547-nrwIvc/openstack-setup.log for more
information
32
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
39. 第2日 ハンズオンガイド No.1
Keystoneの操作 (4)
- ユーザ「nova」「demo_admin」「demo_user」のロールを確認します。
# keystone user-role-list --user=nova --tenant-id=4e11791e81894494a3556911d81150a9
+----------------------------------+-------+----------------------------------+----------------------------------+
|
id
| name |
user_id
|
tenant_id
|
+----------------------------------+-------+----------------------------------+----------------------------------+
| 051e475688404eebb6fd9f5084252a3e | admin | 126e744f5f1f4e9eb3c3b4f0e7a0f819 | 4e11791e81894494a3556911d81150a9 |
+----------------------------------+-------+----------------------------------+----------------------------------+
# keystone user-role-list --user=demo_admin --tenant-id=67a8d2bb80d24b26a94959081d2aaa2a
+----------------------------------+-------+----------------------------------+----------------------------------+
|
id
| name |
user_id
|
tenant_id
|
+----------------------------------+-------+----------------------------------+----------------------------------+
| 051e475688404eebb6fd9f5084252a3e | admin | 7e88f7a917c34838bec6aaa9f66e7dd2 | 67a8d2bb80d24b26a94959081d2aaa2a |
+----------------------------------+-------+----------------------------------+----------------------------------+
# keystone user-role-list --user=demo_user --tenant-id=67a8d2bb80d24b26a94959081d2aaa2a
+----------------------------------+--------+----------------------------------+----------------------------------+
|
id
| name |
user_id
|
tenant_id
|
+----------------------------------+--------+----------------------------------+----------------------------------+
| e9d37957582340d68ec238c089e47b5d | Member | 2c7a5ebb47f645c9b05d2e1a6d4c623f | 67a8d2bb80d24b26a94959081d2aaa2a |
+----------------------------------+--------+----------------------------------+----------------------------------+
- 一般ユーザ「demo_user」用の環境変数設定ファイル「keystonerc_demo_user」を下図の内容
で作成します。
keystonerc_demo_user
export
export
export
export
export
OS_USERNAME=demo_user
一般ユーザは5000番ポートを使用
OS_TENANT_NAME=demo
OS_PASSWORD=passw0rd
OS_AUTH_URL=http://172.16.□.11:5000/v2.0/
PS1='[u@h W(keystone_demo_user)]$ '
39
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
40. 第2日 ハンズオンガイド No.1
Keystoneの操作 (5)
- 環境変数を読み込んで、テナント一覧を表示してみます。
●
一般ユーザのため一覧表示には失敗します。
# . ~/keystonerc_demo_user
# keystone tenant-list
Unable to communicate with identity service: {"error": {"message": "You are not
authorized to perform the requested action: admin_required", "code": 403, "titl
e": "Not Authorized"}}. (HTTP 403)
- パスワードを変更します。
●
最後のメッセージは、環境変数設定ファイルのパスワードを修正しておくことを促しています。
# keystone password-update
新規パスワードを入力
New Password:
Repeat New Password:
新規パスワードを再入力
You should update the password you are using to authenticate to match your new
password
- 環境変数設定ファイル「keystonerc_demo_user」の「OS_PASSWORD」を新しく設定したパスワード
に修正して、再度、設定を読み込みます。
# . ~/keystonerc_demo_user
※ 管理者権限で他のユーザのパスワードを変更する際は「keystone user-password-update」を使用します。
40
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
41. 第2日 ハンズオンガイド No.1
Glanceの操作
■
コントローラノードからコマンドラインでGlanceを操作します。
- 先ほどの操作に続けて、一般ユーザ「demo_user」で作業を継続します。「demo_user」用の環
境変数設定ファイルを読み込んでおいてください。
# . ~/keystonerc_demo_user
- インターネットからテンプレートイメージをダウンロードして、登録します。
●
ここではサンプルの小さなテンプレートイメージ「CirrOS」を使用します。
# cd ~/work
# wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
# glance image-create --name=cirros-0.3.0 --disk-format=qcow2 --container-format=bare
--file=/root/work/cirros-0.3.0-x86_64-disk.img
- 登録されたイメージを一覧表示します。
# glance image-list
+--------------------------------------+--------------+-------------+------------------+-----------+--------+
| ID
| Name
| Disk Format | Container Format | Size
| Status |
+--------------------------------------+--------------+-------------+------------------+-----------+--------+
| c7a5fcaf-935c-48a2-a073-4124c1d1fea4 | cirros-0.3.0 | qcow2
| bare
| 9761280
| active |
| 12cf8861-825c-4b90-af19-b096b402f169 | Fedora19
| qcow2
| bare
| 237371392 | active |
+--------------------------------------+--------------+-------------+------------------+-----------+--------+
41
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
56. 第2日 ハンズオンガイド No.1
Pythonスクリプトによる操作 (1)
■
Python用クライアントライブラリを使用して、仮想マシンインスタンスの起動・停止
を行うスクリプトを作成します。
- 講義テキストの「クライアントライブラリによるAPI操作」に記載のスクリプト「clients.py」と
「launch_vm.py」をカレントディレクトリに作成します。「launch_vm.py」には、実行権を設
定しておきます。
# chmod u+x launch_vm.py
- 「launch_vm.py」を実行すると、仮想マシンインスタンスが起動した後に、ブロックボリュー
ムの作成と接続、フローティングIPの割り当てが自動で行われます。
# . ~/keystonerc_demo_user
# ./launch_vm.py
/usr/lib/python2.7/site-packages/novaclient/client.py:16: UserWarning: Module backports was already imported
from /usr/lib64/python2.7/site-packages/backports/__init__.pyc, but /usr/lib/python2.7/site-packages is being
added to sys.path
import pkg_resources
Waiting status to be active.
(中略)
このWarningはpython-backportsパッケージの既知の問題です。
Waiting status to be active.
ここでは無視して下さい。
Floating IP: 172.16.1.104
# nova list
+--------------------------------------+------+--------+---------------------------------------+
| ID
| Name | Status | Networks
|
+--------------------------------------+------+--------+---------------------------------------+
| f4cdee8d-e145-4014-bea4-0d000667dfff | vm01 | ACTIVE | private01=192.168.101.3, 172.16.1.104 |
+--------------------------------------+------+--------+---------------------------------------+
# cinder list
(出力は省略)
56
Copyright (C) 2014 National Institute of Informatics, All rights reserved.
57. 第2日 ハンズオンガイド No.1
Pythonスクリプトによる操作 (2)
- 下図のスクリプト「delete_all_vm.py」は起動中の仮想マシンインスタンスをまとめて停止しま
す。先のスクリプトと同じディレクトリに作成して、実行権を設定します。
# chmod u+x delete_all_vm.py
delete_all_vm.py
#!/usr/bin/python
from clients import nova, glance, cinder
for instance in nova.servers.list():
if instance.status == 'ACTIVE':
print "Destroying instance %s (id:%s)." % (instance.name, instance.id)
instance.delete()
- 「delete_all_vm.py」を実行すると、先ほど起動した仮想マシンインスタンスが停止します。
# . ~/keystonerc_demo_user
# ./delete_all.py
/usr/lib/python2.7/site-packages/novaclient/client.py:16: UserWarning: Module backports was
already imported from /usr/lib64/python2.7/site-packages/backports/__init__.pyc, but
/usr/lib/python2.7/site-packages is being added to sys.path
import pkg_resources
Destroying instance vm01 (id:f4cdee8d-e145-4014-bea4-0d000667dfff).
- ただし、先ほど作成したブロックボリュームはそのまま残っています。ブロックボリュームを削
除するスクリプトも考えてみて下さい。
57
Copyright (C) 2014 National Institute of Informatics, All rights reserved.