Add Redis Devstack

Change-Id: Ie100d3ae236a510dbc05fc7f12f224362a05ad29
This commit is contained in:
feipeng 2016-03-26 12:58:36 +08:00
parent e0e8993458
commit e0ab03ee14
6 changed files with 275 additions and 0 deletions

View File

@ -12,6 +12,7 @@ DEFAULT_NB_DRIVER_CLASS="dragonflow.db.drivers.etcd_db_driver.EtcdDbDriver"
DEFAULT_TUNNEL_TYPE="geneve"
DEFAULT_APPS_LIST="l2_app.L2App,l3_proactive_app.L3ProactiveApp,dhcp_app.DHCPApp"
DEFAULT_SELECTIVE_TOPO_DIST="False"
DEFAULT_DF_REDIS_PUBSUB="False"
# How to connect to the database storing the virtual topology.
REMOTE_DB_IP=${REMOTE_DB_IP:-$HOST_IP}
@ -21,6 +22,7 @@ NB_DRIVER_CLASS=${NB_DRIVER_CLASS:-$DEFAULT_NB_DRIVER_CLASS}
TUNNEL_TYPE=${TUNNEL_TYPE:-$DEFAULT_TUNNEL_TYPE}
DF_APPS_LIST=${DF_APPS_LIST:-$DEFAULT_APPS_LIST}
DF_SELECTIVE_TOPO_DIST=${DF_SELECTIVE_TOPO_DIST:-$DEFAULT_SELECTIVE_TOPO_DIST}
DF_REDIS_PUBSUB=${DF_REDIS_PUBSUB:-$DEFAULT_DF_REDIS_PUBSUB}
#pubsub
PUBLISHERS_HOSTS=${PUBLISHERS_HOSTS:-"$SERVICE_HOST"}
@ -46,6 +48,10 @@ if is_service_enabled df-zookeeper ; then
source $DEST/dragonflow/devstack/zookeeper_driver
NB_DRIVER_CLASS="dragonflow.db.drivers.zookeeper_db_driver.ZookeeperDbDriver"
fi
if is_service_enabled df-redis ; then
source $DEST/dragonflow/devstack/redis_driver
NB_DRIVER_CLASS="dragonflow.db.drivers.redis_db_driver.RedisDbDriver"
fi
# Pub/Sub Service
#----------------
@ -60,6 +66,10 @@ if is_service_enabled df-zmq-publisher-service ; then
source $DEST/dragonflow/devstack/zmq_pubsub_driver
fi
if [[ "$DF_REDIS_PUBSUB" == "True" ]]; then
init_pubsub
source $DEST/dragonflow/devstack/redis_pubsub_driver
fi
# Dragonflow installation uses functions from these files
source $TOP_DIR/lib/neutron_plugins/ovs_base
source $TOP_DIR/lib/neutron_plugins/openvswitch_agent

148
devstack/redis_driver Normal file
View File

