2016年4月19日火曜日

Contrail R3.0のマニュアルインストール ubuntu編(12)

Contrailの動作確認

Contrailの動作確認を行います。

1.Controllerの確認
contrail-statusコマンドを実行し、Contrailが正常動作しているか確認します。
状態が、Active又は、Backupになっていれば問題ありません。
** contrail-device-manager,contrail-schema,contrail-svc-monitorは3台中1台がActiveになります。
== Contrail Control ==
supervisor-control:           active
contrail-control              active              
contrail-control-nodemgr      active              
contrail-dns                  active              
contrail-named                active              

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

== Contrail Config ==
supervisor-config:            active
contrail-api:0                active              
contrail-config-nodemgr       active              
contrail-device-manager       backup              
contrail-discovery:0          active              
contrail-schema               active              
contrail-svc-monitor          backup              
ifmap                         active              

== Contrail Web UI ==
supervisor-webui:             active
contrail-webui                active              
contrail-webui-middleware     active              

== Contrail Database ==
contrail-database:            active
supervisor-database:          active
contrail-database-nodemgr     active              
kafka                         active              

== Contrail Support Services ==
supervisor-support-service:   active
rabbitmq-server               active    

2.vRouterの確認
同様にcontrail-statusを実行し、Activeか確認します。
== Contrail vRouter ==
supervisor-vrouter:           active
contrail-vrouter-agent        active              
contrail-vrouter-nodemgr      active  

3.WebUIの確認
Webブラウザからhttp://Contrail1:8080/にアクセスし、adminユーザーでログインします。
ダッシュボードに各ノードの数が表示されます。
エラーが表示されていなければContrailの動作確認は終了です。
実際に仮想ネットワークや、仮想マシンを立てて通信してください。



Contrail R3.0のマニュアルインストール ubuntu編(11)

Compute Nodeの設定

Compute Nodeの設定をします。
Nova Computeの設定は色々とありますが、ここでは簡単な設定のみ行います。もし、ContrailのLocal repository以外のNova Computeを利用したい場合は、Contralのパッケージをインストールする前にNova Computeをインストールしておくことをお勧めします。
**対象サーバ Compute1

1.変数の設定
HOST=10.84.50.135  ## インストール対象サーバのIPアドレスを指定
OPENSTACK=10.84.50.134  ## Openstack ServerのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
DEV=p514p2  ## Control/Data用の物理NIC名
MAC=90:e2:ba:a1:aa:e1  ## Control/Data用の物理NICのMACアドレス
DGW=10.84.50.252  ## Control/Data用のデフォルトゲートウェイ。このルーティングはLinux Kernelでは使用しません。

2.Nova Computeパッケージのインストール
apt-get update
apt-get install -y nova-compute sysfsutils

3./etc/nova.confの修正
echo "[DEFAULT]
dhcpbridge_flagfile=/etc/nova/nova.conf
dhcpbridge=/usr/bin/nova-dhcpbridge
logdir=/var/log/nova
state_path=/var/lib/nova
lock_path=/var/lock/nova
force_dhcp_release=True
libvirt_use_virtio_for_bridges=True
verbose=True
ec2_private_dns_show_ip=False
api_paste_config=/etc/nova/api-paste.ini
enabled_apis=ec2,osapi_compute,metadata
rabbit_host = $OPENSTACK
security_group_api = neutron
service_neutron_metadata_proxy = True
compute_driver = libvirt.LibvirtDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
novncproxy_port = 5999
novncproxy_host = 0.0.0.0
auth_strategy = keystone
network_api_class = nova.network.neutronv2.api.API
novncproxy_base_url = http://$OPENSTACK:6080/vnc_auto.html
vncserver_enabled = true
vncserver_listen = $HOST
vncserver_proxyclient_address = $HOST

[keystone_authtoken]
admin_tenant_name = service
admin_user = nova
admin_password = password
auth_protocol = http
auth_host = $OPENSTACK
auth_port = 35357
signing_dir = /tmp/keystone-signing-nova

[neutron]
admin_auth_url = http://$OPENSTACK:35357/v2.0/
admin_username = neutron
admin_password = password
admin_tenant_name = service
url = http://$IVIP:9696/
url_timeout = 300
service_metadata_proxy = True

[compute]
compute_driver = libvirt.LibvirtDriver

[glance]
host = $OPENSTACK" > /etc/nova.conf

4./etc/libvirt/qemu.confの修正
echo 'cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
    "/dev/rtc", "/dev/hpet","/dev/net/tun",
]' >> /etc/libvirt/qemu.conf

5.Contrail vRouterパッケージのインストール
Linux Kernelが3.13.0-40以外の場合
apt-get -y install contrail-openstack-vrouter contrail-vrouter-dkms contrail-vrouter-common contrail-nova-vif
Linux Kernelが3.13.0-40の場合
apt-get -y install contrail-openstack-vrouter contrail-vrouter-3.13.0-40-generic contrail-vrouter-common contrail-nova-vif

6./etc/contrail/vrouter_nodemgr_paramの修正
echo "DISCOVERY=$IVIP" > /etc/contrail/vrouter_nodemgr_param

7./etc/contrail/agent_paramの修正
echo "LOG=/var/log/contrail.log
CONFIG=/etc/contrail/contrail-vrouter-agent.conf
prog=/usr/bin/contrail-vrouter-agent
kmod=vrouter
pname=contrail-vrouter-agent
LIBDIR=/usr/lib64
DEVICE=vhost0
dev=$DEV
LOGFILE=--log-file=/var/log/contrail/vrouter.log" > /etc/contrail/agent_param

8./etc/contrail/contrail-vrouter-agent.confの修正
sed -i -e "/^\[DISCOVERY\]/i platform=default" /etc/contrail/contrail-vrouter-agent.conf
sed -i -e "/^\[DISCOVERY\]/i physical_interface_mac=$MAC" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# server=127.0.0.1/server=$IVIP/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# max_control_nodes=1/max_control_nodes=2/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# type=kvm/type=kvm/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# control_network_ip=/control_network_ip=$HOST/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# name=vhost0/name=vhost0/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# ip=10.1.1.1/24/ip=$HOST/24/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# gateway=10.1.1.254/gateway=$DGW/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# physical_interface=vnet0/physical_interface=$DEV/g" /etc/contrail/contrail-vrouter-agent.conf
sed -i "s/# thread_count = 4/thread_count = 4/g" /etc/contrail/contrail-vrouter-agent.conf

9./etc/network/interfacesの修正
vRouterはControl/Dataで使用する物理NICをvhost0にバインドします。このため、物理インターフェイスにはIPアドレスを振らずに、vhost0にアドレスを振ります。
以下のコマンドを実行して、/etc/network/interfaceにコピペしてください。
echo "auto $DEV
iface $DEV inet manual
    pre-up ifconfig $IDEV up
    post-down ifconfig $IDEV down


auto vhost0
iface vhost0 inet static
    pre-up /opt/contrail/bin/if-vhost0
    netmask 255.255.255.0
    network_name application
    address $HOST
    gateway $DGW
    dns-nameservers 8.8.8.8"

10./etc/contrail/contrail-vrouter-nodemgr.confの修正
echo "[DISCOVERY]
server=$IVIP
port=5998" >> /etc/contrail/contrail-vrouter-nodemgr.conf

11.ComputeNodeのリブート
Compute Nodeをリブートします。

12.ContrailへComputeNodeを追加
WebUIを開き"Configure"->"Infrastructure"->"Virtual Routers"を開き、"+"をクリックします。
以下のようなダイアログが開くので、"Name"にCompute Nodeのホスト名"IP Address"にCompute Nodeのvhost0のIPアドレスを入力します。

