How to install and setup Monasca (1/3)

In my previous blog post I covered my initial impressions on Monasca. In the following trilogy I will cover its installation, setup, and testing. The installation will be performed for the Java version of Monasca, as some components have both Java and Python code available. For those which only need a quick local setup best would be to use the vagrant setup found here.

The installation will be performed on Ubuntu 14.04 and will be split into 3 posts. The first one (this one) will cover dependency installation and configuration, the next one will cover Monasca’s installation and configuration, and the final one will cover the testing of the whole setup.

The first steps are to update, upgrade and reboot the system.

sudo apt-get update
sudo apt-get upgrade -y
sudo reboot

Next we have to setup the hostnames as, during this tutorial, we will use the monasca and devstack hostnames to refer to the virtual machines. For that, /etc/hosts needs to be edited and the following lines added to it.

127.0.0.1 monasca
[please_put_correct_ip] devstack

and then

sudo hostname monasca

Next we will install git as we will use it a lot.

sudo apt-get install -y git

Next we will install MySQL. We will need the username / password combination further on so for tutorial purposes set them to root / password.

sudo apt-get install -y mysql-server libmysqlclient-dev

We have to download the latest Monasca MySQL schema and import it.

wget https://raw.githubusercontent.com/stackforge/cookbook-monasca-schema/master/files/default/mysql/mon.sql
mysql -uroot -ppassword < mon.sql
rm -rf mon.sql

Please note that this schema file is no longer maintained and the schema at

https://github.com/hpcloud-mon/ansible-monasca-schema/blob/master/templates/mon.sql.j2

is the reference one, however it is served as a template for users and should be manually edited according to personal preferences before being imported.

Because of some Monasca which connect on the external interface, the default MySQL bind-address needs to be changed to 0.0.0.0 in /etc/mysql/my.cnf

sudo sed -i.bak 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf

And then we restart MySQL

sudo service mysql restart

Next we’ll install and start Zookeeper

sudo apt-get install -y zookeeper zookeeperd zookeeper-bin
sudo service zookeeper start

And then Kafka and its dependency Scala

sudo apt-get install -y scala

wget http://mirror.switch.ch/mirror/apache/dist/kafka/0.8.1.1/kafka_2.9.2-0.8.1.1.tgz

tar xvf kafka_2.9.2-0.8.1.1.tgz

mv kafka_2.9.2-0.8.1.1 kafka

rm kafka_2.9.2-0.8.1.1.tgz

Next we have to configure and start it

sed -i.bak 's/#host.name=localhost/host.name=monasca/g' kafka/config/server.properties
sed -i.bak 's/zookeeper.connect=localhost:2181/zookeeper.connect=monasca:2181/g' kafka/config/server.properties
sudo nohup ./kafka/bin/kafka-server-start.sh ./kafka/config/server.properties &

Please give it a moment to start before creating the partitions for Monasca

./kafka/bin/kafka-topics.sh --create --topic metrics --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic events --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic raw-events --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic transformed-events --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic alarm-state-transitions --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic alarm-notifications --partitions 4 --zookeeper monasca:2181 --replication-factor 1
./kafka/bin/kafka-topics.sh --create --topic retry-notifications --partitions 4 --zookeeper monasca:2181 --replication-factor 1

Postfix is required by monasca-notification in order to send emails

sudo debconf-set-selections <<< "postfix postfix/mailname string monasca"
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
sudo apt-get install -y postfix

Then we need InfluxDB for storing metrics

wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
sudo dpkg -i influxdb_latest_amd64.deb
rm influxdb_latest_amd64.deb

And we’ll change it’s default port to 9090 and restart the service

sudo sed -i.bak 's/port = 8090/port = 9090/g' /opt/influxdb/shared/config.toml
sudo service influxdb restart

Next we create the database and users

curl -X POST 'http://monasca:8086/db?u=root&p=root' -d '{"name": "mon"}'
curl -X POST 'http://monasca:8086/db/mon/users?u=root&p=root' -d '{"name": "mon_api", "password": "password"}'
curl -X POST 'http://monasca:8086/db/mon/users?u=root&p=root' -d '{"name": "mon_persister", "password": "password"}'

