Help us understand the problem. What is going on with this article?

VagrantにてOpenstack&TungstenFabricを一発構築してみた(作業:1分未満、待ち:数十分)

More than 1 year has passed since last update.

はじめに

勉強のためTungstenFabricを構築しては壊しての日々が続いたため、時間節約のため一発で構築する方法を模索しました。

今回の記事ではOpenstack&TungstenFabric構築を以下オフィシャルを参考にしていますが、同じようにKubernetes&TungstenFabricやhelmも可能かと思われます。※次記事で投稿予定です。

https://github.com/Juniper/contrail-ansible-deployer/wiki/Contrail-with-Openstack-Kolla

前提条件

最低で以下の前提条件は満たす必要があります
・RAMはあればあるだけ嬉しいですが今回は13GBほど使用します
・ディスクは50GBあれば大丈夫かと
・当方ではOSにMacOSを使用しましたがLinux系であれば、おそらく問題ないかも
・最新のVagrant、VirtualBoxインストール済み
・もちろんインターネットにつなげてね

構築に使用したPCは以下
・Macbook pro(2017) 13inch RAM 16GB

正直自分の環境でギリギリ動く感じです。
今回の手順では必要最低限のdockerコンテナだけ稼動させてます。

Openstack&TungstenFabric(AllinOne)構築

以下ファイルでvagrant upするだけです。Boxも勝手にダウンロードされます。完了するまでに数十分かかるのでまったり眺めてましょう。
途中timeoutすることもあるため、その場合はvagrant destroyして再度vagrant upし直して下しい。
■Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8143, host: 8143, host_ip: "127.0.0.1"
  config.vm.define :node1 do |node|
    node.vm.hostname = "contrail"
    config.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--memory", "13124", "--cpus", "2"]
    end
    config.vm.provision "shell", inline: <<-SHELL
      yum install git curl epel-release -y
      yum install ntp ansible-2.4.2.0 net-tools -y
      yum install python-pip -y
      pip install requests
      sudo mkdir -m 700 /root/.ssh
      sudo ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa
      sudo cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
      sudo cat /root/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_key
      row=`grep "ssh_connection" -n /etc/ansible/ansible.cfg | cut -d: -f1`
      sed -i "$row a ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o UserKnownHostsFile=\/dev\/null" /etc/ansible/ansible.cfg
      sudo git clone -b R5.0 http://github.com/Juniper/contrail-ansible-deployer
      sudo mv contrail-ansible-deployer /root
      sudo cat <<'EOF' > /root/contrail-ansible-deployer/config/instances.yaml
provider_config:
  bms:
    ssh_pwd: root
    ssh_user: root
    domainsuffix: local
instances:
  bms1:
    provider: bms
    ip: 10.0.2.15
    roles:
      config_database:
      config:
      control:
      analytics_database:
      analytics:
      webui:
      vrouter:
      openstack:
      openstack_compute:
contrail_configuration:
  RABBITMQ_NODE_PORT: 5673
  AUTH_MODE: keystone
  KEYSTONE_AUTH_URL_VERSION: /v3
  CONTRAIL_CONTAINER_TAG: r5.0.1
  OPENSTACK_VERSION: queens
kolla_config:
  kolla_globals:
    enable_haproxy: "no"
    enable_swift: "no"
    enable_ironic: "no"
  kolla_passwords:
    keystone_admin_password: contrail123
global_configuration:
  CONTAINER_REGISTRY: tungstenfabric
EOF
      sudo sed -i -e 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
      systemctl restart sshd
      sleep 10
      cd /root/contrail-ansible-deployer;ansible-playbook -i inventory/ playbooks/configure_instances.yml -vvv
      sleep 10
      cd /root/contrail-ansible-deployer;ansible-playbook -i inventory/ playbooks/install_openstack.yml -vvv
      cd /root/contrail-ansible-deployer;ansible-playbook -i inventory/ playbooks/install_openstack.yml -vvv
      sleep 10
      for i in `docker ps | grep -e heat -e barbican | awk '{print $1}'`;do docker stop $i;done;
      cd /root/contrail-ansible-deployer;ansible-playbook -i inventory/ -e orchestrator=openstack playbooks/install_contrail.yml -vvv
      sleep 10
      sudo service ntpd start
      sleep 10
      yum install gcc python-level -y
      pip install python-openstackclient
      cp /etc/kolla/kolla-toolbox/admin-openrc.sh /root
      contrail-status
    SHELL
  end
end

install_openstack.ymlを2回Playbookかけてるのはよくtimeoutで失敗するためです。単純に高スペックマシンを使えば解消できるかと思われます。

[root@contrail ~]# contrail-status
~snip~
== Contrail control ==
control: active
nodemgr: active
named: active
dns: active

== Contrail config-database ==
nodemgr: initializing (Disk for DB is too low. )
zookeeper: active
rabbitmq: active
cassandra: active

== Contrail database ==
kafka: active
nodemgr: initializing (Disk for DB is too low. )
zookeeper: active
cassandra: active

== Contrail analytics ==
snmp-collector: active
query-engine: active
api: active
alarm-gen: active
nodemgr: active
collector: active
topology: active

== Contrail webui ==
web: active
job: active

== Contrail vrouter ==
nodemgr: active
agent: inactive

== Contrail config ==
svc-monitor: active
nodemgr: active
device-manager: active
api: active
schema: active

Horizonにはhttp://localhost:8080でブラウザアクセスできます。
Contrail WebUIはhttps://localhost:8143でブラウザアクセスできます。
openstackweb.png
tungstenweb.png

何とか動いていますが、メモリぎりぎりまで使用するためとても重いです。
そこで↓を検討

Contrail Analyticsの停止

Tungsten FabricのAnalyticsはネットワーク可視化のため多くのメモリを使用するため、
メモリ量に悩む場合はこれを停止させることにより動作が安定します。ただしweb-uiのMonitorが動作しなくなるため注意ください。
dockerコンテナを停止させる方法とvagrantのデプロイ対象から外す2通りで実施可能です。

dockerコンテナを停止するパターン

for i in `docker ps | grep -e analytics | awk '{print $1}'`;do docker stop $i;done;

vagrantのデプロイ対象から外すパターン

以下の通りVagrantfileの2行をコメントアウトしてからvagrant upしてください

      #analytics_database:
      #analytics:

停止結果

dockerコンテナを停止するパターンの場合は以下の通りとなりました。
analyticsをストップさせた時

[root@contrail ~]# contrail-status
~snip~
== Contrail control ==
control: initializing (Collector connection down)
nodemgr: initializing (Collector connection down)
named: active
dns: active

== Contrail config-database ==
nodemgr: initializing (Disk for DB is too low. Collector connection down)
zookeeper: active
rabbitmq: active
cassandra: active

== Contrail database ==
kafka: inactive
nodemgr: inactive
zookeeper: inactive
cassandra: inactive

== Contrail analytics ==
snmp-collector: inactive
query-engine: inactive
api: inactive
alarm-gen: inactive
nodemgr: inactive
collector: inactive
topology: inactive

== Contrail webui ==
web: active
job: active

== Contrail vrouter ==
nodemgr: initializing (Collector connection down)
agent: active (Collector connection down)

== Contrail config ==
svc-monitor: initializing (Collector connection down)
nodemgr: initializing (Collector connection down)
device-manager: initializing (Collector connection down)
api: initializing (Collector connection down)
schema: initializing (Collector connection down)

[root@contrail ~]#

(Collector connection down)となりますが、analyticsを止めたためです。想定通りです。
メモリに相当余裕ができます。

[root@contrail ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            12G        7.0G        3.8G         13M        1.5G        5.0G
Swap:          2.0G        1.0M        2.0G
[root@contrail ~]#

以上

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away