1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SoftLayerの無料ベアメタルでOpenStackの学習をする(11) - 第10章「Availability Zoneを活用した災害対策システム」

Last updated at Posted at 2015-03-29

前回はこちら - 次回はこちら


#これはなに
「OpenStackクラウドインテグレーション オープンソースクラウドによるサービス構築入門」の実習をSoftLayerの無料ベアメタルで行う記録である。
OpenStackクラウドインテグレーション オープンソースクラウドによるサービス構築入門

第10章 Availability Zoneを活用した災害対策システム

第5章から第10章までの支援ファイルはこちら。まとめてgitでダウンロードできる。
https://github.com/josug-book1-materials/chapter05-10

第10章の支援ファイルはこちらである。
https://github.com/josug-book1-materials/chapter05-10/tree/master/10

10.1 作業と目的の流れ

別のAvailability Zoneを使って災害対策を行う。
現在のアーキテクチャーではdbsは分散するわけには行かないので、app、web、lbsを新しいAvailability Zone「az2」に立て、dbsサーババーはaz1のdbs01を使うマルチAvailability Zone体制にする。
次にaz1の全面障害を想定しaz1のdbs、app、web、lbsを削除する。
az2に新しいdbsを起動し、第9章のswift上のバックアップからデータを復元しサービスを再開する。swiftはAvailability Zoneに取得しないため、ボリュームバックアップもAvailability Zoneに依存しないで利用できる。

nova と cinder はAvailability Zoneに依存するため、利用可能なAvailability Zoneを表示することができる。


[root@step-server ~]# nova availability-zone-list
+------+-----------+
| Name | Status    |
+------+-----------+
| az1  | available |
| az2  | available |
+------+-----------+
[root@step-server ~]# cinder availability-zone-list
+------+-----------+
| Name |   Status  |
+------+-----------+
| az1  | available |
| az2  | available |
+------+-----------+

10.2 データを持たないサーバーの構築

10.2.1 サーバーの起動

データを持たないapp、web、lbsを新しいAvailability Zone「az2」に立てる。作業内容はこちら

userdataは、app、webには第6章で使ったuserdata_app.txtuserdata_web.txtを、lbsには第7章で使ったuserdata_lbs.txtを利用する。

ネットワークのUUIDを取得する。


[root@step-server ~]# source openrc
[root@step-server ~]# function get_uuid () { cat - | grep " id " | awk '{print $4}'; }
[root@step-server ~]# export MY_DMZ_NET=`neutron net-show dmz-net | get_uuid`
[root@step-server ~]# export MY_APP_NET=`neutron net-show app-net | get_uuid`
[root@step-server ~]# export MY_DBS_NET=`neutron net-show dbs-net | get_uuid`

まずはappサーバー。「--availability-zone az2」が指定されているのが、これまでと違う。


[root@step-server ~]# nova boot --flavor standard.xsmall --image "centos-base" \
> --key-name key-for-internal --user-data userdata_app.txt \
> --security-groups sg-all-from-console,sg-all-from-app-net,sg-all-from-dbs-net \
> --availability-zone az2 \
> --nic net-id=${MY_DMZ_NET} --nic net-id=${MY_APP_NET} --nic net-id=${MY_DBS_NET} \
> az2-app01
+--------------------------------------+---------------------------------------------------------------+
| Property                             | Value                                                         |
+--------------------------------------+---------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                        |
| OS-EXT-AZ:availability_zone          | nova                                                          |
| OS-EXT-STS:power_state               | 0                                                             |
| OS-EXT-STS:task_state                | scheduling                                                    |
| OS-EXT-STS:vm_state                  | building                                                      |
| OS-SRV-USG:launched_at               | -                                                             |
| OS-SRV-USG:terminated_at             | -                                                             |
| accessIPv4                           |                                                               |
| accessIPv6                           |                                                               |
| adminPass                            | keWZGv7xpSkV                                                  |
| config_drive                         |                                                               |
| created                              | 2015-03-29T00:13:46Z                                          |
| flavor                               | standard.xsmall (100)                                         |
| hostId                               |                                                               |
| id                                   | 8802531e-eaad-4433-a4c2-925694b5a3ee                          |
| image                                | centos-base (098f948e-e80b-4b1a-8a46-f8d2dd57e149)            |
| key_name                             | key-for-internal                                              |
| metadata                             | {}                                                            |
| name                                 | az2-app01                                                     |
| os-extended-volumes:volumes_attached | []                                                            |
| progress                             | 0                                                             |
| security_groups                      | sg-all-from-console, sg-all-from-app-net, sg-all-from-dbs-net |
| status                               | BUILD                                                         |
| tenant_id                            | 106e169743964758bcad1f06cc69c472                              |
| updated                              | 2015-03-29T00:13:46Z                                          |
| user_id                              | 98dd78b670884b64b879568215777c53                              |
+--------------------------------------+---------------------------------------------------------------+

次に、webサーバー。「--availability-zone az2」に「--num-instances 2」で起動している。


[root@step-server ~]# nova boot --flavor standard.xsmall --image "centos-base" \
> --key-name key-for-internal --user-data userdata_web.txt \
> --security-groups sg-all-from-console,sg-web-from-internet,sg-all-from-app-net \
> --availability-zone az2 \
> --num-instances 2 \
> --nic net-id=${MY_DMZ_NET} --nic net-id=${MY_APP_NET} \
> az2-web
+--------------------------------------+----------------------------------------------------------------+
| Property                             | Value                                                          |
+--------------------------------------+----------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                         |
| OS-EXT-AZ:availability_zone          | nova                                                           |
| OS-EXT-STS:power_state               | 0                                                              |
| OS-EXT-STS:task_state                | scheduling                                                     |
| OS-EXT-STS:vm_state                  | building                                                       |
| OS-SRV-USG:launched_at               | -                                                              |
| OS-SRV-USG:terminated_at             | -                                                              |
| accessIPv4                           |                                                                |
| accessIPv6                           |                                                                |
| adminPass                            | MJa6inVNWdmV                                                   |
| config_drive                         |                                                                |
| created                              | 2015-03-29T00:15:23Z                                           |
| flavor                               | standard.xsmall (100)                                          |
| hostId                               |                                                                |
| id                                   | 14412db1-e687-4746-8072-cd26c3281cd5                           |
| image                                | centos-base (098f948e-e80b-4b1a-8a46-f8d2dd57e149)             |
| key_name                             | key-for-internal                                               |
| metadata                             | {}                                                             |
| name                                 | az2-web-14412db1-e687-4746-8072-cd26c3281cd5                   |
| os-extended-volumes:volumes_attached | []                                                             |
| progress                             | 0                                                              |
| security_groups                      | sg-all-from-console, sg-web-from-internet, sg-all-from-app-net |
| status                               | BUILD                                                          |
| tenant_id                            | 106e169743964758bcad1f06cc69c472                               |
| updated                              | 2015-03-29T00:15:23Z                                           |
| user_id                              | 98dd78b670884b64b879568215777c53                               |
+--------------------------------------+----------------------------------------------------------------+

そしてlbs。これも「--availability-zone az2」。


[root@step-server ~]# nova boot --flavor standard.xsmall --image "centos-base" \
> --key-name key-for-internal --user-data userdata_lbs.txt \
> --security-groups sg-all-from-console,sg-web-from-internet \
> --availability-zone az2 \
> --nic net-id=${MY_DMZ_NET} \
> az2-lbs01
+--------------------------------------+----------------------------------------------------+
| Property                             | Value                                              |
+--------------------------------------+----------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                             |
| OS-EXT-AZ:availability_zone          | nova                                               |
| OS-EXT-STS:power_state               | 0                                                  |
| OS-EXT-STS:task_state                | scheduling                                         |
| OS-EXT-STS:vm_state                  | building                                           |
| OS-SRV-USG:launched_at               | -                                                  |
| OS-SRV-USG:terminated_at             | -                                                  |
| accessIPv4                           |                                                    |
| accessIPv6                           |                                                    |
| adminPass                            | dknDPuv7uM8D                                       |
| config_drive                         |                                                    |
| created                              | 2015-03-29T00:17:14Z                               |
| flavor                               | standard.xsmall (100)                              |
| hostId                               |                                                    |
| id                                   | f5a32c35-bcb4-4187-86fa-d576ae6db45e               |
| image                                | centos-base (098f948e-e80b-4b1a-8a46-f8d2dd57e149) |
| key_name                             | key-for-internal                                   |
| metadata                             | {}                                                 |
| name                                 | az2-lbs01                                          |
| os-extended-volumes:volumes_attached | []                                                 |
| progress                             | 0                                                  |
| security_groups                      | sg-all-from-console, sg-web-from-internet          |
| status                               | BUILD                                              |
| tenant_id                            | 106e169743964758bcad1f06cc69c472                   |
| updated                              | 2015-03-29T00:17:14Z                               |
| user_id                              | 98dd78b670884b64b879568215777c53                   |
+--------------------------------------+----------------------------------------------------+

