Restore zookeeper to devstack

openstack/devstack-dev has removed zookeeper support.
For details see [1].
Following commits brings back zookeper as it was
previously installed from devstack.

Extra:
* added concepts of devstack dependencies. That speeds
up installation a bit as common packages are installed
prior to the plugin code

Ref:
[1] c0d16c279a

Change-Id: I0323eacb5cbba8418550e3322189104c35cf4c36
This commit is contained in:
Tomasz Trębski 2017-05-26 10:48:14 +02:00
parent 03b5f34c99
commit bfcd3eeece
9 changed files with 264 additions and 101 deletions

View File

@ -122,7 +122,7 @@ LOG_COLOR=False
DEST=/opt/stack
disable_all_services
enable_service zookeeper rabbit key tempest horizon
enable_service rabbit key tempest horizon
# Uncomment one of the following lines to use either MySQL or PostgreSQL
# as RDB (relational database) backend for monasca.

View File

@ -0,0 +1,6 @@
openjdk-8-jdk # dist:xenial
maven # dist:xenial
jq # dist:xenial
python-dev # dist:xenial
build-essential # dist:xenial
mailutils # dist:xenial

View File

@ -0,0 +1,36 @@
#
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Modified from http://packages.ubuntu.com/saucy/zookeeperd
NAME=zookeeper
ZOOCFGDIR=/etc/zookeeper/conf
# seems, that log4j requires the log4j.properties file to be in the classpath
CLASSPATH="$ZOOCFGDIR:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar"
ZOOCFG="$ZOOCFGDIR/zoo.cfg"
ZOO_LOG_DIR=/var/log/zookeeper
USER=$NAME
GROUP=$NAME
PIDDIR=/var/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
JAVA=/usr/bin/java
ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
JMXLOCALONLY=false
JAVA_OPTS=""

View File

@ -0,0 +1,69 @@
#
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# From http://packages.ubuntu.com/saucy/zookeeperd
# ZooKeeper Logging Configuration
#
# Format is "<default threshold> (, <appender>)+
log4j.rootLogger=${zookeeper.root.logger}
# Example: console appender only
# log4j.rootLogger=INFO, CONSOLE
# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
#
# Log INFO level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
#
# Add ROLLINGFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=WARN
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/zookeeper.log
# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize=10MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex=10
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
#
# Add TRACEFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.log.dir}/zookeeper_trace.log
log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,74 @@
#
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper
# Place the dataLogDir to a separate physical disc for better performance
# dataLogDir=/disk2/zookeeper
# the port at which the clients will connect
clientPort=2181
# Maximum number of clients that can connect from one client
maxClientCnxns=60
# specify all zookeeper servers
# The fist port is used by followers to connect to the leader
# The second one is used for leader election
server.0=127.0.0.1:2888:3888
# To avoid seeks ZooKeeper allocates space in the transaction log file in
# blocks of preAllocSize kilobytes. The default block size is 64M. One reason
# for changing the size of the blocks is to reduce the block size if snapshots
# are taken more often. (Also, see snapCount).
#preAllocSize=65536
# Clients can submit requests faster than ZooKeeper can process them,
# especially if there are a lot of clients. To prevent ZooKeeper from running
# out of memory due to queued requests, ZooKeeper will throttle clients so that
# there is no more than globalOutstandingLimit outstanding requests in the
# system. The default limit is 1,000.ZooKeeper logs transactions to a
# transaction log. After snapCount transactions are written to a log file a
# snapshot is started and a new transaction log file is started. The default
# snapCount is 10,000.
#snapCount=1000
# If this option is defined, requests will be will logged to a trace file named
# traceFile.year.month.day.
#traceFile=
# Leader accepts client connections. Default value is "yes". The leader machine
# coordinates updates. For higher update throughput at thes slight expense of
# read throughput the leader can be configured to not accept clients and focus
# on coordination.
#leaderServes=yes
# Autopurge every hour to avoid using lots of disk in bursts
# Order of the next 2 properties matters.
# autopurge.snapRetainCount must be before autopurge.purgeInterval.
autopurge.snapRetainCount=3
autopurge.purgeInterval=1

66
devstack/lib/zookeeper Normal file
View File

@ -0,0 +1,66 @@
#!/bin/bash
# Copyright 2017 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# call_order:
# - is_zookeeper_enabled
# - install_zookeeper
# - configure_zookeeper
# - clean_zookeeper
_XTRACE_ZOOKEEPER=$(set +o | grep xtrace)
set +o xtrace
# Set up default directories
ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper
ZOOKEEPER_CONF_DIR=/etc/zookeeper
function is_zookeeper_enabled {
is_service_enabled monasca-zookeeper && return 0
return 1
}
function clean_zookeeper {
sudo rm -rf $ZOOKEEPER_DATA_DIR
apt_get -y purge zookeeper
}
function configure_zookeeper {
if is_zookeeper_enabled; then
sudo cp $PLUGIN_FILES/zookeeper/* $ZOOKEEPER_CONF_DIR
sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg
sudo rm -rf $ZOOKEEPER_DATA_DIR || true
sudo mkdir -p $ZOOKEEPER_DATA_DIR || true
restart_service zookeeper
fi
}
function install_zookeeper {
if is_zookeeper_enabled; then
if is_ubuntu; then
install_package zookeeperd
else
die $LINENO "Don't know how to install zookeeper on this platform"
fi
fi
# NOTE(trebskit) it shouldn't really be done here
# but monasca devstack cannot allow it do be done properly
# we'd have to first refactor parts where services are:
# installed, configured and started in single phase
configure_zookeeper
}
$_XTRACE_ZOOKEEPER

View File

@ -44,6 +44,10 @@ set -o xtrace
ERREXIT=$(set +o | grep errexit)
set -o errexit
# source lib/*
source ${MONASCA_API_DIR}/devstack/lib/zookeeper
# source lib/*
# Set default implementations to python
export MONASCA_API_IMPLEMENTATION_LANG=${MONASCA_API_IMPLEMENTATION_LANG:-python}
export MONASCA_PERSISTER_IMPLEMENTATION_LANG=${MONASCA_PERSISTER_IMPLEMENTATION_LANG:-python}
@ -81,11 +85,9 @@ MONASCA_API_URI_V2=${MONASCA_API_BASE_URI}/v2.0
function pre_install_monasca {
echo_summary "Pre-Installing Monasca Components"
install_git
install_maven
install_openjdk_8_jdk
find_nearest_apache_mirror
install_kafka
install_zookeeper
if is_service_enabled monasca-storm; then
install_storm
@ -96,7 +98,6 @@ function pre_install_monasca {
}
function find_nearest_apache_mirror {
install_jq
apache_mirror=`curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq --raw-output '.preferred'`
}
@ -168,8 +169,6 @@ function extra_monasca {
install_monasca_agent
install_monasca_default_alarms
if is_service_enabled horizon; then
install_monasca_horizon_ui
@ -241,9 +240,6 @@ function clean_monasca {
unstack_monasca
clean_monasca_default_alarms
clean_keystone_client
if is_service_enabled horizon; then
clean_monasca_horizon_ui
@ -278,8 +274,6 @@ function clean_monasca {
clean_monasca_common
clean_maven
clean_schema
clean_cli_creds
@ -288,7 +282,7 @@ function clean_monasca {
clean_kafka
clean_openjdk_8_jdk
clean_zookeeper
clean_monasca_virtual_env
@ -707,55 +701,6 @@ function clean_schema {
}
function install_openjdk_8_jdk {
echo_summary "Install Monasca openjdk_8_jdk"
apt_get -y install openjdk-8-jdk
}
function clean_openjdk_8_jdk {
echo_summary "Clean Monasca openjdk_8_jdk"
apt_get -y purge openjdk-8-jdk
apt_get -y autoremove
}
function install_maven {
echo_summary "Install Monasca Maven"
apt_get -y remove maven2
apt_get -y install maven
}
function clean_maven {
echo_summary "Clean Monasca Maven"
apt_get -y purge maven
}
function install_git {
echo_summary "Install git"
apt_get -y install git
}
function install_jq {
echo_summary "Install jq"
apt_get -y install jq
}
function download_monasca_libraries {
echo_summary "Download Monasca monasca_common and monasca_statsd"
@ -866,8 +811,6 @@ function install_monasca_api_python {
echo_summary "Install Monasca monasca_api_python"
apt_get -y install python-dev
sudo mkdir -p /opt/monasca-api
sudo chown $STACK_USER:monasca /opt/monasca-api
@ -1032,7 +975,6 @@ function clean_monasca_api_python {
if is_service_enabled postgresql; then
apt_get -y purge libpq-dev
elif is_service_enabled mysql; then
apt_get -y purge libpq-dev
apt_get -y purge libmysqlclient-dev
fi
@ -1261,9 +1203,6 @@ function install_monasca_notification {
echo_summary "Install Monasca monasca_notification"
apt_get -y install python-dev
apt_get -y install build-essential
git_clone $MONASCA_NOTIFICATION_REPO $MONASCA_NOTIFICATION_DIR $MONASCA_NOTIFICATION_BRANCH
PIP_VIRTUAL_ENV=/opt/monasca
@ -1272,8 +1211,7 @@ function install_monasca_notification {
apt_get -y install libpq-dev
pip_install_gr psycopg2
elif is_service_enabled mysql; then
apt_get -y install python-mysqldb
apt_get -y install libmysqlclient-dev
apt_get -y install python-mysqldb libmysqlclient-dev
pip_install_gr PyMySQL
pip_install_gr mysql-python
fi
@ -1348,8 +1286,6 @@ function install_monasca_notification {
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local only'"
apt_get -y install mailutils
}
function clean_monasca_notification {
@ -1370,10 +1306,6 @@ function clean_monasca_notification {
sudo rm /var/log/upstart/monasca-notification.log*
apt_get -y purge build-essential
apt_get -y purge python-dev
apt_get -y purge mailutils
if is_service_enabled postgresql; then
apt_get -y purge libpq-dev
elif is_service_enabled mysql; then
@ -1607,8 +1539,6 @@ function create_metric_accounts {
}
function install_keystone_client {
apt_get -y install python-dev
PIP_VIRTUAL_ENV=/opt/monasca
pip_install_gr python-keystoneclient
@ -1617,19 +1547,11 @@ function install_keystone_client {
unset PIP_VIRTUAL_ENV
}
function clean_keystone_client {
apt_get -y purge python-dev
}
function install_monasca_agent {
echo_summary "Install Monasca monasca_agent"
apt_get -y install python-dev
apt_get -y install python-yaml
apt_get -y install build-essential
apt_get -y install libxml2-dev
apt_get -y install libxslt1-dev
apt_get -y install python-yaml libxml2-dev libxslt1-dev
# clients needs to be downloaded without git_clone wrapper
# because of the GIT_DEPTH flag that affects python package version
@ -1720,19 +1642,7 @@ function clean_monasca_agent {
apt_get -y purge libxslt1-dev
apt_get -y purge libxml2-dev
apt_get -y purge build-essential
apt_get -y purge python-yaml
apt_get -y purge python-dev
}
function install_monasca_default_alarms {
:
}
function clean_monasca_default_alarms {
:
}

View File

@ -44,7 +44,7 @@ enable_service monasca
#
# devstack zookeeper
enable_service zookeeper
enable_service monasca-zookeeper
# Monasca databases
# MySQL is already enabled in devstack
@ -53,7 +53,7 @@ enable_service monasca-influxdb
# Apache Storm
enable_service monasca-storm
# monasca-kafka depends on devstack-dlm-zookeeper
# monasca-kafka depends on monasca-zookeeper
enable_service monasca-kafka
#
@ -161,6 +161,7 @@ MONASCA_DATABASE_USE_ORM=false
# Other settings
DOWNLOAD_FILE_TIMEOUT=${DOWNLOAD_FILE_TIMEOUT:-30}
PLUGIN_FILES=$MONASCA_API_DIR/devstack/files
# Public configuration
## monasca-statsd