-
-
Save congto/b46c9ceb759ceff327406d39aa7aa4a9 to your computer and use it in GitHub Desktop.
masakari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MGMT_IP=$(ifconfig br-mgmt | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}') | |
HOST=$(hostname -s) | |
ADMIN_IP=$(hiera management_vip) | |
PUB_IP=$(hiera public_vip) | |
USER='masakari' | |
PASS='masakari' | |
DIR="$(dirname `readlink -f $0`)" | |
apt-get install pacemaker-remote | |
iptables -A INPUT -p tcp -m multiport --ports 3121 -m comment --comment "pacemaker-remore" -j ACCEPT | |
apt-get install -y --force-yes git python-pip python-dev pkg-config libvirt-dev | |
pip install --upgrade pip | |
pip install virtualenv | |
virtualenv v-masakari | |
source v-masakari/bin/activate | |
git clone https://github.com/openstack/python-masakariclient | |
cd python-masakariclient | |
pip install -r requirements.txt | |
python setup.py install | |
cd $DIR | |
git clone https://github.com/openstack/masakari-monitors | |
cat > masakari-monitors/fix-req.txt <<- EOM | |
libvirt-python>=1.2.5 # LGPLv2+ | |
oslo.config>=3.10.0 # Apache-2.0 | |
oslo.i18n>=2.1.0 # Apache-2.0 | |
oslo.log>=1.14.0 # Apache-2.0 | |
oslo.middleware>=3.0.0 # Apache-2.0 | |
oslo.service>=1.10.0 # Apache-2.0 | |
oslo.utils>=3.11.0 # Apache-2.0 | |
pbr>=1.6 # Apache-2.0 | |
python-openstackclient>=3.3.0 # Apache-2.0 | |
EOM | |
cd masakari-monitors | |
pip install -r fix-req.txt | |
python setup.py install | |
mkdir -p /etc/masakari | |
cat > /etc/masakari/hostmonitor.conf <<- EOM | |
# Monitoring interval(in seconds) of node status | |
# Default : 60 | |
MONITOR_INTERVAL=60 | |
# Timeout value(in seconds) when cannot send the notice to resource management. | |
# Default : 10 | |
NOTICE_TIMEOUT=10 | |
# Retry numbers when failed to notify the resource management. | |
# Default : 12 | |
NOTICE_RETRY_COUNT=12 | |
# Retry interval(in seconds) when cannot send the notice to resource management. | |
# Default : 10 | |
NOTICE_RETRY_INTERVAL=10 | |
# Standby time(in seconds) until activate STONITH | |
# Default : 30 | |
STONITH_WAIT=30 | |
# Stonith type ( ipmi(default) / ssh(for test) ) | |
STONITH_TYPE=ssh | |
# Maximum number of child process to start | |
# Default : 3 | |
MAX_CHILD_PROCESS=3 | |
# Timeout value(in seconds) of the tcpdump command when monitor the HB line | |
# Default : 10 | |
TCPDUMP_TIMEOUT=10 | |
# Timeout value(in seconds) of the ipmitool command | |
# Default : 5 | |
IPMI_TIMEOUT=5 | |
# Number of ipmitool command retries | |
# Default : 3 | |
IPMI_RETRY_MAX=3 | |
# Retry interval(in seconds) of the ipmitool command | |
# Default : 10 | |
IPMI_RETRY_INTERVAL=10 | |
# Configuration file path of corosync | |
# Default : /etc/corosync/corosync.conf | |
HA_CONF="/etc/corosync/corosync.conf" | |
# Log level ( info / debug ) | |
# Otherwise, info is set | |
# Default : info | |
LOG_LEVEL="debug" | |
# These value of the order to get the token from the key stone | |
# DOMAIN,ADMIN_USER,ADMIN_PASS,AUTH_URL | |
# Domain name which the project belongs | |
DOMAIN="Default" | |
# The name of a user with administrative privileges | |
ADMIN_USER="admin" | |
# Administrator user's password | |
ADMIN_PASS="admin" | |
# Administrator user's project name | |
PROJECT="admin" | |
# Name of Region | |
REGION="RegionOne" | |
IGNORE_RESOURCE_GROUP_NAME_PATTERN="stonith" | |
# Address of Keystone | |
AUTH_URL="http://${ADMIN_IP}:5000/" | |
EOM | |
cat > /etc/init/masakari-hostmonitor.conf <<- EOM | |
description "Masakari Hostmonitor" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
chdir /root/ | |
script | |
. /root/v-masakari/bin/activate | |
exec /root/masakari-monitors/masakarimonitors/hostmonitor/hostmonitor.sh /etc/masakari/hostmonitor.conf | |
end script | |
EOM | |
initctl reload-configuration | |
service masakari-hostmonitor start | |
echo "Activate masakari virtual env: source /root/v-masakari/bin/activate" | |
echo "Make sure that all pacemaker nodes (cluster and remote) use the same /etc/pacemaker/authkey" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
MGMT_IP=$(ifconfig br-mgmt | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}') | |
HOST=$(hostname -s) | |
ADMIN_IP=$(hiera management_vip) | |
PUB_IP=$(hiera public_vip) | |
PORT='15868' | |
USER='masakari' | |
PASS='masakari' | |
DIR="$(dirname `readlink -f $0`)" | |
apt-get update | |
apt-get install -y --force-yes git python-pip python-dev | |
pip install --upgrade pip | |
pip install virtualenv | |
source /root/openrc | |
openstack user create --password $USER $PASS | |
openstack role add --project services --user $USER admin | |
openstack service create --name masakari --description "masakari high availability" ha | |
id=$(openstack service show masakari -f value -c id 2>/dev/null) | |
openstack endpoint create --region RegionOne $id --publicurl "http://${PUB_IP}:${PORT}/v1/%(tenant_id)s" --adminurl "http://${ADMIN_IP}:${PORT}/v1/%(tenant_id)s" --internalurl "http://${ADMIN_IP}:${PORT}/v1/%(tenant_id)s" | |
mysql --execute="CREATE DATABASE masakari; GRANT ALL PRIVILEGES ON masakari.* To '${USER}'@'%' IDENTIFIED BY '${PASS}';" | |
virtualenv v-masakari | |
source v-masakari/bin/activate | |
git clone https://github.com/openstack/masakari.git | |
cd masakari | |
pip install -r requirements.txt | |
pip install PyMySql | |
python setup.py install | |
mkdir -p /etc/masakari | |
cd etc/masakari | |
cp policy.json api-paste.ini /etc/masakari/ | |
rabbit_pass=$(hiera rabbit | sed 's/[{},=>"]/ /g' | awk '{print $2}') | |
nova_pass=$(hiera nova | grep user_password | sed 's/[",=>]/ /g' | awk '{print $2}') | |
mysql_host=$(hiera management_vip) | |
cat > /etc/masakari/masakari.conf <<- EOM | |
[DEFAULT] | |
graceful_shutdown_timeout = 5 | |
os_privileged_user_tenant = services | |
os_privileged_user_password = ${nova_pass} | |
os_privileged_user_name = nova | |
logging_exception_prefix = %(color)s%(asctime)s.%(msecs)03d TRACE %(name)s %(instance)s | |
logging_debug_format_suffix = from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d | |
logging_default_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s | |
logging_context_format_string = %(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s%(color)s] %(instance)s%(color)s%(message)s | |
use_syslog = False | |
debug = True | |
masakari_api_workers = 2 | |
[keystone_authtoken] | |
auth_uri = http://${ADMIN_IP}:5000 | |
auth_url = http://${ADMIN_IP}:35357 | |
auth_type = password | |
project_name = services | |
username = ${USER} | |
password = ${PASS} | |
project_domain_name = Default | |
user_domain_name = Default | |
[database] | |
connection = mysql+pymysql://${USER}:${PASS}@${ADMIN_IP}/masakari?charset=utf8 | |
[oslo_messaging_rabbit] | |
rabbit_hosts = ${MGMT_IP}:5673 | |
rabbit_userid = nova | |
rabbit_password = ${rabbit_pass} | |
EOM | |
iptables -A INPUT -p tcp -m multiport --ports $PORT -m comment --comment "masakari-api" -j ACCEPT | |
cat > /etc/init/masakari-api.conf <<- EOM | |
description "Masakari API" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
chdir /root/ | |
script | |
. /root/v-masakari/bin/activate | |
exec masakari-api --config-file=/etc/masakari/masakari.conf --debug | |
end script | |
EOM | |
cat > /etc/init/masakari-engine.conf <<- EOM | |
description "Masakari engine" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
chdir /root/ | |
script | |
. /root/v-masakari/bin/activate | |
exec masakari-engine --config-file=/etc/masakari/masakari.conf --debug | |
end script | |
EOM | |
cat > /etc/haproxy/conf.d/199-masakari.cfg <<- EOM | |
listen masakari-api | |
bind ${PUB_IP}:${PORT} | |
bind ${ADMIN_IP}:${PORT} | |
http-request set-header X-Forwarded-Proto https if { ssl_fc } | |
option httpchk | |
option httplog | |
option httpclose | |
server ${HOST} ${MGMT_IP}:${PORT} check inter 10s fastinter 2s downinter 3s rise 3 fall 3 | |
EOM | |
/usr/lib/ocf/resource.d/fuel/ns_haproxy reload | |
cd $DIR | |
pip install python-openstackclient | |
git clone https://github.com/openstack/python-masakariclient | |
cd python-masakariclient | |
pip install -r requirements.txt | |
python setup.py install | |
initctl reload-configuration | |
service masakari-api start | |
masakari-manage db sync | |
service masakari-engine start | |
echo "Activate masakari virtual env: source /root/v-masakari/bin/activate" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment