no about note

エンジニアのメモ書き

Cobbler+Ansible+PackstackでOpenstack(Liberty)マルチノードを構築した話(その2)

f:id:noabout:20160616235742p:plain

前回の話

noaboutsnote.hatenablog.com

Packstack実行後の設定

Neutronの外部ネットワークへの接続設定

NetworkNode(opsn02)で実施

ifcfg-br-ex作成
## opsn02で実施

# vi ifcfg-br-ex
DEVICE=br-ex
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=172.16.0.32
NETMASK=255.255.0.0
GATEWAY=172.16.0.1
ONBOOT=yes
NM_CONTROLLED=no
ifcfg-xxxx修正
## 変更後
# cat ifcfg-xxxx
DEVICE=enp2s0f0
ONBOOT=yes
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=br-ex
ネットワークサービス再起動
# systemctl restart network

openvswitch_agent.iniの設定変更

NetworkNodeとComputeNodeで実施
## opsn02-06で実施 (Controllerノード以外)

# cd /etc/neutron/plugins/ml2/
# cp -p openvswitch_agent.ini openvswitch_agent.ini.org
# diff openvswitch_agent.ini openvswitch_agent.ini.org
205,206c205
< #local_ip = 172.16.0.3x
< local_ip = 10.10.0.3x
---
> local_ip = 172.16.0.3x
neutron-openvswitch-agent サービスの再起動
# systemctl restart neutron-openvswitch-agent.service

Openstackの動作確認

adminユーザのクレデンシャルファイルを読み込む

# source /root/keystonerc_admin
セキュリティグループの追加
  • これはプロジェクトごとに設定する
# nova secgroup-list-rules default
+-------------+-----------+---------+----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+----------+--------------+
|             |           |         |          | default      |
|             |           |         |          | default      |
+-------------+-----------+---------+----------+--------------+

## ICMPを許可
# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

## SSHを許可
# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0


# nova secgroup-list-rules default
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
|             |           |         |           | default      |
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
|             |           |         |           | default      |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

初期ネットワーク作成

Neutronサービス動作確認

# neutron agent-list

publicネットワーク作成

# neutron net-list
# neutron router-create router1
# neutron net-create public --router:external --shared
# neutron subnet-create --name public_subnet --enable_dhcp=False --allocation-pool=start=172.16.100.2,end=172.16.100.253 --gateway=172.16.1.1 public 172.16.1.1/16

privateネットワーク作成

# neutron net-create private-net
# neutron subnet-create --name private_subnet --enable_dhcp=True --allocation-pool=start=192.168.1.2,end=192.168.1.253  private-net 192.168.1.0/24
# neutron router-gateway-set router1 public
# neutron router-interface-add router1 subnet=private_subnet

ネットワークの動作確認

# ip netns
qrouter-5e22e13a-a9aa-4303-9b6a-xxxxx
qdhcp-b1f7958a-f1d5-4147-a8ea-xxxxxx

## Ping疎通確認
# ip netns exec qrouter-5e22e13a-a9aa-4303-9b6a-1c3b1b36dfcc ping 172.16.100.1
# ip netns exec qrouter-5e22e13a-a9aa-4303-9b6a-1c3b1b36dfcc ping 192.168.1.2

Pingが疎通することを確認

Glanceにイメージ登録

Glance image-list

# glance image-list

wgetrcの確認 (※Proxy配下の場合)

# grep proxy /etc/wgetrc  | grep -iv "^#"
http_proxy=http://xxx.xxx.xxx.xxx:(PortNumber)
https_proxy=http://xxx.xxx.xxx.xxx:(PortNumber)

イメージファイルをダウンロード

# cd /tmp/
# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

glance-image-createでGlanceにイメージ登録

# glance image-create --name "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress
# glance image-list

キーペアの作成

## opsn01で実施
# nova keypair-list
+------+-------------+
| Name | Fingerprint |
+------+-------------+
+------+-------------+

キーペア作成

# ssh-keygen -t rsa -f  id_rsa

keypair登録

# nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey

# nova keypair-list
+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 3c:ef:17:79:86:6b:4b:61:e8:c3:eb:a7:d2:44:f8:b5 |
+-------+-------------------------------------------------+

インスタンス作成

# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+

Neutronネットワークid確認