これで設定は終了です。
次は動作確認です。

Contrail R3.0のマニュアルインストール ubuntu編(10)

Contrailの初期設定

Contrailを初期設定します。
**対象サーバ Contrail1 どれか一つで行えばOKです。
1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
OPENSTACK=10.84.50.134  ## Openstack ServerのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス
host_name1=contrail1  ## Contrail1のホスト名
host_name2=contrail2  ## Contrail2のホスト名
host_name3=contrail3  ## Contrail3のホスト名

2.Config Nodeの設定
python /opt/contrail/utils/provision_config_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name1 --host_ip $host1
python /opt/contrail/utils/provision_config_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name2 --host_ip $host2
python /opt/contrail/utils/provision_config_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name3 --host_ip $host3

3.Database Nodeの設定
python /opt/contrail/utils/provision_database_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name1 --host_ip $host1
python /opt/contrail/utils/provision_database_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name2 --host_ip $host2
python /opt/contrail/utils/provision_database_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name3 --host_ip $host3

4.Analytics Nodeの設定
python /opt/contrail/utils/provision_analytics_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name1 --host_ip $host1
python /opt/contrail/utils/provision_analytics_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name2 --host_ip $host2
python /opt/contrail/utils/provision_analytics_node.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name3 --host_ip $host3

5.ContrailのConfig設定
python /opt/contrail/utils/provision_control.py --api_server_ip $IVIP --api_server_port 8082 --admin_user admin --admin_password password --admin_tenant_name admin --oper add --host_name $host_name1 --host_ip $host1 --router_asn 64512
python /opt/contrail/utils/provision_encap.py --api_server_ip $IVIP --admin_user admin --admin_password password --oper add --encap_priority MPLSoUDP,MPLSoGRE,VXLAN
python /opt/contrail/utils/provision_linklocal.py --api_server_ip $IVIP --admin_user admin --admin_password password --admin_tenant_name admin --oper add --ipfabric_service_ip $OPENSTACK --ipfabric_service_port 8775 --linklocal_service_name metadata --linklocal_service_ip 169.254.169.254 --linklocal_service_port 80

次はCompute Nodeの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(9)

WebUIの設定

ContrailのWebUIを設定します
WebUIはcontrail-webui,contrail-webui-middlewareで構成されます
**対象サーバ Contrail1-3

1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
OPENSTACK=10.84.50.134  ## Openstack ServerのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス

2.パッケージのインストール
apt-get -y install contrail-openstack-webui

3./etc/contrail/config.global.jsの修正
sed -i "s/config.networkManager.ip =.*/config.networkManager.ip = '$IVIP';/g" /etc/contrail/config.global.js
sed -i "s/config.imageManager.ip = .*/config.imageManager.ip = '$OPENSTACK'/g" /etc/contrail/config.global.js
sed -i "s/config.computeManager.ip = .*/config.computeManager.ip = '$OPENSTACK'/g" /etc/contrail/config.global.js
sed -i "s/config.identityManager.ip = .*/config.identityManager.ip = '$OPENSTACK'/g" /etc/contrail/config.global.js
sed -i "s/config.storageManager.ip = .*/config.storageManager.ip = '$OPENSTACK'/g" /etc/contrail/config.global.js
sed -i "s/config.cnfg.server_ip = /config.cnfg.server_ip = '$IVIP'/g" /etc/contrail/config.global.js
sed -i "s/config.analytics.server_ip = /config.analytics.server_ip = '$IVIP'/g" /etc/contrail/config.global.js
sed -i "s/config.cassandra.server_ips = .*/config.cassandra.server_ips = ['$host1', '$host2', '$host3']/g" /etc/contrail/config.global.js

4.contrail-webui-userauth.jsの修正
set -i "s/contrail123/password/g" /etc/contrail/contrail-webui-userauth.js

5.シンボリックリンクの作成
ln -s /usr/bin/node /usr/bin/nodejs

6.WebUIの起動
service supervisor-webui restart

次は初期コンフィグの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(8)

Analytics Nodeの設定

Contrailで使用するAnalytics Nodeを設定します。
Analytics Nodeはcontrail-alarm-gen,contrail-analytics-api,contrail-collector,contrail-query-engine,contrail-snmp-collector,contrail-topologyで構成されます。
**対象サーバ Contrail1-3

1. 変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
OPENSTACK=10.84.50.134  ## Openstack ServerのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス

2.パッケージのインストール
apt-get -y install contrail-openstack-analytics

3./etc/redis/redis.confの修正
sed -i "s/^bind/#bind/g" /etc/redis/redis.conf
sed -i "s/^save/#save/g" /etc/redis/redis.conf
sed -i "s/^dbfilename/#dbfilename/g" /etc/redis/redis.conf
sed -i "s/^lua-time-limit 5000/lua-time-limit 15000/g" /etc/redis/redis.conf

4./etc/contrail/contrail-collector.confの修正
sed -i "s/^# cassandra_server_list=.*/cassandra_server_list=$host1:9160 $host2:9160 $host3:9160/g" /etc/contrail/contrail-collector.conf
sed -i "s/^# kafka_broker_list=.*/kafka_broker_list=$host1:9092 $host2:9092 $host3:9092/g" /etc/contrail/contrail-collector.conf
sed -i "s/^# hostip=/hostip=$HOST/g" /etc/contrail/contrail-collector.conf
sed -i "s/^# http_server_port=8089/http_server_port=8089/g" /etc/contrail/contrail-collector.conf
sed -i "s/^# syslog_port=514/syslog_port=-1/g" /etc/contrail/contrail-collector.conf
sed -i "s/^# port=8086/port=8086/g" /etc/contrail/contrail-collector.conf
sed -i -e "/^# IP address of discovery server/a server=$IVIP" /etc/contrail/contrail-collector.conf
sed -i -e "/^# IP address of redis-server/a server=127.0.0.1" /etc/contrail/contrail-collector.conf
sed -i -e "/^cassandra_server_list/a zookeeper_server_list=$host1:2181,$host2:2181,$host3:2181" /etc/contrail/contrail-collector.conf

5./etc/contrail/contrail-query-engine.confの修正
sed -i "s/^# Collector configuration options/# Query-Engine configuration options/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# cassandra_server_list=127.0.0.1:9160/cassandra_server_list=$host1:9160 $host2:9160 $host3:9160/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# hostip=.*/hostip=$HOST/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# http_server_port=8089/http_server_port=8091/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# server=127.0.0.1 # discovery_server IP address/server=$IVIP/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# port=6379/port=6379/g" /etc/contrail/contrail-query-engine.conf
sed -i "s/^# server=127.0.0.1/server=127.0.0.1/g" /etc/contrail/contrail-query-engine.conf

6./etc/contrail/contrail-analytics-api.confの修正
sed -i "s/^#host_ip = 127.0.0.1/host_ip = $HOST/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#cassandra_server_list=127.0.0.1:9160/cassandra_server_list=$host1:9160 $host2:9160 $host3:9160/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#http_server_port = 8090/http_server_port = 8090/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#rest_api_port = 8081/rest_api_port = 9081/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#rest_api_ip = 0.0.0.0/rest_api_ip = 0.0.0.0/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#log_category = /log_category = /g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#disc_server_ip = 127.0.0.1/disc_server_ip = $IVIP/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#disc_server_port = 5998/disc_server_port = 5998/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#redis_server_port=6379/redis_server_port=6379/g" /etc/contrail/contrail-analytics-api.conf
sed -i "s/^#redis_query_port=6379/redis_query_port=6379/g" /etc/contrail/contrail-analytics-api.conf

