我在Vagrant上尝试一键构建Openstack和TungstenFabric(操作时间:不到1分钟,等待时间:数十分钟)
首先
由于为了勉强学习,我一直在构建和破坏TungstenFabric,为了节省时间,我开始探索一次性搭建的方法。
在这篇文章中,我们参考了Openstack和TungstenFabric的官方建设指南。但是,我们也认为使用Kubernetes和TungstenFabric或helm也是可能的。※我们计划在下一篇文章中发布。
前提条件
请满足以下最低前提条件:
– RAM尽量多,本次大约使用13GB
– 硬盘至少50GB应该可以
– 我们使用的是MacOS作为操作系统,但是如果是Linux系列的,应该也没有问题
– 已经安装了最新的Vagrant和VirtualBox
– 当然要连接到互联网
我所使用的构建电脑如下:
· Macbook Pro(2017)13英寸内存16GB。
在我当前的环境中,只是勉强能够工作的感觉。
在这个步骤中,我只启动了必需的最少数量的docker容器。
Openstack和TungstenFabric(一体式)的建设
只需在以下文件中运行vagrant up。Vagrant会自动下载箱子文件。由于完成需要数十分钟,所以让我们放松一下眺望吧。
由于中途可能会发生超时,所以在这种情况下,请运行vagrant destroy,然后再次运行vagrant up。
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”Playbook两次是为了解决经常因超时而失败的问题。使用高规格的机器可能简单地解决这个问题。
[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
目前虽能运作,但因为要使用到极限的内存,所以非常的卡顿。因此,考虑以下方案:
Contrail Analytics的停止:停止Contrail Analytics
钨织布(Tungsten Fabric)的分析模块为实现网络可视化功能而消耗大量内存,如果面临内存不足问题,可以通过停止此模块使系统稳定。但需要注意的是,这样会导致web-ui的监控功能无法使用。停止方法有两种,一种是停止Docker容器,另一种是将其从Vagrant部署目标中移除。
停止Docker容器的模式
for i in `docker ps | grep -e analytics | awk '{print $1}'`;do docker stop $i;done;
将vagrant的部署目标排除的模式
请先将以下的Vagrantfile文件中的两行代码注释掉,然后执行vagrant up命令。
#analytics_database:
#analytics:
停下来的结果 de
当停止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 ~]#
由于(收集器连接中断),这是因为停止了分析。这是预料之内的。
这样做会释放出相当大的内存空间。
[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 ~]#
以上