「az2-」で始まる4つのサーバーがこの項で起動したもの。


[root@step-server ~]# nova list --field name,networks
+--------------------------------------+----------------------------------------------+-----------------------------------------------------------------+
| ID                                   | Name                                         | Networks                                                        |
+--------------------------------------+----------------------------------------------+-----------------------------------------------------------------+
| 35d338e5-6e8a-4cee-9be1-9a37b431bf38 | app01                                        | dmz-net=192.168.0.3; app-net=172.16.10.3; dbs-net=172.16.20.1   |
| 8802531e-eaad-4433-a4c2-925694b5a3ee | az2-app01                                    | dmz-net=192.168.0.16; app-net=172.16.10.12; dbs-net=172.16.20.6 |
| f5a32c35-bcb4-4187-86fa-d576ae6db45e | az2-lbs01                                    | dmz-net=192.168.0.19                                            |
| 14412db1-e687-4746-8072-cd26c3281cd5 | az2-web-14412db1-e687-4746-8072-cd26c3281cd5 | dmz-net=192.168.0.18; app-net=172.16.10.14                      |
| 1fb89f91-4f22-464d-82e2-d6bbe20b2642 | az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 | dmz-net=192.168.0.17; app-net=172.16.10.13                      |
| edf1b599-de4f-4b2c-be90-17ab1252728f | dbs01                                        | dmz-net=192.168.0.4; dbs-net=172.16.20.3                        |
| 37cbd237-9fd9-4f95-b4e3-caafeaf67454 | lbs01                                        | dmz-net=192.168.0.5, 192.168.100.133                            |
| 65d3400d-3467-4563-9ff5-9c0e30c7157e | step-server                                  | work-net=10.0.0.1, 192.168.100.131                              |
| ca755522-3eb2-475a-8e37-7fe23398b1d9 | web01                                        | dmz-net=192.168.0.1; app-net=172.16.10.1                        |
| d0ce0d2a-f4fa-448d-bb9b-b605af386b9f | web02                                        | dmz-net=192.168.0.6; app-net=172.16.10.4                        |
| 5e8fb496-f248-42e4-a6d9-997fd6307402 | web03                                        | dmz-net=192.168.0.7; app-net=172.16.10.5                        |
| 1955e438-626f-4582-8d15-bfe13b97a084 | web04                                        | dmz-net=192.168.0.8; app-net=172.16.10.6                        |
+--------------------------------------+----------------------------------------------+-----------------------------------------------------------------+

10.2.2 アプリケーションの設定

az2-lbs01 → az2-web-(1,2) → az2-app01 → dbs01(az1)になるように設定をする。

まず、az2-app01。「dmz-net=192.168.0.16」にsshで接続。「dbs-net=172.16.20.3」のaz1にあるdbs01に接続するように設定。