7./etc/contrail/contrail-analytics-nodemgr.confの修正
sed -i "s/server=.*/server=$IVIP/g" /etc/contrail/contrail-analytics-nodemgr.conf

8./etc/contrail/contrail-snmp-collector.confの修正
sed -i "s/^#zookeeper=.*/zookeeper=$host1:2181,$host2:2181,$host3:2181/g" /etc/contrail/contrail-snmp-collector.conf
sed -i "s/^#disc_server_ip=.*/disc_server_ip=$IVIP/g" /etc/contrail/contrail-snmp-collector.conf
sed -i "s/^#disc_server_port=5998/disc_server_port=5998/g" /etc/contrail/contrail-snmp-collector.conf

9./etc/contrail/supervisord_analytics_files/contrail-snmp-collector.iniの修正
sed -i "s/command=.*/command=\/usr\/bin\/contrail-snmp-collector --conf_file \/etc\/contrail\/contrail-snmp-collector.conf --conf_file \/etc\/contrail\/contrail-keystone-auth.conf/g" /etc/contrail/supervisord_analytics_files/contrail-snmp-collector.ini

10./etc/contrail/contrail-topology.confの修正
sed -i "s/^#zookeeper=.*/zookeeper=$host1:2181,$host2:2181,$host3:2181/g" /etc/contrail/contrail-topology.conf

echo "[DISCOVERY]
disc_server_ip = $IVIP
disc_server_port = 5998" >> /etc/contrail/contrail-topology.conf

11./etc/contrail/supervisord_analytics_files/contrail-topology.iniの修正
sed -i "s/command=.*/command=\/usr\/bin\/contrail-topology --conf_file \/etc\/contrail\/contrail-topology.conf --conf_file \/etc\/contrail\/contrail-keystone-auth.conf/g" /etc/contrail/supervisord_analytics_files/contrail-topology.ini

12./etc/contrail/contrail-alarm-gen.confの修正
sed -i "s/^#host_ip =.*/host_ip = $HOST/g" /etc/contrail/contrail-alarm-gen.conf
sed -i "s/^#kafka_broker_list =.*/kafka_broker_list=$host1:9092 $host2:9092 $host3:9092/g" /etc/contrail/contrail-alarm-gen.conf
sed -i "s/^#zk_list =.*/zk_list = $host1:2181,$host2:2181,$host3:2181/g" /etc/contrail/contrail-alarm-gen.conf
sed -i "s/^#disc_server_ip =.*/disc_server_ip=$IVIP/g" /etc/contrail/contrail-alarm-gen.conf
sed -i "s/^#disc_server_port =.*/disc_server_port=5998/g" /etc/contrail/contrail-alarm-gen.conf

13.Analytics Nodeの起動
service supervisor-analytics restart

次はWebUIの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(7)

Control Nodeの設定

Contrailで使用するControl Nodeを設定します。
Control Nodeはcontrail-control,contrail-dns,contrail-namedで構成されます。
**対象サーバ Contrail1-3

1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定 

2./etc/contrail/contrail-control.confの修正
sed -i "s/# hostip=/hostip=$HOST/g" /etc/contrail/contrail-control.conf
sed -i "s/# server=127.0.0.1/server=$IVIP/g" /etc/contrail/contrail-control.conf
sed -i "s/# password=control-node/password=$HOST/g" /etc/contrail/contrail-control.conf
sed -i "s/# user=control-node/user=$HOST/g" /etc/contrail/contrail-control.conf

3./etc/contrail/contrail-dns.confの修正
cp /etc/contrail/contrail-control.conf /etc/contrail/contrail-dns.conf
sed -i "s/^# Control-node/# DNS/g" /etc/contrail/contrail-dns.conf
sed -i "s/^password=.*/password=$HOST.dns/g" /etc/contrail/contrail-dns.conf
sed -i "s/^user=.*/user=$HOST.dns/g" /etc/contrail/contrail-dns.conf

4.Control nodeの起動
service supervisor-control restart

次はAnalytics Nodeの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(6)

Config Nodeの設定 

Contrail Nodeはcontrail-api, contrail-device-manager, contrail-discovery, contrail-schema, contrail-svc-monitor, ifmapで構成されます。
**対象サーバ Contrail1-3

1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
OPENSTACK=10.84.50.134  ## Openstack ServerのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス

2./etc/security/limits.confの修正
echo 'root soft nofile 65535' >> /etc/security/limits.conf 
echo 'root hard nofile 65535' >> /etc/security/limits.conf 
echo '* hard nofile 65535' >> /etc/security/limits.conf 
echo '* soft nofile 65535' >> /etc/security/limits.conf 
echo '* hard nproc 65535' >> /etc/security/limits.conf 

3./etc/contrail/contrail-keystone-auth.confの修正
echo "
[KEYSTONE]
auth_host=$OPENSTACK
auth_protocol=http
auth_port=35357
admin_user=admin
admin_password=password
admin_tenant_name=admin
insecure=False
memcache_servers=127.0.0.1:11211" > /etc/contrail/contrail-keystone-auth.conf

4./etc/ifmap-server/log4j.propertiesの修正
sed -i 's/log4j.rootLogger=INFO/log4j.rootLogger=TRACE, CONSOLE/g' /etc/ifmap-server/log4j.properties
sed -i 's/log4j.logger.de.fhhannover.inform.irond.proc=INFO, A1/log4j.logger.de.fhhannover.inform.irond.proc=TRACE, A1, A2/g' /etc/ifmap-server/log4j.properties
sed -i 's/log4j.appender.A1=org.apache.log4j.FileAppender/log4j.appender.A1=org.apache.log4j.ConsoleAppender/g' /etc/ifmap-server/log4j.properties
sed -i -e '/log4j.appender.A1.File=\/var\/log\/contrail\/ifmap-server.log/d'  /etc/ifmap-server/log4j.properties

echo '
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=/var/log/contrail/ifmap-server.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %x - %m%n

log4j.logger.de.fhhannover.inform.irond.rawrequests=TRACE, A3
log4j.additivity.de.fhhannover.inform.irond.rawrequests=false
log4j.appender.A3=org.apache.log4j.FileAppender
log4j.appender.A3.file=irond_raw.log
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%d %-5p %x - %m%n

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-8r [%t] %-5p %C{1} %x - %m%n' >> /etc/ifmap-server/log4j.properties

5./etc/ifmap-server/basicauthusers.propertiesの修正
ユーザー名は変更になる可能性があります。https://bugs.launchpad.net/juniperopenstack/+bug/1499206
echo "
api-server:api-server
schema-transformer:schema-transformer
svc-monitor:svc-monitor

# This is a read-only MAPC
reader:reader
$host1:$host1
$host1.dns:$host1.dns
$host2:$host2
$host2.dns:$host2.dns
$host3:$host3
$host3.dns:$host3.dns" > /etc/ifmap-server/basicauthusers.properties

echo 'api-server=api-server-1--0000000001-1' > /etc/ifmap-server/publisher.properties

6./etc/contrail/contrail-api.conf の修正
sed -i -e '/^\#/d' /etc/contrail/contrail-api.conf 
sed -i -e '/^$/d' /etc/contrail/contrail-api.conf 
sed -i "s/cassandra_server_list = .*/cassandra_server_list=$host1:9160 $host2:9160 $host3:9160/g" /etc/contrail/contrail-api.conf
sed -i "s/disc_server_ip = .*/disc_server_ip=$IVIP/g" /etc/contrail/contrail-api.conf
sed -i 's/ = /=/g' /etc/contrail/contrail-api.conf

echo "ifmap_server_ip=$HOST
ifmap_server_port=8443
listen_ip_addr=0.0.0.0
listen_port=9100
disc_server_ip=$IVIP
disc_server_port=5998
zk_server_ip=$host1:2181,$host2:2181,$host3:2181
rabbit_server=$IVIP:5673
list_optimization_enabled=True
auth = keystone
multi_tenancy=True

[SECURITY]
use_certs=False
keyfile=/etc/contrail/ssl/private_keys/apiserver_key.pem
certfile=/etc/contrail/ssl/certs/apiserver.pem
ca_certs=/etc/contrail/ssl/certs/ca.pem" >> /etc/contrail/contrail-api.conf

7./etc/init.d/contrail-apiの修正
echo '#!/bin/sh

# chkconfig: 2345 99 01
# description: Juniper Network Virtualization API

supervisorctl -s unix:///tmp/supervisord_config.sock ${1} `basename ${0}:0`' > /etc/init.d/contrail-api

8./etc/contrail/contrail-schema.confの修正
sed -i "s/disc_server_ip = .*/disc_server_ip=$IVIP/g" /etc/contrail/contrail-schema.conf
sed -i 's/ = /=/g' /etc/contrail/contrail-schema.conf

echo "ifmap_server_ip=$HOST
ifmap_server_port=8443
ifmap_username=schema-transformer
ifmap_password=schema-transformer
api_server_ip=$IVIP
api_server_port=8082
api_server_use_ssl=False
zk_server_ip=$host1:2181,$host2:2181,$host3:2181
cassandra_server_list=$host1:9160 $host2:9160 $host3:9160
rabbit_server=$IVIP:5673

[SECURITY]
use_certs=False
keyfile=/etc/contrail/ssl/private_keys/schema_xfer_key.pem
certfile=/etc/contrail/ssl/certs/schema_xfer.pem
ca_certs=/etc/contrail/ssl/certs/ca.pem" >> /etc/contrail/contrail-schema.conf

9./etc/contrail/contrail-device-manager.confの修正
sed -i "s/disc_server_ip = .*/disc_server_ip=$IVIP/g" /etc/contrail/contrail-device-manager.conf
sed -i 's/ = /=/g' /etc/contrail/contrail-device-manager.conf

echo "api_server_ip=$IVIP
api_server_port=8082
api_server_use_ssl=False
zk_server_ip=$host1:2181,$host2:2181,$host3:2181
cassandra_server_list=$host1:9160 $host2:9160 $host3:9160
rabbit_server=$IVIP:5673" >> /etc/contrail/contrail-device-manager.conf

10./etc/contrail/contrail-svc-monitor.confの修正
echo "[DEFAULTS]
ifmap_server_ip=$HOST
ifmap_server_port=8443
ifmap_username=svc-monitor
ifmap_password=svc-monitor
api_server_ip=$IVIP
api_server_port=8082
api_server_use_ssl=False
zk_server_ip=$host1:2181,$host2:2181,$host3:2181
log_file=/var/log/contrail/contrail-svc-monitor.log
cassandra_server_list=$host1:9160 $host2:9160 $host3:9160
disc_server_ip=$IVIP
disc_server_port=5998
region_name=RegionOne
log_local=1
log_level=SYS_NOTICE
rabbit_server=$IVIP:5673

[SECURITY]
use_certs=False
keyfile=/etc/contrail/ssl/private_keys/svc_monitor_key.pem
certfile=/etc/contrail/ssl/certs/svc_monitor.pem
ca_certs=/etc/contrail/ssl/certs/ca.pem

[SCHEDULER]
analytics_server_ip=$IVIP
analytics_server_port=8081" > /etc/contrail/contrail-svc-monitor.conf

11./etc/contrail/contrail-discovery.confの修正
sed -i "s/zk_server_ip=.*/zk_server_ip=$host1,$host2,$host3/g" /etc/contrail/contrail-discovery.conf
sed -i 's/listen_port=.*/listen_port=9110/g' /etc/contrail/contrail-discovery.conf
sed -i "s/cassandra_server_list.*/cassandra_server_list=$host1:9160 $host2:9160 $host3:9160/g" /etc/contrail/contrail-discovery.conf


echo '[DNS-SERVER]
policy=fixed ' >> /etc/contrail/contrail-discovery.conf

#"modify contrail discovery init script"
echo '#!/bin/sh

# chkconfig: 2345 99 01
# description: Juniper Network Virtualization API

supervisorctl -s unix:///tmp/supervisord_config.sock ${1} `basename ${0}:0`' >  /etc/init.d/contrail-discovery

12./etc/contrail/contrail-discovery.confの修正
sed -i 's/;AUTHN_TYPE =.*/AUTHN_TYPE=keystone/g' /etc/contrail/vnc_api_lib.ini
sed -i 's/;AUTHN_PROTOCOL =.*/AUTHN_PROTOCOL=http/g' /etc/contrail/vnc_api_lib.ini
sed -i "s/;AUTHN_SERVER =.*/AUTHN_SERVER=$OPENSTACK/g" /etc/contrail/vnc_api_lib.ini
sed -i 's/;AUTHN_PORT =.*/AUTHN_PORT=35357/g' /etc/contrail/vnc_api_lib.ini
sed -i 's/;AUTHN_URL =.*/AUTHN_URL=\/v2.0\/tokens/g' /etc/contrail/vnc_api_lib.ini

13./etc/contrail/contrail-config-nodemgr.confの修正
sed -i "s/server=.*/server=$IVIP/g" /etc/contrail/contrail-config-nodemgr.conf

14./etc/sudoers.d/contrail_sudoersの修正
echo 'Defaults:contrail !requiretty

Cmnd_Alias CONFIGRESTART = /usr/sbin/service supervisor-config restart

contrail ALL = (root) NOPASSWD:CONFIGRESTART' > /etc/sudoers.d/contrail_sudoers

15./etc/neutron/plugins/opencontrail/ContrailPlugin.iniの修正
echo "[APISERVER]
api_server_ip = $IVIP
api_server_port = 8082
multi_tenancy = True
contrail_extensions = ipam:neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_ipam.NeutronPluginContrailIpam,policy:neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_policy.NeutronPluginContrailPolicy,route-table:neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_vpc.NeutronPluginContrailVpc,contrail:None

[COLLECTOR]
analytics_api_ip = $IVIP
analytics_api_port = 8081

[KEYSTONE]
auth_url = http://$OPENSTACK:35357/v2.0
admin_user=admin
admin_password=password
admin_tenant_name=admin" > /etc/neutron/plugins/opencontrail/ContrailPlugin.ini

16./etc/default/neutron-serverの修正
sed -i 's/NEUTRON_PLUGIN_CONFIG=.*/NEUTRON_PLUGIN_CONFIG="\/etc\/neutron\/plugins\/opencontrail\/ContrailPlugin.ini"/g' /etc/default/neutron-server

set values to neutron config
sed -i 's/^core_plugin = .*/core_plugin = neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2/g' /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a log_format = %(asctime)s.%(msecs)d %(levelname)8s [%(name)s] %(message)s/' /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a service_plugins = neutron_plugin_contrail.plugins.opencontrail.loadbalancer.plugin.LoadBalancerPlugin' /etc/neutron/neutron.conf
sed -i -e "/^core_plugin/a rabbit_hosts = $IVIP:5673" /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a api_extensions_path = extensions:\/usr\/lib\/python2.7\/dist-packages\/neutron_plugin_contrail\/extensions' /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a allow_overlapping_ips = True' /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a auth_strategy = keystone' /etc/neutron/neutron.conf
sed -i -e '/^core_plugin/a bind_port = 9697' /etc/neutron/neutron.conf