As a side note, in order to view the metrics stored in InfluxDB, one can go to http://monasca:8083/ (please replace monasca with the appropriate IP) and login with username/password combination root/root.

In order to install Monasca’s packages we need to setup the python environment and java environment

sudo apt-get install -y python-pip default-jre default-jdk maven

Monasca’s thresholding engine is reliant on Apache Storm so that’s what we’ll setup and start next

wget http://mirror.switch.ch/mirror/apache/dist/storm/apache-storm-0.9.3/apache-storm-0.9.3.tar.gz
tar xvf apache-storm-0.9.3.tar.gz
rm apache-storm-0.9.3.tar.gz
sudo mkdir -p /opt/storm/
sudo mv apache-storm-0.9.3/ /opt/storm/
sudo mv /opt/storm/apache-storm-0.9.3/ /opt/storm/current

We need to make storm play nice with Zookeeper and set it up

sudo sed -i.bak '/"nimbus"/a\
nimbus.host: "monasca"\
storm.zookeeper.servers:\
  - monasca\
\
ui.port: 60888' /opt/storm/current/conf/storm.yaml

Last thing is to start nimbus and the supervisor. Please give nimbus some time to start up before running the supervisor startup

/opt/storm/current/bin/storm nimbus &
/opt/storm/current/bin/storm supervisor &

Up next are the installation and configuration of Monasca components.


12 Kommentare

  • Hi,

    After following these steps, I was able to set it up but having only the below issue – I was not able to see list of metrics in the “Create Alarm Definition” popup window for the field “Expression”.

    Could you please help where can it go wrong? I’m able to see the list of all the default alarm definitions and corresponding alarms. Also I was able to manually create an alarm definition using python-monascaclient and the alarm worked for this. But the only issue is I’m not able to see the metrics list and expressions like (“max”, “avg” etc.) in the “Create Alarm Definition” window.

    Thanks & Regards,
    Sourav

  • Hello,

    I am trying to install Monasca in an OpenStack testbed.

    After following the steps I have an issue with InfluxDB:
    The url: http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb for InfluxDB doesn’t work and I installed it via : https://s3.amazonaws.com/influxdb/influxdb_0.9.5.1_amd64.deb but I don’t have the file /opt/influxdb/shared/config.toml and I can’t change the port to 9090. Also I can’t create the database and users in the following step where I get the error — 404 page not found

    Could you please help me with InfluxDB?

    Best Regards
    Ani

  • getting error as page not found while executing below command
    curl -X POST ‘http://monasca:8086/db/mon/users?u=root&p=root’ -d ‘{“name”: “mon_persister”, “password”: “password”}’

    • I’m getting the same, although for the first of the curl commands. For now, I skipped over the step to change the port from 8090 to 9090 as the config file is no longer under /opt–wondering if this is related…?

      • getting 404 error while doing
        curl -X POST ‘http://monasca:8086/db?u=root&p=root’ -d ‘{“name”: “mon”}’
        curl -X POST ‘http://monasca:8086/db/mon/users?u=root&p=root’ -d ‘{“name”: “mon_api”, “password”: “password”}’
        curl -X POST ‘http://monasca:8086/db/mon/users?u=root&p=root’ -d ‘{“name”: “mon_persister”, “password”: “password”}’

        and am not able to do execute this step also

        sudo sed -i.bak ‘s/port = 8090/port = 9090/g’ /opt/influxdb/shared/config.toml

        any suggestions

        Thanks

      • getting 404 error while doing
        curl -X POST ‘http://monasca:8086/db?u=root&p=root’ -d ‘{“name”: “mon”}’
        curl -X POST ‘http://monasca:8086/db/mon/users?u=root&p=root’ -d ‘{“name”: “mon_api”, “password”: “password”}’
        curl -X POST ‘http://monasca:8086/db/mon/users?u=root&p=root’ -d ‘{“name”: “mon_persister”, “password”: “password”}’

        and am not able to do execute this step also

        sudo sed -i.bak ‘s/port = 8090/port = 9090/g’ /opt/influxdb/shared/config.toml

        any suggestions

        Thanks

      • You can avoid this by using the influxdb CLI:

        on the command line type : influx
        you get a CLI to interact with, you can create your databases, users, etc..


Leave a Reply

Your email address will not be published. Required fields are marked *