[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.16
[root@az2-app01 ~]# nano /root/sample-app/endpoint.conf
[root@az2-app01 ~]# cat /root/sample-app/endpoint.conf
[rest-server]
rest_host = 127.0.0.1
rest_endpoint = http://%(rest_host)s:5555/bbs

[db-server]
db_host = 172.16.20.3
db_endpoint = mysql://user:password@%(db_host)s/sample_bbs?charset=utf8
[root@az2-app01 ~]# sh /root/sample-app/server-setup/rest.init.sh start
Starting rest.py                                           [  OK  ]
[root@az2-app01 ~]# exit
logout
Connection to 192.168.0.16 closed.

次にaz2-web。「dmz-net=192.168.0.17」と「dmz-net=192.168.0.18」の2台に「app-net=172.16.10.12」のIPでaz2-app01に接続できるようにする。


[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.17
[root@az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 ~]# nano /root/sample-app/endpoint.conf
[root@az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 ~]# cat /root/sample-app/endpoint.conf
[rest-server]
rest_host = 172.16.10.12
rest_endpoint = http://%(rest_host)s:5555/bbs

[db-server]
db_host = localhost
db_endpoint = mysql://user:password@%(db_host)s/sample_bbs?charset=utf8
[root@az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 ~]# sh /root/sample-app/server-setup/web.init.sh start
Starting web.py                                            [  OK  ]
[root@az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 ~]# exit
logout
Connection to 192.168.0.17 closed.

[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.18
[root@az2-web-14412db1-e687-4746-8072-cd26c3281cd5 ~]# nano /root/sample-app/endpoint.conf
[root@az2-web-14412db1-e687-4746-8072-cd26c3281cd5 ~]# cat /root/sample-app/endpoint.conf
[rest-server]
rest_host = 172.16.10.12
rest_endpoint = http://%(rest_host)s:5555/bbs

[db-server]
db_host = localhost
db_endpoint = mysql://user:password@%(db_host)s/sample_bbs?charset=utf8
[root@az2-web-14412db1-e687-4746-8072-cd26c3281cd5 ~]# sh /root/sample-app/server-setup/web.init.sh start
Starting web.py                                            [  OK  ]
[root@az2-web-14412db1-e687-4746-8072-cd26c3281cd5 ~]# exit
logout
Connection to 192.168.0.18 closed.

「dmz-net=192.168.0.19」で起動したaz2-lbs01のnginxに「dmz-net=192.168.0.17」「dmz-net=192.168.0.18」でwebサーバーを登録する。


[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.19
[root@az2-lbs01 ~]# nano /etc/nginx/conf.d/lbs.conf
[root@az2-lbs01 ~]# cat /etc/nginx/conf.d/lbs.conf
upstream web-server {
  server 192.168.0.17:80;
  server 192.168.0.18:80;
}

server {
  listen 80 default_server;
  server_name _;

  location / {
    proxy_pass http://web-server/;
  }
}
[root@az2-lbs01 ~]# service nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@az2-lbs01 ~]# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]
[root@az2-lbs01 ~]# exit
logout
Connection to 192.168.0.19 closed.

az2-lbs01にExt-NetのFloating Ipを払い出して付与する。


[root@step-server ~]# nova floating-ip-create Ext-Net
+-----------------+-----------+----------+---------+
| Ip              | Server Id | Fixed Ip | Pool    |
+-----------------+-----------+----------+---------+
| 192.168.100.134 |           | -        | Ext-Net |
+-----------------+-----------+----------+---------+

[root@step-server ~]# nova floating-ip-associate az2-lbs01 192.168.100.134

[root@step-server ~]# nova floating-ip-list
+-----------------+-----------+--------------+---------+
| Ip              | Server Id | Fixed Ip     | Pool    |
+-----------------+-----------+--------------+---------+
| 192.168.100.131 |           | 10.0.0.1     | Ext-Net |
| 192.168.100.134 |           | 192.168.0.19 | Ext-Net |
| 192.168.100.133 |           | 192.168.0.5  | Ext-Net |
+-----------------+-----------+--------------+---------+

192.168.100.134が付いた。でも、いつもの様に外部からはアクセスできない。

これまでWebサービスがたつ度にnginxでReverse Proxyを立ててきたが、考えてみればホストにForward Proxyをひとつ立てておけば、それでまかなえた。例えば、手順はこちら。8章のswiftからのイメージの取得も出来たはずである。

今回も、結局、Reverse Proxyにする。前回のをコピーし、接続先のIPと待ちうけポートを変更するだけですむし。


user01@test:~$ cat /etc/nginx/conf.d/az2.conf
server {
  listen 2080;
  server_name [Public IP];
  location /  {
    auth_basic "Input ID/PASS";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://192.168.100.134/;
  }
}

az2-lbs01にアクセスできることを確認する。

az2-lbs01へのアクセス

10.3 az1の障害を想定した切り替え

10.3.1 az1のサーバー停止

az1で稼動するsetp-server以外のサーバーを停止する。


[root@step-server ~]# nova list --field name,OS-EXT-AZ:availability_zone
+--------------------------------------+----------------------------------------------+------------------------------+
| ID                                   | Name                                         | OS-EXT-AZ: Availability Zone |
+--------------------------------------+----------------------------------------------+------------------------------+
| 35d338e5-6e8a-4cee-9be1-9a37b431bf38 | app01                                        | az1                          |
| 8802531e-eaad-4433-a4c2-925694b5a3ee | az2-app01                                    | az2                          |
| f5a32c35-bcb4-4187-86fa-d576ae6db45e | az2-lbs01                                    | az2                          |
| 14412db1-e687-4746-8072-cd26c3281cd5 | az2-web-14412db1-e687-4746-8072-cd26c3281cd5 | az2                          |
| 1fb89f91-4f22-464d-82e2-d6bbe20b2642 | az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 | az2                          |
| edf1b599-de4f-4b2c-be90-17ab1252728f | dbs01                                        | az1                          |
| 37cbd237-9fd9-4f95-b4e3-caafeaf67454 | lbs01                                        | az1                          |
| 65d3400d-3467-4563-9ff5-9c0e30c7157e | step-server                                  | az1                          |
| ca755522-3eb2-475a-8e37-7fe23398b1d9 | web01                                        | az1                          |
| d0ce0d2a-f4fa-448d-bb9b-b605af386b9f | web02                                        | az1                          |
| 5e8fb496-f248-42e4-a6d9-997fd6307402 | web03                                        | az1                          |
| 1955e438-626f-4582-8d15-bfe13b97a084 | web04                                        | az1                          |
+--------------------------------------+----------------------------------------------+------------------------------+

[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.3 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.4 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.5 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.1 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.6 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.7 shutdown -h now
[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.8 shutdown -h now

az1のサーバーはSHUTOFFの状態になった。


[root@step-server ~]# nova list --field name,status
+--------------------------------------+----------------------------------------------+---------+
| ID                                   | Name                                         | Status  |
+--------------------------------------+----------------------------------------------+---------+
| 35d338e5-6e8a-4cee-9be1-9a37b431bf38 | app01                                        | SHUTOFF |
| 8802531e-eaad-4433-a4c2-925694b5a3ee | az2-app01                                    | ACTIVE  |
| f5a32c35-bcb4-4187-86fa-d576ae6db45e | az2-lbs01                                    | ACTIVE  |
| 14412db1-e687-4746-8072-cd26c3281cd5 | az2-web-14412db1-e687-4746-8072-cd26c3281cd5 | ACTIVE  |
| 1fb89f91-4f22-464d-82e2-d6bbe20b2642 | az2-web-1fb89f91-4f22-464d-82e2-d6bbe20b2642 | ACTIVE  |
| edf1b599-de4f-4b2c-be90-17ab1252728f | dbs01                                        | SHUTOFF |
| 37cbd237-9fd9-4f95-b4e3-caafeaf67454 | lbs01                                        | SHUTOFF |
| 65d3400d-3467-4563-9ff5-9c0e30c7157e | step-server                                  | ACTIVE  |
| ca755522-3eb2-475a-8e37-7fe23398b1d9 | web01                                        | SHUTOFF |
| d0ce0d2a-f4fa-448d-bb9b-b605af386b9f | web02                                        | SHUTOFF |
| 5e8fb496-f248-42e4-a6d9-997fd6307402 | web03                                        | SHUTOFF |
| 1955e438-626f-4582-8d15-bfe13b97a084 | web04                                        | SHUTOFF |
+--------------------------------------+----------------------------------------------+---------+

10.3.2 SNSアプリケーションの復旧

ここでの手順はこちら

第6章でaz1にdbs01を立てたuserdata_dbs.txtで、az2にaz2-dbs01を立てる。


[root@step-server ~]# nova boot --flavor standard.xsmall --image "centos-base" \
> --key-name key-for-internal --user-data userdata_dbs.txt \
> --security-groups sg-all-from-console,sg-all-from-dbs-net \
> --availability-zone az2 \
> --nic net-id=${MY_DMZ_NET} --nic net-id=${MY_DBS_NET} \
> az2-dbs01
+--------------------------------------+----------------------------------------------------+
| Property                             | Value                                              |
+--------------------------------------+----------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                             |
| OS-EXT-AZ:availability_zone          | nova                                               |
| OS-EXT-STS:power_state               | 0                                                  |
| OS-EXT-STS:task_state                | scheduling                                         |
| OS-EXT-STS:vm_state                  | building                                           |
| OS-SRV-USG:launched_at               | -                                                  |
| OS-SRV-USG:terminated_at             | -                                                  |
| accessIPv4                           |                                                    |
| accessIPv6                           |                                                    |
| adminPass                            | 8YurPSQdxQV3                                       |
| config_drive                         |                                                    |
| created                              | 2015-03-29T01:59:40Z                               |
| flavor                               | standard.xsmall (100)                              |
| hostId                               |                                                    |
| id                                   | 1610ebe2-7ca8-4d95-949a-c3d20017bb23               |
| image                                | centos-base (098f948e-e80b-4b1a-8a46-f8d2dd57e149) |
| key_name                             | key-for-internal                                   |
| metadata                             | {}                                                 |
| name                                 | az2-dbs01                                          |
| os-extended-volumes:volumes_attached | []                                                 |
| progress                             | 0                                                  |
| security_groups                      | sg-all-from-console, sg-all-from-dbs-net           |
| status                               | BUILD                                              |
| tenant_id                            | 106e169743964758bcad1f06cc69c472                   |
| updated                              | 2015-03-29T01:59:40Z                               |
| user_id                              | 98dd78b670884b64b879568215777c53                   |
+--------------------------------------+----------------------------------------------------+

[root@step-server ~]# nova list --field name,networks --name az2-dbs01
+--------------------------------------+-----------+-------------------------------------------+
| ID                                   | Name      | Networks                                  |
+--------------------------------------+-----------+-------------------------------------------+
| 1610ebe2-7ca8-4d95-949a-c3d20017bb23 | az2-dbs01 | dmz-net=192.168.0.21; dbs-net=172.16.20.7 |
+--------------------------------------+-----------+-------------------------------------------+

10GBのボリュームaz2_dbs_vol01を作成する。


[root@step-server ~]# cinder create --display-name az2_dbs_vol01 --availability-zone az2 10
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 az2                  |
|       bootable      |                false                 |
|      created_at     |      2015-03-29T02:01:26.509122      |
| display_description |                 None                 |
|     display_name    |            az2_dbs_vol01             |
|      encrypted      |                False                 |
|          id         | 4986af31-18a7-40cb-a4d5-d000d05ba3a1 |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+

[root@step-server ~]# cinder list --display-name az2_dbs_vol01
+--------------------------------------+-----------+---------------+------+-------------+----------+-------------+
|                  ID                  |   Status  |  Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+---------------+------+-------------+----------+-------------+
| 4986af31-18a7-40cb-a4d5-d000d05ba3a1 | available | az2_dbs_vol01 |  10  |     None    |  false   |             |
+--------------------------------------+-----------+---------------+------+-------------+----------+-------------+

[root@step-server ~]# export MY_AZ2_DBS_VOL01=`cinder show az2_dbs_vol01 | get_uuid`
[root@step-server ~]# echo $MY_AZ2_DBS_VOL01
4986af31-18a7-40cb-a4d5-d000d05ba3a1

既存のバックアップdbs_vol01_res-backup01をボリュームaz2_dbs_vol01にリストアする。


[root@step-server ~]# cinder backup-list
+--------------------------------------+--------------------------------------+-----------+------------------------+------+--------------+---------------+
|                  ID                  |              Volume ID               |   Status  |          Name          | Size | Object Count |   Container   |
+--------------------------------------+--------------------------------------+-----------+------------------------+------+--------------+---------------+
| e269e1a1-0faa-49d7-ae4b-c5afb7517cf8 | 6d9d3c53-0a1b-44e9-8b51-ce41f30cdd8e | available | dbs_vol01_res-backup01 |  10  |     206      | volumebackups |
+--------------------------------------+--------------------------------------+-----------+------------------------+------+--------------+---------------+

[root@step-server ~]# export MY_DBS_VOL01_RES_BK01=`cinder backup-list |grep dbs_vol01_res-backup01 | awk '{print $2}'`

[root@step-server ~]# echo $MY_DBS_VOL01_RES_BK01
e269e1a1-0faa-49d7-ae4b-c5afb7517cf8

[root@step-server ~]# cinder backup-restore --volume-id $MY_AZ2_DBS_VOL01 $MY_DBS_VOL01_RES_BK01

[root@step-server ~]# cinder list --display-name az2_dbs_vol01
+--------------------------------------+------------------+---------------+------+-------------+----------+-------------+
|                  ID                  |      Status      |  Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+------------------+---------------+------+-------------+----------+-------------+
| 4986af31-18a7-40cb-a4d5-d000d05ba3a1 | restoring-backup | az2_dbs_vol01 |  10  |     None    |  false   |             |
+--------------------------------------+------------------+---------------+------+-------------+----------+-------------+

restoring-backupのボリュームが無くなる。


[root@step-server ~]# cinder list --status restoring-backup
+----+--------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+----+--------+--------------+------+-------------+----------+-------------+
+----+--------+--------------+------+-------------+----------+-------------+

az2_dbs_vol01という名前のボリュームも無くなりあわてる。


[root@step-server ~]# cinder list --display-name az2_dbs_vol01
+----+--------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+----+--------+--------------+------+-------------+----------+-------------+
+----+--------+--------------+------+-------------+----------+-------------+

そうそう、リストアするとボリューム名がバックアップ時のものに戻る。


[root@step-server ~]# cinder list
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+
|                  ID                  |   Status  |  Display Name | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+
| 4986af31-18a7-40cb-a4d5-d000d05ba3a1 | available | dbs_vol01_res |  10  |     None    |  false   |                                      |
| 6d9d3c53-0a1b-44e9-8b51-ce41f30cdd8e |   in-use  | dbs_vol01_res |  10  |     None    |  false   | edf1b599-de4f-4b2c-be90-17ab1252728f |
+--------------------------------------+-----------+---------------+------+-------------+----------+--------------------------------------+

名前をaz2_dbs_vol01に戻し、az2-dbs01に接続する。


[root@step-server ~]# cinder rename $MY_AZ2_DBS_VOL01 az2_dbs_vol01

[root@step-server ~]# nova volume-attach az2-dbs01 $MY_AZ2_DBS_VOL01
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdc                             |
| id       | 4986af31-18a7-40cb-a4d5-d000d05ba3a1 |
| serverId | 1610ebe2-7ca8-4d95-949a-c3d20017bb23 |
| volumeId | 4986af31-18a7-40cb-a4d5-d000d05ba3a1 |
+----------+--------------------------------------+

az2-dbs01に入り、/var/lib/mysqlにマウントする。


[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.21
[root@az2-dbs01 ~]# lsblk /dev/vdc
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdc    252:32   0  10G  0 disk
└─vdc1 252:33   0  10G  0 part
[root@az2-dbs01 ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@az2-dbs01 ~]# mount LABEL=mysql_data /var/lib/mysql
[root@az2-dbs01 ~]# service mysqld start
Starting mysqld:                                           [  OK  ]
[root@az2-dbs01 ~]# exit
logout
Connection to 192.168.0.21 closed.

az2-app01に入りdb_hostをaz2-dbs01の「dbs-net=172.16.20.7」にする。


[root@step-server ~]# ssh -i key-for-internal.pem root@192.168.0.16
[root@az2-app01 ~]# nano /root/sample-app/endpoint.conf
[root@az2-app01 ~]# cat /root/sample-app/endpoint.conf
[rest-server]
rest_host = 127.0.0.1
rest_endpoint = http://%(rest_host)s:5555/bbs

[db-server]
db_host = 172.16.20.7
db_endpoint = mysql://user:password@%(db_host)s/sample_bbs?charset=utf8
[root@az2-app01 ~]# sh /root/sample-app/server-setup/rest.init.sh restart

Starting rest.py                                           [  OK  ]
[root@az2-app01 ~]# exit
logout
Connection to 192.168.0.16 closed.

az2-lbs01経由で接続できた。ただしデータはバックアップ取得時のものに戻っている。

10-2.png


第10章の完了。
第5章からここまでがOpenStackの基本機能でクラウドを構築する内容だった。
次章からは外部ツールとの組み合わせを学習するようだ。


前回はこちら - 次回はこちら

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?