@ -0,0 +1,148 @@
#!/bin/bash
#
#
# ``plugin.sh`` calls the following methods in the sourced driver:
#
# - nb_db_driver_install_server
# - nb_db_driver_install_client
# - nb_db_driver_start_server
# - nb_db_driver_stop_server
# - nb_db_driver_clean
REDIS_VERSION=3.0.6
RUBY_VERSION=2.3
REDIS_SERVER_LIST=$REMOTE_DB_IP
REMOTE_PORT_START=$REMOTE_DB_PORT
NODE_COUNT_END=5
REMOTE_PORT_END=`expr $REMOTE_PORT_START + $NODE_COUNT_END`
REDIS_PORT=`seq $REMOTE_PORT_START $REMOTE_PORT_END`
function configure_redis {
pushd /opt/redis3/conf
sudo sh -c "echo ulimit -SHn 40960 >> /etc/profile"
sudo sh -c "echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse"
sudo sh -c "echo never > /sys/kernel/mm/transparent_hugepage/enabled"
sudo sh -c "echo 2048 > /proc/sys/net/core/somaxconn"
sudo sh -c "echo vm.overcommit_memory = 1 >> /etc/sysctl.conf"
sudo sh -c "sysctl -p"
for redisserver in $REDIS_SERVER_LIST; do
for port in $REDIS_PORT; do
echo "shutdown redis: "$redisserver:$port
sudo cp redis.conf redis-$port.conf
sudo sed -i "s/6379/$port/g" redis-$port.conf
sudo sed -i "s/dump.rdb/dump-$port.rdb/g" redis-$port.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/g" redis-$port.conf
sudo sed -i "s/# cluster-config-file/cluster-config-file/g" redis-$port.conf
sudo sed -i "s/pubsub 32mb 8mb 60/pubsub 0 0 0/g" redis-$port.conf
done
done
popd
}
function nb_db_driver_install_server {
if is_service_enabled df-redis-server ; then
echo "Installing rediscluster"
if [ ! -f "$DEST/redis/redis-$REDIS_VERSION/redis" ]; then
mkdir -p $DEST/redis
if [ ! -f "$DEST/redis/redis-$REDIS_VERSION.tar.gz" ]; then
wget http://download.redis.io/releases/redis-$REDIS_VERSION.tar.gz -O $DEST/redis/redis-$REDIS_VERSION.tar.gz
fi
tar xzvf $DEST/redis/redis-$REDIS_VERSION.tar.gz -C $DEST/redis
pushd $DEST/redis/redis-$REDIS_VERSION
make
cd src
sudo make PREFIX=/opt/redis3 install
sudo mkdir -p /opt/redis3/conf
sudo cp $DEST/redis/redis-$REDIS_VERSION/redis.conf /opt/redis3/conf
sudo ln -sf /opt/redis3/conf /etc/redis3
sudo cp $DEST/redis/redis-$REDIS_VERSION/src/redis-trib.rb /opt/redis3/bin/
if is_ubuntu || is_fedora; then
configure_redis
fi
sudo pip install crc16
mkdir -p $DEST/ruby
if [ ! -f "$DEST/ruby/ruby-$RUBY_VERSION.0.tar.gz" ]; then
wget https://cache.ruby-lang.org/pub/ruby/$RUBY_VERSION/ruby-$RUBY_VERSION.0.tar.gz -O $DEST/ruby/ruby-$RUBY_VERSION.0.tar.gz
fi
tar xzvf $DEST/ruby/ruby-$RUBY_VERSION.0.tar.gz -C $DEST/ruby
cd $DEST/ruby/ruby-$RUBY_VERSION.0
sudo ./configure
sudo make
sudo make install
#apt-get install ruby
gem list redis | grep redis
if [ $? -ne 0 ];then
sudo gem source -a https://rubygems.org/
sudo gem install redis
fi
popd
fi
fi
}
function nb_db_driver_install_client {
sudo pip install redis
}
function nb_db_driver_status_server
{
TEMP_PIDS=`ps cax | grep redis`
if [ -z "$TEMP_PIDS" ]; then
return 1
fi
return 0
}
function nb_db_driver_start_server {
create=
if is_service_enabled df-redis-server ; then
if is_ubuntu || is_fedora; then
#to acquire if should recreate cluster
for redisserver in $REDIS_SERVER_LIST; do
for port in $REDIS_PORT; do
test -f /opt/redis3/conf/nodes-$port.conf || { create=true; break 2 ; }
done
done
#start redis
for redisserver in $REDIS_SERVER_LIST; do
for port in $REDIS_PORT; do
echo $redisserver:$port
pushd /opt/redis3/
[ "$create" ] && {
sudo rm nodes* -rf
}
sudo ./bin/redis-server ./conf/redis-$port.conf &
redis_cluster="$redis_cluster"" ""$redisserver:$port"
popd
done
done
#create cluster
[ "$create" ] && {
echo "create the cluster: "$redis_cluster
pushd /opt/redis3/bin/
echo "yes" |sudo ./redis-trib.rb create --replicas 1 $redis_cluster
popd
}
fi
fi
}
function nb_db_driver_stop_server {
if is_service_enabled df-redis-server ; then
if is_ubuntu || is_fedora; then
for redisserver in $REDIS_SERVER_LIST; do
for port in $REDIS_PORT; do
echo "shutshow redis: "$redisserver:$port
sudo /opt/redis3/bin/redis-cli -p $port shutdown
pushd /opt/redis3/
sudo rm -rf nodes*.conf
sudo rm -rf dump*.rdb
sudo netstat -apn | grep $port | awk '{print $7}' | cut -d '/' -f1 | xargs sudo kill -9
popd
done
done
fi
fi
}

