概要
- Openstackというのをちょいと前に知った。どのようなものか軽く試そうとしたが、何度もくじけた末に、やっと動いた.
の、記録. - パッケージインストールまでは、vagrant使用、そのあと、ネットワークの設定を変更以降は、vagrantに設定を上書きされないように、使用しないように.
環境
- ホスト
- Windows 7 64bit メモリたくさんがいい
- VirtualBox 5.1.12
- Vagrant 1.9.1
手順
OpenStack環境の準備
-
適当なフォルダを作って、
Vagrantfile
作成
VM_MEMORY
は多いほうがいい。
↓は6GBだと、CirrosというテストOSくらいしか動かないカモ。FedoraとかUbuntuとか使うなら、8GBにする。Vagrantfile# Vagrantfile # http://qiita.com/mt08/items/1da3f44489f01bf1b64c VB_NAME="OpenStack - Newton" #VM_MEMORY=16384 #VM_MEMORY=8192 VM_MEMORY=6144 VM_CORES=2 VM_HOSTNAME="openstack1.localdomain" Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.network "private_network", ip: "192.168.56.100" #config.vm.network "public_network", bridge: 'Intel(R) Ethernet Connection I217-LM' config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.hostname = VM_HOSTNAME config.vm.provider "virtualbox" do |vb| # vb.gui = true vb.name = VB_NAME vb.memory = VM_MEMORY vb.cpus = VM_CORES vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"] #publicのmacaddress固定にして、dhcpで同じIPを得る #vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all", "--macaddress3", "080027010203", "--nicpromisc3", "allow-all"] end config.vm.provision "shell", inline: <<-SHELL yum update -y -q # epel必要なものがあれば。 #yum install -q -y epel-release #sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo #yum --nogpgcheck install -q -y --enablerepo=epel htop byobu # Passwordでも、ssh接続できる. sed -i -e 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config systemctl restart sshd yum install -y -q ntp systemctl start ntpd systemctl enable ntpd # お好みの時間帯. #timedatectl set-timezone Europe/London timedatectl set-timezone Asia/Tokyo #timedatectl set-timezone America/Los_Angeles echo "LANG=en_US.utf-8" > /etc/environment echo "LC_ALL=en_US.utf-8" >> /etc/environment systemctl disable firewalld systemctl stop firewalld systemctl disable NetworkManager systemctl stop NetworkManager systemctl enable network systemctl restart network yum install -y -q centos-release-openstack-newton yum update -y -q yum install -y -q openstack-packstack packstack --allinone --provision-demo=n --default-password=password --gen-answer-file=/root/answer.txt sed -i -e 's/10.0.2.15/192.168.56.100/g' /root/answer.txt #sed -i -e 's/10.0.2.15/publicのIPアドレス/g' /root/answer.txt packstack --answer-file=/root/answer.txt SHELL end
-
vagrant up
待つこんな感じ(時間を計ってみた)... ==> default: Applying 192.168.56.100_controller.pp 192.168.56.100_controller.pp: [ DONE ] ==> default: Applying 192.168.56.100_network.pp 192.168.56.100_network.pp: [ DONE ] ==> default: Applying 192.168.56.100_compute.pp 192.168.56.100_compute.pp: [ DONE ] ==> default: Applying Puppet manifests [ DONE ] ==> default: Finalizing [ DONE ] ==> default: ==> default: **** Installation completed successfully ****** ==> default: ==> default: Additional information: ==> default: * Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components. ==> default: * File /root/keystonerc_admin has been created on OpenStack client host 192.168.56.100. To use the command line tools you need to source the file. ==> default: * To access the OpenStack Dashboard browse to http://192.168.56.100/dashboard . ==> default: Please, find your login credentials stored in the keystonerc_admin in your home directory. ==> default: * To use Nagios, browse to http://192.168.56.100/nagios username: nagiosadmin, password: password ==> default: * The installation log file is available at: /var/tmp/packstack/20170116-150223-PYWqvR/openstack-setup.log ==> default: * The generated manifests are available at: /var/tmp/packstack/20170116-150223-PYWqvR/manifests real 12m49.294s user 0m0.000s sys 0m0.015s
-
ホストから、
ping 192.168.56.100
で応答を確認する。
=>応答がなかったら、なにかおかしい。こんな感じになるハズ$ ping 192.168.56.100 Pinging 192.168.56.100 with 32 bytes of data: Reply from 192.168.56.100: bytes=32 time<1ms TTL=64 Reply from 192.168.56.100: bytes=32 time<1ms TTL=64
ssh vagrant@192.168.56.100
パスワードvagrant
で、ログイン。
=>@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
なんてのがでたら、~/.ssh/known_hosts
の該当箇所を消す。-
(ゲストVM内)以下コピペ。
これ以降、vagrantは使わないように。vagrant up
とかすると、ネットワークの設定が書き換えられてしまう.
再起動には時間がかかるので、待つ。ブリッジネットワーク関係の設定(br-ex)とキーの生成sudo -s # # # cd # cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-br-ex TYPE=OVSBridge OVSBOOTPROTO=dhcp OVSDHCPINTERFACES=eth0 NAME=br-ex DEVICE=br-ex DEVICETYPE=ovs ONBOOT=yes EOF # cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=OVSPort NAME=eth0 DEVICE=eth0 DEVICETYPE=ovs OVS_BRIDGE=br-ex ONBOOT=yes EOF # # キーの生成 cd . keystonerc_admin nova keypair-add admin > admin_key.pem chmod 600 ./admin_key.pem # sync ; sleep 5; reboot
OpenStackでインスタンス(VM)を起動するためのネットワークの準備
ホストのブラウザで、http://192.168.56.100/
にアクセス。admin
password
でログイン。(ちなみにパスワードは、packstack実行時、 --default-password=password
のオプションで指定している。)
-
左側 Admin > Networks で、右上のほうにある [+Create Network] を押す。
項目 設定 Name: public Project: admin Provider Network Type: VXLAN Physical Network: default Segmentation ID: 1 Admin State: UP [v]
チェックするShared [v]
チェックするExternal Network => [Submit]
-
左側 Project > Network > Networks で、
public
と出てる右のほうの [Add Subnet]を押す項目 設定 Subnet name: public_subnet Network Address: 10.0.2.0/24 IP Version: IPv4 Gateway IP: 10.0.2.16 br-exのIPアドレス [ ]
チェックなしDiable Gateway [Next]を押して~ [v]
チェックするEnable DHCP Allocation Pools: 10.0.2.20,10.0.2.50
30個 DNS Name Servers: 8.8.8.8
=>[Create]を押す
-
左側 Project > Network > Networks 右上のほうの [+Create Network]を押す
項目 設定 Network Name: private Admin State: UP [ ]
チェックなしShared [v]
チェックするCreate Subnet [Next]を押して Subnet name: private_subnet Network Address: 192.168.10.0/24 IP Version: IPv4 Gateway IP: 192.168.10.1 [ ]
チェックなしDiable Gateway [Next]を押して~ [v]
チェックするEnable DHCP Allocation Pools: 192.168.10.10,192.168.10.30
20個 DNS Name Servers: 8.8.8.8
=>[Create]を押す
-
左側 Project > Network > Routers 右上のほうの [+Create Router]を押す
項目 設定 Router Name: router_admin Admin State: UP External Network Select network 選択しない => [Create Router]
-
↑のまま、
router_admin
の右のほう、[Set Gateway] を押す。項目 設定 External Network: public => [Submit]
-
↑のまま、
router_admin
を押して、Interface
を押して、[+Add Interface]を押す項目 設定 Subnet: private: 192.168.10.0/24(private_subnet) IP Address (optional) 空白のまま => [Submit]
-
Project > Compute > Access & Security の Security Groupsタブで、
default
の右のほうの [Manage Rules]を押す- 右上の [+Add Rule]を押して、 Rule:
ALL ICMP
を選んで [Add] - 同様に [+Add Rule]を押して Rule:
SSH
を選んで [Add]
- 右上の [+Add Rule]を押して、 Rule:
OSイメージの準備
ホストのブラウザからアップロードする。
-
OSイメージをダウンロードしてくる.=>参考: OpenStack Docs: イメージの入手
- CirrOS(ユーザcirros):
cirros-0.3.4-x86_64-disk.img
- Fedora(ユーザfedora) :
Fedora-Cloud-Base-25-1.3.x86_64.qcow2
- Ubuntu(ユーザubuntu) :
xenial-server-cloudimg-amd64-disk1.img
- CirrOS(ユーザcirros):
-
左側 Project > Compute > Imagesにて、右上のほうの [+Create Image]を押す
項目 設定 Image Name : Cirros Image Description: 空白 File : cirros-0.3.4-x86_64-disk.img Browseボタンを押して、ファイル選択 Format : QCOW2 - QEMU Emulator => [Create Image] でアップロードされるハズ。
インスタンス起動
-
左側 Project > Compute > Instances で右のほうの、[Launch Instance]を押す。
項目 設定 Details Instance Name: CirrosVM Availability Zone nova (そのまま) Count 1 (そのまま) [Next] を押す Source Select Boot Source: Image Volume Size(GB) 1 (そのまま)) Create New Volume Yes Delete Volume on Instance Delete Yes お好みで 下のほうに Cirrusってあるやつの右の [+] を押す [Next] Flavor m1.tinyの右の[+]を押す [Next] Networks privateの右の[+]を押す [Next] Network Ports そのまま[Next] Security Groups default
確認[Next] Key Pair admin
確認ここまで確認したらOK => [Launch Instance]を押す
-
CirrosVMというインスタンス名の右のドロップダウンボタンから、[Associate Floating IP]を選択
- IP Addressのとこの
[+]
をおす。 - Pool:
public
を確認、[Allocate IP]
- で、もどってきたら、
[Associate]
を押す。
=>192.168.10.xx
と10.0.2.xx
が関係図けられましたと。
- IP Addressのとこの
-
VirtualboxのVMに
ssh
ログインして、そこからCirrosにログインする実行例$ ssh vagrant@192.168.56.100 vagrant@192.168.56.100's password: Last login: Mon Jan 16 15:36:48 2017 from 192.168.56.1 [vagrant@localhost ~]$ sudo -s [root@localhost vagrant]# cd /root [root@localhost ~]# ssh -i ./admin_key.pem cirros@10.0.2.27 $ uname -a Linux cirrosvm 3.2.0-80-virtual #116-Ubuntu SMP Mon Mar 23 17:28:52 UTC 2015 x86_64 GNU/Linux $
その他
- OpenStackのインスタンスへのsshログインは、生成したキーを使って、
ssh -i ./admin_key.pem user@ip_address
こんな感じで。 - UbuntuもFedora同様だが、インスタンス作成時に、
Volume Size(GB)
を10ぐらいにする。あと、VirtualboxのVMのメモリがないとだめ。 -
VirtualboxのVMのメモリ6GBだと、m1.tinyのCirros実行時で、スワップが発生してる.
スワップが発生してる.[vagrant@localhost ~]$ free total used free shared buff/cache available Mem: 5946376 5615336 146992 7588 184048 73180 Swap: 1572860 772888 799972 [vagrant@localhost ~]$
次のステップを、ご教示願いたい...
参考にしたところ
- OpenStack Mitakaの導入 (Win7, Virtual Box, CentOS 7, RDO)
- ... ほかにもたくさん ...