コマンド実行:
$ /opt/support/t2-c1/1_init.sh <--- ディレクトリー「/opt/support/t2-c1」を使用します。 ...(中略)... | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+---------------------------------+ | b5440947-e245-4c7c-8d4f-301e5b75f34a | step-server | ACTIVE | - | Running | work-net=10.0.0.1, 118.67.96.82 | +--------------------------------------+-------------+--------+------------+-------------+---------------------------------+ ============================================================ Initialization Completed! ============================================================
スクリプトの内容:
$ cat userdata_dbs.txt #!/bin/bash cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime cd /root git clone -q https://github.com/josug-book1-materials/sample-app.git cd sample-app git checkout -b v1.0 remotes/origin/v1.0 sh /root/sample-app/server-setup/install_db.sh echo "### end userdata_dbs"
コマンド実行:
$ source get_net_id.sh $ nova boot --flavor standard.xsmall --image "centos-base" \ --key-name default --user-data userdata_dbs.txt \ --security-groups sg-all-from-console,sg-all-from-dbs-net \ --availability-zone az1 \ --nic net-id=${MY_DBS_NET} --nic net-id=${MY_WORK_NET} \ dbs01
コマンド実行:
$ watch -n5 nova console-log --length 30 dbs01 ...(中略)... CentOS release 6.6 (Final) Kernel 2.6.32-504.el6.x86_64 on an x86_64 dbs01 login:
スクリプトの内容:
$ cat userdata_app.txt #!/bin/bash cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime cd /root git clone https://github.com/josug-book1-materials/sample-app.git cd sample-app git checkout -b v1.0 remotes/origin/v1.0 sh /root/sample-app/server-setup/install_rest.sh yum install -y jq crudini DBS_IP=`curl -s http://169.254.169.254/openstack/latest/meta_data.json \ | jq -r '.["meta"]["dbs_ip"]'` crudini --set /root/sample-app/endpoint.conf db-server db_host $DBS_IP sh /root/sample-app/server-setup/rest.init.sh start
コマンド実行:
$ MY_DBS_IP=`get_instance_ip dbs01 dbs-net` $ echo $MY_DBS_IP 172.16.20.1 $ nova boot --flavor standard.xsmall --image "centos-base" \ --key-name default --user-data userdata_app.txt \ --security-groups \ sg-all-from-console,sg-all-from-app-net,sg-all-from-dbs-net \ --availability-zone az1 --nic net-id=${MY_APP_NET} \ --nic net-id=${MY_DBS_NET} --nic net-id=${MY_WORK_NET} \ --meta dbs_ip=${MY_DBS_IP} \ app01
スクリプトの内容:
$ cat userdata_web.txt #!/bin/bash cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime cd /root git clone -q https://github.com/josug-book1-materials/sample-app.git cd sample-app git checkout -b v1.0 remotes/origin/v1.0 sh /root/sample-app/server-setup/install_web.sh yum install -y jq crudini APP_IP=`curl -s http://169.254.169.254/openstack/latest/meta_data.json \ | jq -r '.["meta"]["app_ip"]'` crudini --set /root/sample-app/endpoint.conf rest-server rest_host $APP_IP sh /root/sample-app/server-setup/web.init.sh start
コマンド実行:
$ MY_APP_IP=`get_instance_ip app01 app-net` $ echo $MY_APP_IP 172.16.10.1 $ nova boot \ --flavor standard.xsmall --image "centos-base" \ --key-name default --user-data userdata_web.txt \ --security-groups sg-all-from-console,sg-web-from-internet,sg-all-from-app-net \ --availability-zone az1 \ --nic net-id=${MY_DMZ_NET} --nic net-id=${MY_APP_NET} \ --meta app_ip=${MY_APP_IP} \ web01
コマンド実行:
$ nova floating-ip-create Ext-Net +--------------+-----------+----------+---------+ | Ip | Server Id | Fixed Ip | Pool | +--------------+-----------+----------+---------+ | 118.67.96.85 | | - | Ext-Net | +--------------+-----------+----------+---------+ $ nova floating-ip-associate web01 118.67.96.85
コマンド実行:
$ nova list --fields name,networks +--------------------------------------+-------------+-------------------------------------------------------------+ | ID | Name | Networks | +--------------------------------------+-------------+-------------------------------------------------------------+ | d6e8c082-1839-46fb-93e6-f0d61ed1d149 | app01 | app-net=172.16.10.1; dbs-net=172.16.20.3; work-net=10.0.0.4 | | 6c84a6c9-fdda-4fce-b576-5be757ba2a74 | dbs01 | dbs-net=172.16.20.1; work-net=10.0.0.3 | | b5440947-e245-4c7c-8d4f-301e5b75f34a | step-server | work-net=10.0.0.1, 118.67.96.82 | | 2fcebc7d-ada8-416a-bade-0abad4b319b8 | web01 | dmz-net=192.168.0.1; app-net=172.16.10.3 | +--------------------------------------+-------------+-------------------------------------------------------------+
コマンド実行:
$ nova list --name step-server --fields name,networks +--------------------------------------+-------------+---------------------------------+ | ID | Name | Networks | +--------------------------------------+-------------+---------------------------------+ | b5440947-e245-4c7c-8d4f-301e5b75f34a | step-server | work-net=10.0.0.1, 118.67.96.82 | +--------------------------------------+-------------+---------------------------------+ $ ssh -i default.pem root@118.67.96.82 [root@step-server ~]#
コマンド実行:
[root@step-server ~]# ssh -i default.pem root@192.168.0.1 [root@web01 ~]# [root@web01 ~]# curl -s http://169.254.169.254/openstack/latest/; echo meta_data.json user_data password vendor_data.json [root@web01 ~]# [root@web01 ~]# curl -s http://169.254.169.254/openstack/latest/user_data #!/bin/bash ... APP_IP=`curl -s http://169.254.169.254/openstack/latest/meta_data.json \ | jq -r '.["meta"]["app_ip"]'` crudini --set /root/sample-app/endpoint.conf rest-server rest_host $APP_IP sh /root/sample-app/server-setup/web.init.sh start
コマンド実行:
[root@web01 ~]# curl -s \ http://169.254.169.254/openstack/latest/meta_data.json [root@web01 ~]# curl -s \ http://169.254.169.254/openstack/latest/meta_data.json | jq . { "name": "web01", "public_keys": { "default": "ssh-rsa AAAA...." }, "meta": { "app_ip": "172.16.10.1" }, ... }
コマンド実行:
[root@web01 ~]# curl -s \ http://169.254.169.254/openstack/latest/meta_data.json \ | jq -r '.["meta"]["app_ip"]' 172.16.10.1
userdata での参照例:
APP_IP=`curl -s http://169.254.169.254/openstack/latest/meta_data.json \ | jq -r '.["meta"]["app_ip"]'` crudini --set /root/sample-app/endpoint.conf \ rest-server rest_host $APP_IP
コマンド実行の様子:
$ /opt/support/common/9_cleanup.sh ### delete all instances # delete instance: 43a929db-44ca-4754-a8bb-bd3c1981affa # delete instance: 0b602aaf-5a18-4441-9876-c21300e1ff2d ... ### delete all FIPs # delete FIP: 118.67.96.118 ########## completed !!
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |