2016年4月19日火曜日

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の設定です。

0 件のコメント:

コメントを投稿