rdudyala | b086cf3 | 2016-08-11 00:07:45 -0400 | [diff] [blame] | 1 | |
| 2 | Subscribe-Publish Frame Work: |
| 3 | 1.Command to Install Flask Webserver frame work. |
| 4 | sudo pip install Flask |
| 5 | |
| 6 | Along with flask we need the following packages: |
| 7 | msgpack |
| 8 | fnmatch |
| 9 | operator |
| 10 | logging |
| 11 | oslo_utils |
| 12 | ConfigParser |
| 13 | |
| 14 | 2.Files: i.sub_main.py |
| 15 | ii.pubrecords.py |
| 16 | iii.pub_sub.conf |
| 17 | |
| 18 | 3.Command to start the server: |
| 19 | #python sun_main.py |
| 20 | 4.Command for subscription: |
| 21 | i.app_id:Application ID,should be unique. |
| 22 | ii.target: |
| 23 | Presently only udp is supported. |
| 24 | a.udp:<ip:portno> |
| 25 | b.kafka:<kafkaip:kafkaport> |
| 26 | iii.sub_info:Sunscription notifications.ex:cpu_util,cpu_* |
| 27 | It can be given as single input or list. |
| 28 | iv.query: |
| 29 | Below information need to provide as part of query. |
| 30 | a.field:fileds like user id ,porject id etc., |
| 31 | b.op:"eq","gt","lt" etc., |
| 32 | c.value:value of the fileds. |
| 33 | Example: |
| 34 | curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10","target":"udp://10.11.10.1:5006","sub_info":"cpu_util","query":[{"field":"user_id","op":"eq","value":"e1271a86bd4e413c87248baf2e5f01e0"},{"field":"project_id","op":"eq","value":"b1a3bf16d2014b47be9aefea88087318"},{"field":"resource_id","op":"eq","value":"658cd03f-d0f0-4f55-9f48-39e7222a8646"}]}' -L http://10.11.10.1:4455/subscribe |
| 35 | curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10","target":"udp://10.11.10.1:5006", "sub_info":["cpu_util", "memory"],"query":[{"field":"user_id","op":"eq","value":"e1271a86bd4e413c87248baf2e5f01e0"},{"field":"project_id","op":"eq","value":"b1a3bf16d2014b47be9aefea88087318"},{"field":"resource_id","op":"eq","value":"658cd03f-d0f0-4f55-9f48-39e7222a8646"}]}' -L http://10.11.10.1:4455/subscribe |
| 36 | |
| 37 | 5.Command for unsunscription: |
| 38 | For unsubcription only appid will be needed. |
| 39 | curl -i -H "Content-Type: application/json" -X POST -d '{"app_id":"10"}' http://10.11.10.1:4455/unsubscribe |
| 40 | |
| 41 | 6.Running Kafka on the server server where pub-sub module is running: |
| 42 | i.Download the kafka from: |
| 43 | #https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz |
| 44 | http://apache.arvixe.com/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz |
| 45 | ii.install java |
| 46 | sudo apt-get update |
| 47 | sudo apt-get install default-jre |
| 48 | iii. install kafka package |
| 49 | sudo easy_install pip |
| 50 | sudo pip install kafka-python |
| 51 | iv.tar -xzf kafka_2.11-0.9.0.0.tgz |
| 52 | v. Start the zookeeper server: |
| 53 | bin/zookeeper-server-start.sh config/zookeeper.properties |
| 54 | vi.Start Kafka Server : |
| 55 | bin/kafka-server-start.sh config/server.properties |
| 56 | vii.To read messages from kafka on a topic test : |
| 57 | bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning |
| 58 | viii.Before configuring kafka:// publisher in ceilometer: |
| 59 | install kafka on both controller node and compute nodes |
| 60 | Restart the ceilometer-agent-notification, ceilometer-agent-compute, ceilometer-agent-central daemons |
| 61 | |
| 62 | 7.[Optional]Install Kafka-web-console (GUI) |
| 63 | i.wget https://github.com/adamfokken/kafka-web-console/archive/topic-add-remove.zip |
| 64 | ii.unzip it |
| 65 | iii.wget http://downloads.typesafe.com/typesafe-activator/1.3.2/typesafe-activator-1.3.2-minimal.zip |
| 66 | iv.unzip it and add it to the system path so you can execute the activator command that it provides. |
| 67 | v.Install javac if required: sudo apt-get install openjdk-7-jdk |
| 68 | vi.cd kafka-web-console-topic-add-remove |
| 69 | vii.activator start -DapplyEvolutions.default=true |
| 70 | viii.Point your browser to the kafka we-console port (9000) and register the zookeeper |