sed -i -e "/^\[quotas\]/a quota_driver = neutron_plugin_contrail.plugins.opencontrail.quota.driver.QuotaDriver" /etc/neutron/neutron.conf

sed -i "s/auth_uri = .*/auth_uri = http:\/\/$OPENSTACK:35357\/v2.0\//g" /etc/neutron/neutron.conf
sed -i "s/identity_uri = .*/identity_uri = http:\/\/$IVIP:5000/g" /etc/neutron/neutron.conf
sed -i "s/admin_tenant_name = .*/admin_tenant_name = service/g" /etc/neutron/neutron.conf
sed -i "s/admin_user = .*/admin_user = neutron/g" /etc/neutron/neutron.conf
sed -i "s/admin_password = .*/admin_password = password/g"  /etc/neutron/neutron.conf
sed -i -e '/^admin_password/a auth_protocol = http' /etc/neutron/neutron.conf
sed -i -e "/^admin_password/a auth_host = $OPENSTACK" /etc/neutron/neutron.conf

echo '[QUOTAS]
quota_network = -1
quota_subnet = -1
quota_port = -1

[service_providers]
service_provider = LOADBALANCER:Opencontrail:neutron_plugin_contrail.plugins.opencontrail.loadbalancer.driver.OpencontrailLoadbalancerDriver:default' >> /etc/neutron/neutron.conf

17.プロセスのリスタート
service neutron-server restart
service supervisor-config restart

次はControlNodeの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(5)

Contrail Support Serviceの設定 

Contrailで使用するRabbitMQを設定します。
**対象サーバ Contrail1-3

1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
HOSTNAME=contrail1  ## インストール対象サーバのホスト名を指定
COOKIES=AANIJMOJRKEOIUDWHAVA  ## RabbitMQのCokkieを指定。全てのサーバで共通のCokkieを使用

2.不要プロセスの停止とディレクトリ削除
pkill -9 beam
pkill -9 epmd
rm -rf /var/lib/rabbitmq/mnesia

3./etc/rabbitmq/rabbitmq-env.confの修正
echo "NODE_IP_ADDRESS=$HOST
NODENAME=rabbit@$HOSTNAME-ctrl" >/etc/rabbitmq/rabbitmq-env.conf