View File

@ -0,0 +1,7 @@
#!/bin/bash
function configure_pubsub_service_plugin {
NEUTRON_CONF=${NEUTRON_CONF:-"/etc/neutron/neutron.conf"}
PUB_SUB_DRIVER=${PUB_SUB_DRIVER:-"redis_db_pubsub_driver"}
iniset $NEUTRON_CONF df pub_sub_driver $PUB_SUB_DRIVER
}

View File

@ -0,0 +1,48 @@
#
# Sample DevStack local.conf.
#
# This sample file is intended to be used when adding an additional compute node
# to your test environment. It runs a very minimal set of services.
#
# For this configuration to work, you *must* set the SERVICE_HOST option to the
# IP address of the main DevStack host.
#
[[local|localrc]]
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
ADMIN_PASSWORD=password
Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER=True
enable_plugin dragonflow http://git.openstack.org/openstack/dragonflow
disable_all_services
enable_service n-cpu
enable_service df-controller
enable_service df-redis
enable_service df-ext-services
enable_service n-novnc
# Set this to the address of the main DevStack host running the rest of the
# OpenStack services. (Controller node)
SERVICE_HOST=<IP address of host running everything else>
RABBIT_HOST=$SERVICE_HOST
Q_HOST=$SERVICE_HOST
REMOTE_DB_IP=$SERVICE_HOST
# Make VNC work on compute node
NOVA_VNC_ENABLED=True
NOVNCPROXY_URL=http://$SERVICE_HOST:6080/vnc_auto.html
VNCSERVER_LISTEN=$HOST_IP
VNCSERVER_PROXYCLIENT_ADDRESS=$VNCSERVER_LISTEN
[[post-config|$NEUTRON_CONF]]
[df]
enable_df_pub_sub = True
pub_sub_driver = "redis_db_pubsub_driver"

View File

@ -0,0 +1,31 @@
[[local|localrc]]
Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER=True
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
ADMIN_PASSWORD=password
DF_REDIS_PUBSUB=True
enable_plugin dragonflow http://git.openstack.org/openstack/dragonflow
enable_service df-redis
enable_service df-redis-server
enable_service df-controller
enable_service df-ext-services
disable_service n-net
enable_service q-svc
enable_service q-l3
disable_service heat
disable_service tempest
# Enable q-meta once nova is being used.
#enable_service q-meta
# We have to disable the neutron L2 agent. DF does not use the L2 agent.
disable_service q-agt
# We have to disable the neutron dhcp agent. DF does not use the dhcp agent.
disable_service q-dhcp

View File

@ -0,0 +1,31 @@
[[local|localrc]]
Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER=True
DATABASE_PASSWORD=password
RABBIT_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
ADMIN_PASSWORD=password
DF_REDIS_PUBSUB=True
enable_plugin dragonflow http://git.openstack.org/openstack/dragonflow
enable_service df-redis
enable_service df-redis-server
enable_service df-controller
enable_service df-ext-services
disable_service n-net
enable_service q-svc
enable_service q-l3
disable_service heat
disable_service tempest
# Enable q-meta once nova is being used.
#enable_service q-meta
# We have to disable the neutron L2 agent. DF does not use the L2 agent.
disable_service q-agt
# We have to disable the neutron dhcp agent. DF does not use the dhcp agent.
disable_service q-dhcp