# neutron net-list
+--------------------------------------+----------+-----------------------------------------------------+
| id                                   | name     | subnets                                             |
+--------------------------------------+----------+-----------------------------------------------------+
| b1f7958a-f1d5-4147-a8ea-c7e480a193a4 | private-net | 8fb069e2-ff31-42e9-ac1e-53557d7d80c4 192.168.2.0/24 |
| c11ecf00-657c-4898-a2d1-17a91b35fadb | public   | d5e4b06b-7e37-4e1c-a4d7-f506342ac37a 172.16.0.0/16  |
+--------------------------------------+----------+-----------------------------------------------------+

インスタンス起動

# nova boot --flavor m1.tiny --image cirros --nic net-id=b1f7958a-f1d5-4147-a8ea-c7e480a193a4 --security-group default --key-name mykey cirros-test001

FloatingIP確保

# neutron floatingip-create public
Created a new floatingip:

FloatingIP割り当て

# nova floating-ip-associate cirros-test001 172.16.100.2
# nova list

Cinderボリューム作成

# cinder list
+----+--------+------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+----+--------+------+------+-------------+----------+-------------+
+----+--------+------+------+-------------+----------+-------------+

利用できるCinderタイプ確認

# cinder type-list
+--------------------------------------+------+-------------+-----------+
|                  ID                  | Name | Description | Is_Public |
+--------------------------------------+------+-------------+-----------+
| 7bca3c24-317c-44c8-8308-8ecb9d23033b | nfs  |      -      |    True   |
+--------------------------------------+------+-------------+-----------+

Cinderボリューム作成

# cinder create --volume_type nfs --display_name nfsvolume001 1

インスタンスへの接続

# nova volume-attach cirros-test001 bfa47292-e01d-4d93-9f28-c87e6c7034cc auto

インスタンスでボリュームを使用する

# ssh 172.16.10.1

# hostname
cirros-test001

$ sudo -i

# fdisk -l

Disk /dev/vda: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *       16065     2088449     1036192+  83  Linux

Disk /dev/vdb: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders, total 2097152 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: 0x00000000

Disk /dev/vdb doesn't contain a valid partition table

# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x75782e5b.
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/vdb: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders, total 2097152 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: 0x75782e5b

   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): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151

Command (m for help): p

Disk /dev/vdb: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders, total 2097152 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: 0x75782e5b

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     2097151     1047552   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

# mkdir /mnt/volume01
# mkfs.ext4 /dev/vdb
mke2fs 1.42.2 (27-Mar-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 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

# mount /dev/vdb /mnt/volume01/
# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev                    242.3M         0    242.3M   0% /dev
/dev/vda1                23.2M     18.0M      4.0M  82% /
tmpfs                   245.8M         0    245.8M   0% /dev/shm
tmpfs                   200.0K     72.0K    128.0K  36% /run
/dev/vdb               1007.9M     33.3M    923.4M   3% /mnt/volume01

# cd /mnt/volume01/
# touch test.txt
# ls -la
total 21
drwxr-xr-x    3 root     root          4096 Apr 19 08:05 .
drwxrwxr-x    3 root     root          1024 Apr 19 08:04 ..
drwx------    2 root     root         16384 Apr 19 08:04 lost+found
-rw-------    1 root     root             0 Apr 19 08:05 test.txt

Glanceにcirrosイメージ以外の追加

参考:
Download pre-built images for OpenStack

CentOS6
## CentOS6_x86_64
# wget http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-1603.qcow2 -P /tmp

# glance image-create --name "CentOS6_x86_64" --file /tmp/CentOS-6-x86_64-GenericCloud-1603.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
CentOS7
## CentOS7_x86_64
# wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1603.qcow2 -P /tmp
# glance image-create --name "CentOS7_x86_64" --file /tmp/CentOS-7-x86_64-GenericCloud-1603.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
Ubuntu
## Ubuntu
# wget http://cloud-images.ubuntu.com/releases/15.10/release/ubuntu-15.10-server-cloudimg-amd64-disk1.img -P /tmp
# glance image-create --name "Ubuntu15.10_amd64" --file /tmp/ubuntu-15.10-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public --progress
Fedora
## Fedora
# wget https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-23-20151030.x86_64.qcow2 -P /tmp

# glance image-create --name "Fedora_23_Cloud" --file /tmp/Fedora-Cloud-Base-23-20151030.x86_64.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress

続きは次回

OpenStack 構築手順書 Liberty版 (Think IT Books)

OpenStack 構築手順書 Liberty版 (Think IT Books)

OpenStack-Ansibleで作る HA環境構築手順書 Kilo版 (Think IT Books)

OpenStack-Ansibleで作る HA環境構築手順書 Kilo版 (Think IT Books)