4./etc/rabbitmq/rabbitmq-env.confの修正
echo "[
   {rabbit, [ {tcp_listeners, [{\"$HOST\", 5672}]}, {cluster_partition_handling, autoheal},{loopback_users, []},
              {cluster_nodes, {['rabbit@contrail1-ctrl', 'rabbit@contrail2-ctrl', 'rabbit@contrail3-ctrl'], disc}},
              {vm_memory_high_watermark, 0.4},
              {disk_free_limit,50000000},
              {log_levels,[{connection, info},{mirroring, info}]},
              {heartbeat,10},
              {delegate_count,20},
              {channel_max,5000},
              {tcp_listen_options,
                        [binary,
                          {packet, raw},
                          {reuseaddr, true},
                          {backlog, 128},
                          {nodelay, true},
                          {exit_on_close, false},
                          {keepalive, true}
                         ]
              },
              {collect_statistics_interval, 60000}
            ]
   },
   {rabbitmq_management_agent, [ {force_fine_statistics, true} ] },
   {kernel, [{net_ticktime,  30}]}
]." > /etc/rabbitmq/rabbitmq.config

5./var/lib/rabbitmq/.erlang.cookieの修正
echo $COOKIES > /var/lib/rabbitmq/.erlang.cookie

6.プロセスのスタート
service supervisor-support-service restart

7.RabbitMQの確認
rabbitmqctl cluster_statusを実行し、クラスタの確認を行います。
rabbitmqctl cluster_status
Cluster status of node 'rabbit@contrail1-ctrl' ...
[{nodes,[{disc,['rabbit@contrail1-ctrl','rabbit@contrail2-ctrl',
                'rabbit@contrail3-ctrl']}]},
 {running_nodes,['rabbit@contrail3-ctrl','rabbit@contrail2-ctrl','rabbit@contrail1-ctrl']},
 {cluster_name,<<"rabbit@contrail1">>},
 {partitions,[]}]

次はConfig Nodeの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(4)

Database Nodeの設定 

Contrailで使用するDatabase Nodeを設定します。
Database Nodeは Cassandra,Zookeeper,Kafkaで構成されます。
**対象サーバ Contrail1-3

1.変数の設定
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
ID=1  ## Zookeeper用のID。サーバ毎に一意のIDを設定。例えば、1,2,3とそれぞれのサーバに割り当て
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス

2.パッケージのインストール
apt-get -y install contrail-openstack-database
以下のようなエラーが発生した場合は、再度上記コマンドを実行してください。
Errors were encountered while processing:
 cassandra
 contrail-openstack-database
E: Sub-process /usr/bin/dpkg returned an error code (1)

3.Analytics用のディレクトリを作成
mkdir -p /var/lib/cassandra/data/config_db_uuid 
mkdir -p /var/lib/cassandra/data/ContrailAnalytics
mkdir -p /var/lib/cassandra/data
sudo chown -R cassandra /var/lib/cassandra
sudo chgrp -R cassandra /var/lib/cassandra

4./etc/cassandra/cassandra.yamlの修正
sed -i "s/cluster_name: 'Test Cluster'/cluster_name: 'Contrail'/g" /etc/cassandra/cassandra.yaml
sed -i "s/- seeds: \"127.0.0.1\"/- seeds: \"$host2,$host3\"/g" /etc/cassandra/cassandra.yaml
sed -i "s/listen_address: localhost/listen_address: $HOST/g" /etc/cassandra/cassandra.yaml
sed -i "s/rpc_address: localhost/rpc_address: $HOST/g" /etc/cassandra/cassandra.yaml

5./etc/cassandra/cassandra-env.shの修正
sed -i 's/JVM_OPTS="$JVM_OPTS -Xss256k"/JVM_OPTS="$JVM_OPTS -Xss512k"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"/JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=30"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"/JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"/JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"/JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"/JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"/JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"/JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"/JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"/g' /etc/cassandra/cassandra-env.sh
sed -i 's/# JVM_OPTS="$JVM_OPTS -Xloggc:\/var\/log\/cassandra\/gc-`date +%s`.log"/JVM_OPTS="$JVM_OPTS -Xloggc:\/var\/log\/cassandra\/gc-`date +%s`.log"/g' /etc/cassandra/cassandra-env.sh

6./etc/zookeeper/conf/zoo.cfgの修正
echo "maxSessionTimeout=120000" >> /etc/zookeeper/conf/zoo.cfg
echo "autopurge.purgeInterval=3" >> /etc/zookeeper/conf/zoo.cfg
echo "server.1=$host1:2888:3888" >> /etc/zookeeper/conf/zoo.cfg
echo "server.2=$hos2:2888:3888" >> /etc/zookeeper/conf/zoo.cfg
echo "server.3=$host3:2888:3888" >> /etc/zookeeper/conf/zoo.cfg 

7./etc/zookeeper/conf/log4j.propertiesの修正
sed -i 's/^#log4j.appender.ROLLINGFILE.MaxBackupIndex=/log4j.appender.ROLLINGFILE.MaxBackupIndex=/g' /etc/zookeeper/conf/log4j.properties 

8./etc/zookeeper/conf/environmentの修正
echo ZOO_LOG4J_PROP="INFO,CONSOLE,ROLLINGFILE" >> /etc/zookeeper/conf/environment

9./var/lib/zookeeper/myidの修正
echo $ID > /var/lib/zookeeper/myid

10./usr/share/kafka/config/server.propertiesの修正
sed -i "s/broker.id=0/broker.id=$ID/g" /usr/share/kafka/config/server.properties
sed -i 's/listeners=PLAINTEXT:\/\/:9092/#listeners=PLAINTEXT:\/\/:9092/g' /usr/share/kafka/config/server.properties
sed -i 's/#port=9092/port=9092/g' /usr/share/kafka/config/server.properties
sed -i "s/#advertised.host.name=/advertised.host.name=$HOST/g" /usr/share/kafka/config/server.properties
sed -i "s/zookeeper.connect=localhost:2181/zookeeper.connect=$host1:2181,$host2:2181,$host3:2181/g" /usr/share/kafka/config/server.properties

echo "log.cleanup.policy=compact" >> /usr/share/kafka/config/server.properties
echo "delete.topic.enable=true" >> /usr/share/kafka/config/server.properties

11./usr/share/kafka/config/log4j.propertiesの修正
sed -i 's/DailyRollingFileAppender/RollingFileAppender/g' /usr/share/kafka/config/log4j.properties
sed -i "s/DatePattern='.'yyyy-MM-dd-HH/MaxBackupIndex=10/g" /usr/share/kafka/config/log4j.properties

12./etc/contrail/contrail-database-nodemgr.confの修正
sed -i "s/hostip=127.0.0.1/hostip=$HOST/g" /etc/contrail/contrail-database-nodemgr.conf
sed -i "s/server=127.0.0.1/server=$IVIP/g" /etc/contrail/contrail-database-nodemgr.conf
sed -i 's/minimum_diskGB=4/minimum_diskGB=100/g' /etc/contrail/contrail-database-nodemgr.conf

ln -s /bin/true /sbin/chkconfig
database-server-setup.sh $HOST
13.zookeeperの確認
全てのノードで"/usr/share/zookeeper/bin/zkServer.sh status"を実行し、1台がLeaderで残りがfollowerであればZookeeperのクラスタは完成です。
/usr/share/zookeeper/bin/zkServer.sh status 
JMX enabled by default 
Using config: /etc/zookeeper/conf/zoo.cfg 
Mode: follower 
14.cassandraの確認
nodetool statusを実行し、3台のサーバが確認できればCassandraのクラスタは完成です。
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address       Load       Tokens  Owns    Host ID                               Rack
UN  10.84.50.132  2.83 GB    256     ?       4022583f-bfeb-41af-a877-878468ef379a  rack1
UN  10.84.50.133  2.68 GB    256     ?       4a7a351a-9e62-4388-9c45-b66c37a4efe2  rack1
UN  10.84.50.131  2.66 GB    256     ?       ed68231d-edc0-40df-9987-411de522888a  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless

次はContrail Support Serviceの設定です。

Contrail R3.0のマニュアルインストール ubuntu編(3)

ContrailのHA設定 

ここではHAで使用するhaproxyとkeepalivedを設定します。外部ロードバランサを使用する場合は設定不要です。外部ロードバランサを適切に設定してください。
**対象サーバ Contrail1-3

1.変数の設定
インストールを楽に進めるため、IPアドレスや物理NIC情報を変数登録します。
実際のサーバのIPアドレスや物理NIC名に変更してください。
HOST=10.84.50.131  ## インストール対象サーバのIPアドレスを指定
IVIP=10.84.50.139  ## Control/Dataの仮想IPアドレスを指定
IVIP_name=10_84_50_139  ## keepalivedのControl/Data用VIP用識別子IDEV=eth0  ## Control/Data用に使用する物理NIC名
EVIP_name=172_27_115_159  ## keepalivedのManagement用VIP用識別子
EVIP=172.27.115.159  ## Managementの仮想IPアドレスを指定
EDEV=eth1  ## Management用に使用する物理NIC名
PRIORITY=100  ## KeepalivedのPriority。各サーバで0-255間で一意の数字を指定。もっとも大きいPirorityのサーバがMasterサーバに昇格
host1=10.84.50.131  ## Contrail1のControl/Data用物理IPアドレス
host2=10.84.50.132  ## Contrail2のControl/Data用物理IPアドレス
host3=10.84.50.133  ## Contrail3のControl/Data用物理IPアドレス

2.パッケージのインストール
apt-get install -y contrail-openstack-config

3.haproxyの設定
IPアドレス冗長が必要な、Neutron, RabbitMQ, Contrail API, Discovery Server, Analytics API向けの設定を行います。

外向け、内向けポートの内訳は以下です。(外向け/内向け)
Neutron
9696 / 9697
RabbitMQ
5673 / 5672
Contrail API
8082 / 9100
Discovery server
5998 / 9110
AnalyticsAPI
8081 / 9081

**Contrailの冗長構成についてはJuniperのドキュメントを参考にしてください。

設定は以下をコピペしてください。
sed -i -e '1a\ \ \ \ \ \ \ \ tune.bufsize 16384' /etc/haproxy/haproxy.cfg
sed -i -e '1a\ \ \ \ \ \ \ \ tune.maxrewrite 1024' /etc/haproxy/haproxy.cfg

echo '
listen contrail-config-stats :5937
   mode http
   stats enable
   stats uri /
   stats auth haproxy:contrail123

' >> /etc/haproxy/haproxy.cfg

echo "
##contrail-collector-marker-start
frontend  contrail-analytics-api *:8081
    default_backend    contrail-analytics-api

backend contrail-analytics-api
    option nolinger
    balance     roundrobin
    option tcp-check
    tcp-check connect port 6379
    default-server error-limit 1 on-error mark-down
    server $host1 $host1:9081 check inter 2000 rise 2 fall 3
    server $host2 $host2:9081 check inter 2000 rise 2 fall 3
    server $host3 $host3:9081 check inter 2000 rise 2 fall 3

#contrail-collector-marker-end


#contrail-config-marker-start

frontend  contrail-api *:8082
    default_backend    contrail-api-backend
    timeout client 3m

frontend neutron-server *:9696
    default_backend    neutron-server-backend

frontend  contrail-discovery *:5998
    default_backend    contrail-discovery-backend

backend neutron-server-backend
    option nolinger
    balance     roundrobin
    server $host1 $host1:9697 check inter 2000 rise 2 fall 3
    server $host2 $host2:9697 check inter 2000 rise 2 fall 3
    server $host3 $host3:9697 check inter 2000 rise 2 fall 3

backend contrail-api-backend
    option nolinger
    timeout server 3m
    balance     roundrobin
    server $host1 $host1:9100 check inter 2000 rise 2 fall 3
    server $host2 $host2:9100 check inter 2000 rise 2 fall 3
    server $host3 $host3:9100 check inter 2000 rise 2 fall 3

backend contrail-discovery-backend
    option nolinger
    balance     roundrobin
    server $host1 $host1:9110 check inter 2000 rise 2 fall 3
    server $host2 $host2:9110 check inter 2000 rise 2 fall 3
    server $host3 $host3:9110 check inter 2000 rise 2 fall 3

listen  rabbitmq 0.0.0.0:5673
    mode tcp
    maxconn 10000
    balance leastconn
    option tcpka
    option nolinger
    option forceclose
    timeout client 0
    timeout server 0
    timeout client-fin 60s
    timeout server-fin 60s
    server rabbit1 $host1:5672 weight 200 check inter 2000 rise 2 fall 3
    server rabbit2 $host2:5672 weight 100 check inter 2000 rise 2 fall 3 backup
    server rabbit3 $host3:5672 weight 100 check inter 2000 rise 2 fall 3 backup

#contrail-config-marker-end" >> /etc/haproxy/haproxy.cfg

4.keepalivedの設定
設定は以下をコピペしてください。ManagementrとControl/Dataを1つのNICで共有する場合はEXTERNALの設定は削除してください。
echo "
vrrp_script chk_haproxy_INTERNAL_$IVIP_NAME {
        script \"pgrep -x haproxy > /dev/null\" # verify if pid exists
        interval 1
        timeout 3
        rise 2
        fall 2
}

vrrp_script chk_ctrldatanet_INTERNAL_$IVIP_NAME {
    script \"/opt/contrail/bin/chk_ctrldata.sh\"
    interval 1
    timeout 3
    rise 1
    fall 1
}

vrrp_instance INTERNAL_$IVIP_NAME {
        interface $IDEV
        state MASTER
        preempt_delay 7
        garp_master_delay 5
        garp_master_repeat 3
        garp_master_refresh 1
        advert_int 1
        virtual_router_id 100
        vmac_xmit_base
        priority  $PRIORITY
        virtual_ipaddress {
                $IVIP/24 dev $IDEV
        }
        track_script  {
                chk_haproxy_INTERNAL_$IVIP_NAME
        }

        track_script  {
            chk_ctrldatanet_INTERNAL_$IVIP_NAME
        }
        track_interface {
            $IDEV
        }
}

vrrp_script chk_haproxy_EXTERNAL_$EVIP_NAME {
        script \"pgrep -x haproxy > /dev/null\" # verify if pid exists
        interval 1
        timeout 3
        rise 2
        fall 2
}

vrrp_script chk_ctrldatanet_EXTERNAL_$EVIP_NAME {
    script \"/opt/contrail/bin/chk_ctrldata.sh\"
    interval 1
    timeout 3
    rise 1
    fall 1
}

vrrp_instance EXTERNAL_$EVIP_NAME {
        interface $EDEV
        state MASTER
        preempt_delay 7
        garp_master_delay 5
        garp_master_repeat 3
        garp_master_refresh 1
        advert_int 1
        virtual_router_id 100
        vmac_xmit_base
        priority  $PRIORITY
        virtual_ipaddress {
                $EVIP/24 dev $EDEV
        }
        track_script  {
                chk_haproxy_EXTERNAL_$EVIP_NAME
        }

        track_script  {
            chk_ctrldatanet_EXTERNAL_$EVIP_NAME
        }
        track_interface {
            $IDEV
            $EDEV
        }
}" > /etc/keepalived/keepalived.conf

5.プロセスのリスタート
haproxyとkeepalivedの設定を反映します。
service keepalived restart
service haproxy restart

次は、Database nodeの設定です。

Contrai R3.0lのマニュアルインストール ubuntu編(2)

Contrailのリポジトリ作成と共通コンフィグの設定 

Contrail用のaptリポジトリの作成と、Linuxの共通コンフィグの設定を行います。
この項目は各物理サーバで共通です。全ての物理サーバで行ってください。
**対象サーバ Contrail1-3, Compute1

1.パッケージのインストール
contrail-install-packages_3.0.0.0-2725~ubuntu-14-04kilo_all.deb を/tmpなどに保存し、dpkgでdebファイルをインストールします。
dpkg -i contrail-install-packages_3.0.0.0-2725~ubuntu-14-04kilo_all.deb

2.Contrailパッケージを解凍します
mkdir -p /opt/contrail/contrail_install_repo
cd /opt/contrail/contrail_install_repo
tar zxvf /opt/contrail/contrail_packages/contrail_debs.tgz

3./opt/contrail/binにContrailのシェルスクリプトを配置します
mkdir -p /opt/contrail/bin
cd /opt/contrail/contrail_install_repo
dpkg -i binutils_*.deb make_*.deb libdpkg-perl_*.deb dpkg-dev_*.deb patch_*.deb

4.aptリポジトリをローカルパッケージのみ参照するように変更
sed -e '1ideb file:\/opt\/contrail\/contrail_install_repo \.\/' -i /etc/apt/sources.list

5.認証されていないパッケージのインストールを許可
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf

6./opt/contralから /etc/apt/apt.confへローカルリポジトリをインストールし、パッケージ化
cp /opt/contrail/contrail_packages/preferences /etc/apt/preferences
cd /opt/contrail/contrail_install_repo
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

7.Contrailセットアップパッケージをインストール
apt-get -y update
apt-get -y install contrail-setup

8.Linux Kernelの変更(option)
**Juniperの推奨Kernelに合わせる場合はこの項目を実行してください。
Kernelが違ってもインストールは可能です。
apt-get -y install linux-headers-3.13.0-40 linux-image-extra-3.13.0-40-generic

9.GRUBの修正(option)
**Juniperの推奨Kernelに合わせる場合はこの項目を実行してください。
sed -i "s/GRUB_DEFAULT=0/GRUB_DEFAULT='Advanced options for Ubuntu\>Ubuntu\,\ with Linux 3.13.0-40-generic'/g" /etc/default/grub
update-grub
reboot

10.Linuxの共通コンフィグ
sysctl net.ipv4.ip_forward=1
sysctl kernel.core_pattern=/var/crashes/core.%e.%p.%h.%t
sysctl fs.file-max=65535
sysctl -p
mkdir -m 0777 -p /var/crashes

echo 'fs.file-max = 65535' >> /etc/sysctl.conf
echo 'kernel.core_pattern = /var/crashes/core.%e.%p.%h.%t' >> /etc/sysctl.conf

11.SE Linuxの無効化(option)
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

12./etc/hostsの設定
/etc/hostsに以下を追加 ホスト名 + "-ctrl"はRabbitMQで使用します。
127.0.0.1       localhost
10.84.50.131    contrail1 contrail1-ctrl
10.84.50.132    contrail2 contrail2-ctrl
10.84.50.133    contrail3 contrail3-ctrl
10.84.50.134    controller
10.84.50.135    compute1

13.ntpのインストール
apt-get -y install ntp
ntpq -p で同期を確認してください。

次は、Contrail用のHA設定です。

Contrail R3.0のマニュアルインストール ubuntu編(1)

Contrailのインストール方法はFabricを使う方法と、Contrail Server Managerでインストールする方法がありますが、マニュアルでもインストールができます。 AnsibleやChefなど、自分で使いたい構成管理ツールを使う場合、マニュアルでインストールする方法を理解することで、構成管理ツールに組みこくことができます。

今回は、ContrailのHA構成でインストールします。インストール手順は以下のとおりです。
  1. Contrailのリポジトリ作成と共通コンフィグの設定
  2. HAモジュールのインストール
  3. Contrail Database Nodeのインストール
  4. Contrail Support Serviceのインストール
  5. Contrail Config Nodeのインストール
  6. Contrail Control Nodeのインストール
  7. Contrail Analytics Nodeのインストール
  8. Contrail WebUIのインストール
  9. 初期コンフィグの設定
  10. Compute Nodeのインストール
  11. 動作確認
数は多いですが、ほとんどコピペで 設定できるように構成しています。

Contrailインストールの前提条件 
  • Contrail のバージョンはjuniper.netで配布されている、3.0を使用します。 
  • Contrailをインストールする前に、Neutron以外のOpenstackコンポーネントはインストールしてください。
  • Ubuntuは14.04.2を使用します。IPアドレスやデフォルトゲートウェイなどの基本設定は行ってください。
以下の物理構成でインストールします。
ManagementはSSHなどの管理用で、Control/DataはContrailのコントロールトラフィックや実際のユーザーデータで使用します。


各NodeのIPアドレスとホスト名
Contrail
10.84.50.131    contrail1
10.84.50.132    contrail2
10.84.50.133    contrail3
Openstack
10.84.50.134    openstack
Compute
10.84.50.135    compute1
HAのVIP
172.27.115.159
10.84.50.139

ユーザーIDとパスワード
Neutron
neutron / password
Openstack Admin
admin / password

Openstackにインストールされているコンポーネント
Keysotne
Nova
Cinder
Glance
Horizon

次は、Contrail用のリポジトリの作成と、共通設定項目です。

2016年3月17日木曜日

contrail_sandeshlibs.pyの使いかた

vRouter-agentのintrospectで、virutal-networkを見る場合、 http://<compute-node>:8085/Snh_VnListReq?name= でXMLを確認できます。
ただ、生のintrospectデータはXMLのため、ブラウザでは見えないタグなどがついていてpythonでは扱いにくいです。
contrail_sandeshlibs.py はintrospectのXMLデータをpythonのdict/list形式に変換するプログラムです。
contrail_sandeshlibs.pyはxmlの'@type'のTypeが'sandesh', 'struct', 'i64', 'i32', 'i16', 'u64', 'u32', 'u16', 'double', 'string', 'bool'の場合、Pythonの辞書キーをセットします。
もし、タイプがlistの場合、共通の辞書キーの中にリストを格納します。
contrail_sandeshlibs.py はsandeshのテーブル名から多数のdef定義してあります。
例えば、def get_vn_list(self, name='') はVnListRespから命名されています。
それぞれのdefはコメントを参照してください。

注意: 幾つかのdefは大量のデータを返します。特にifmap系のデータは大量です。事故を防ぐため、幾つかのifmapのdefはフラグを立てないと全てのデータを取ることはできません。全てを取得したい場合、ifmap_dump=Trueを引数にセットしてください。

** vrouter introspect のドキュメントはこちら
** bumtreedisp.pytor_tsn_compare.pyはこのライブラリを使っています。

使い方

1) librariesのインストール
sys
copy
xmltodict
urllib2
** contrail_sandeshlibs.py は以下のライブラリを使っています。xmltodictは標準ライブラリではないですが、Contrailが使っているライブラリです

2) contrail_sandeshlibs のインポート
3) ホスト名とポートのセット. デフォルト値 hostname=127.0.0.1 port=8085
   ポート番号はデーモン毎に異なります。こちらを参照してください。 RolesDaemaonPorts.
