Skip to content

Instantly share code, notes, and snippets.

@congto
Forked from michalskalski/masakari-compute.sh
Created May 1, 2018 02:25
Show Gist options
  • Select an option

  • Save congto/b46c9ceb759ceff327406d39aa7aa4a9 to your computer and use it in GitHub Desktop.

Select an option

Save congto/b46c9ceb759ceff327406d39aa7aa4a9 to your computer and use it in GitHub Desktop.

Revisions

  1. @michalskalski michalskalski revised this gist Jan 30, 2017. 2 changed files with 5 additions and 3 deletions.
    6 changes: 4 additions & 2 deletions masakari-compute.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ 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 git python-pip python-dev pkg-config libvirt-dev
    apt-get install -y --force-yes git python-pip python-dev pkg-config libvirt-dev
    pip install --upgrade pip
    pip install virtualenv

    @@ -107,11 +107,13 @@ ADMIN_USER="admin"
    ADMIN_PASS="admin"
    # Administrator user's project name
    PROJECT="demo"
    PROJECT="admin"
    # Name of Region
    REGION="RegionOne"
    IGNORE_RESOURCE_GROUP_NAME_PATTERN="stonith"
    # Address of Keystone
    AUTH_URL="http://${ADMIN_IP}:5000/"
    EOM
    2 changes: 1 addition & 1 deletion masakari-controller.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ PASS='masakari'
    DIR="$(dirname `readlink -f $0`)"

    apt-get update
    apt-get install -y git python-pip python-dev
    apt-get install -y --force-yes git python-pip python-dev
    pip install --upgrade pip
    pip install virtualenv
    source /root/openrc
  2. @michalskalski michalskalski revised this gist Jan 27, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions masakari-controller.sh
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ mysql_host=$(hiera management_vip)

    cat > /etc/masakari/masakari.conf <<- EOM
    [DEFAULT]
    raceful_shutdown_timeout = 5
    graceful_shutdown_timeout = 5
    os_privileged_user_tenant = services
    os_privileged_user_password = ${nova_pass}
    os_privileged_user_name = nova
    @@ -66,7 +66,7 @@ user_domain_name = Default
    connection = mysql+pymysql://${USER}:${PASS}@${ADMIN_IP}/masakari?charset=utf8
    [oslo_messaging_rabbit]
    rabbit_hosts = ${MGMT_IP}:5672
    rabbit_hosts = ${MGMT_IP}:5673
    rabbit_userid = nova
    rabbit_password = ${rabbit_pass}
    EOM
  3. @michalskalski michalskalski revised this gist Dec 6, 2016. 2 changed files with 102 additions and 7 deletions.
    99 changes: 97 additions & 2 deletions masakari-compute.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,10 @@ 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 git python-pip python-dev pkg-config libvirt-dev
    pip install --upgrade pip
    pip install virtualenv
    @@ -33,9 +37,100 @@ 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

    apt-get install pacemaker-remote
    iptables -A INPUT -p tcp -m multiport --ports 3121 -m comment --comment "pacemaker-remore" -j ACCEPT
    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="demo"
    # Name of Region
    REGION="RegionOne"
    # 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"
    10 changes: 5 additions & 5 deletions masakari-controller.sh
    Original file line number Diff line number Diff line change
    @@ -101,11 +101,6 @@ script
    end script
    EOM

    initctl reload-configuration
    service masakari-api start
    masakari-manage db sync
    service masakari-engine start

    cat > /etc/haproxy/conf.d/199-masakari.cfg <<- EOM
    listen masakari-api
    bind ${PUB_IP}:${PORT}
    @@ -124,4 +119,9 @@ 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"
  4. @michalskalski michalskalski revised this gist Dec 6, 2016. 1 changed file with 34 additions and 3 deletions.
    37 changes: 34 additions & 3 deletions masakari-controller.sh
    Original file line number Diff line number Diff line change
    @@ -72,9 +72,39 @@ rabbit_password = ${rabbit_pass}
    EOM

    iptables -A INPUT -p tcp -m multiport --ports $PORT -m comment --comment "masakari-api" -j ACCEPT
    screen -dmS masakari-api masakari-api --config-file=/etc/masakari/masakari.conf --debug

    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

    initctl reload-configuration
    service masakari-api start
    masakari-manage db sync
    screen -dmS masakari-engine masakari-engine --config-file=/etc/masakari/masakari.conf --debug
    service masakari-engine start

    cat > /etc/haproxy/conf.d/199-masakari.cfg <<- EOM
    listen masakari-api
    @@ -93,4 +123,5 @@ pip install python-openstackclient
    git clone https://github.com/openstack/python-masakariclient
    cd python-masakariclient
    pip install -r requirements.txt
    python setup.py install
    python setup.py install
    echo "Activate masakari virtual env: source /root/v-masakari/bin/activate"
  5. @michalskalski michalskalski revised this gist Nov 30, 2016. 1 changed file with 41 additions and 0 deletions.
    41 changes: 41 additions & 0 deletions masakari-compute.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/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 -y 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

    pip install -r fix-req.txt
    python setup.py install
    mkdir -p /etc/masakari

    apt-get install pacemaker-remote
    iptables -A INPUT -p tcp -m multiport --ports 3121 -m comment --comment "pacemaker-remore" -j ACCEPT
  6. @michalskalski michalskalski created this gist Nov 28, 2016.
    96 changes: 96 additions & 0 deletions masakari-controller.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,96 @@
    #!/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 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]
    raceful_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}:5672
    rabbit_userid = nova
    rabbit_password = ${rabbit_pass}
    EOM

    iptables -A INPUT -p tcp -m multiport --ports $PORT -m comment --comment "masakari-api" -j ACCEPT
    screen -dmS masakari-api masakari-api --config-file=/etc/masakari/masakari.conf --debug
    masakari-manage db sync
    screen -dmS masakari-engine masakari-engine --config-file=/etc/masakari/masakari.conf --debug

    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