4) オブジェクトの作成
5) インスタンスの実行。引数をつけることが可能です。

### Sample code
from contrail_sandeshlibs import *

hostname='172.27.113.207'
port='8085'

a = GetContrailSandesh(hostname=hostname,port=port)
py_dict = a.get_vn_list(name='default-domain:test-project1:VRRPvn1')
return py_dict
### Example:Result
{u'VnListResp': {u'vn_list': {u'vxlan_id': u'7833', u'bridging': u'true', u'name': u'default-domain:test-project1:VRRPvn1', u'admin_state': u'true', u'mirror_acl_uuid': '', u'acl_uuid': '', u'config_vxlan_id': u'0', u'enable_rpf': u'true', u'ipv4_forwarding': u'true', u'flood_unknown_unicast': u'false', u'vrf_name': u'default-domain:test-project1:VRRPvn1:VRRPvn1', u'layer2_forwarding': u'true', u'ipam_host_routes': {u'ipam_name': u'default-domain:default-project:default-network-ipam', u'host_routes': ''}, u'mirror_cfg_acl_uuid': '', u'ipam_data': {u'dns_server': u'10.0.0.2', u'dhcp_enable': u'true', u'ipam_name': u'default-domain:default-project:default-network-ipam', u'ip_prefix': u'10.0.0.0', u'prefix_len': u'24', u'gateway': u'10.0.0.1'}, u'vn_id': u'7833', u'uuid': u'bf34d68a-1eb7-4722-ac78-d7d6104de250'}}}
### Example:Raw XML これは元データです。これが上のようなdictに変換されます
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/universal_parse.xsl"?>
<__VnListResp_list type="slist">
  <VnListResp type="sandesh">
    <vn_list type="list" identifier="1">
      <list type="struct" size="1">
        <VnSandeshData>
          <name type="string" identifier="1">default-domain:test-project1:VRRPvn1</name>
          <uuid type="string" identifier="2">bf34d68a-1eb7-4722-ac78-d7d6104de250</uuid>
          <acl_uuid type="string" identifier="3" link="AclReq"/>
          <mirror_acl_uuid type="string" identifier="4" link="AclReq"/>
          <mirror_cfg_acl_uuid type="string" identifier="5" link="AclReq"/>
          <vrf_name type="string" identifier="6" link="VrfListReq">default-domain:test-project1:VRRPvn1:VRRPvn1</vrf_name>
          <ipam_data type="list" identifier="7">
            <list type="struct" size="1">
              <VnIpamData>
                <ip_prefix type="string" identifier="1">10.0.0.0</ip_prefix>
                <prefix_len type="i32" identifier="2">24</prefix_len>
                <gateway type="string" identifier="3">10.0.0.1</gateway>
                <ipam_name type="string" identifier="4">default-domain:default-project:default-network-ipam</ipam_name>
                <dhcp_enable type="string" identifier="5">true</dhcp_enable>
                <dns_server type="string" identifier="6">10.0.0.2</dns_server>
              </VnIpamData>
            </list>
          </ipam_data>
          <ipam_host_routes type="list" identifier="8">
            <list type="struct" size="1">
              <VnIpamHostRoutes>
                <ipam_name type="string" identifier="1">default-domain:default-project:default-network-ipam</ipam_name>
                <host_routes type="list" identifier="2">
                  <list type="string" size="0"/>
                </host_routes>
              </VnIpamHostRoutes>
            </list>
          </ipam_host_routes>
          <layer2_forwarding type="bool" identifier="9">true</layer2_forwarding>
          <ipv4_forwarding type="bool" identifier="10">true</ipv4_forwarding>
          <admin_state type="bool" identifier="11">true</admin_state>
          <vxlan_id type="i32" identifier="12">7833</vxlan_id>
          <config_vxlan_id type="i32" identifier="13">0</config_vxlan_id>
          <vn_id type="i32" identifier="14">7833</vn_id>
          <enable_rpf type="bool" identifier="15">true</enable_rpf>
          <bridging type="bool" identifier="16">true</bridging>
          <flood_unknown_unicast type="bool" identifier="17">false</flood_unknown_unicast>
        </VnSandeshData>
      </list>
    </vn_list>
    <more type="bool" identifier="0">true</more>
  </VnListResp>
  <Pagination type="sandesh">
    <req type="struct" identifier="1">
      <PageReqData>
        <prev_page type="string" identifier="1" link="PageReq"/>
        <next_page type="string" identifier="2" link="PageReq"/>
        <first_page type="string" identifier="3" link="PageReq">begin:0,end:99,table:db.vn.0,name:default-domain:test-project1:VRRPvn1</first_page>
        <all type="string" identifier="4" link="PageReq">begin:-1,end:-1,table:db.vn.0,name:default-domain:test-project1:VRRPvn1</all>
        <table_size type="u32" identifier="5">2</table_size>
        <entries type="string" identifier="6">0-0/1</entries>
      </PageReqData>
    </req>
    <more type="bool" identifier="0">false</more>
  </Pagination>
</__VnListResp_list>