zookeeper 1) cp /vagrant/zookeeper-3.5.2-alpha.tar.gz ~2) cd zookeeper-3.5.2-alpha3) mkdir data4) mkdir datalog5) cd data6) touch myid7) echo 1 > myid ...
zookeeper
1) cp /vagrant/zookeeper-3.5.2-alpha.tar.gz ~
2) cd zookeeper-3.5.2-alpha
3) mkdir data
4) mkdir datalog
5) cd data
6) touch myid
7) echo 1 > myid
8) more myid
9) cd ..
10) cd conf
11) cp zoo_sample.cfg zoo.cfg
12) vi zoo.cfg
13) update as below
dataDir=/home/vagrant/zookeeper-3.4.8/data
dataLogDir=/home/vagrant/zookeeper-3.4.8/datalog
# the port at which the clients will connect
clientPort=2181
server.1=192.168.1.10:2888:3888
server.2=192.168.1.11:2888:3888
server.3=192.168.1.12:2888:3888
14) sudo vi /etc/hosts
192.168.1.10 Mesos01
192.168.1.11 Slave01
192.168.1.12 Slave02
15) bash bin/zkServer.sh start/status/stop
Mesos for zookeeper
# 切換到源碼目錄
$ cd build
# 啟動 mesos 主控端(請確保 目錄存在,且許可權合適)
$ sudo ./bin/mesos-master.sh --zk=zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos --quorum=1 --work_dir=/var/lib/mesos --hostname=Mesos01
$ sudo ./bin/mesos-master.sh --zk=zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos --quorum=1 --work_dir=/var/lib/mesos --hostname=Slave01
$ sudo ./bin/mesos-master.sh --zk=zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos --quorum=1 --work_dir=/var/lib/mesos --hostname=Slave02
# 啟動 被控
$ sudo ./bin/mesos-slave.sh --master=zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos --work_dir=/var/lib/mesos
# 訪問 mesos頁面
$ http://192.168.1.10:5050
# 運行 C++ 框架 (運行任務成功後會退出)
$ ./src/test-framework --master=zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos
# 運行Java 框架 (運行任務成功後會退出)
$ ./src/examples/java/test-framework zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos
# 運行 Python 框架 (運行任務成功後會退出)
$ ./src/examples/python/test-framework zk://192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183/mesos
Kafka for zookeeper
1) vi $KAFKA_HOME/config/server.properties
broker.id=0/1/2
port=9092
host.name=Mesos01/Slave01/Slave02
advertised.host.name=Mesos01/Slave01/Slave02
...
num.partitions=2
...
zookeeper.connect=192.168.1.10:2181,192.168.1.11:2182,192.168.1.12:2183
2) 啟動kafka服務, 在zk1,zk2,zk3上分別運行:
bin/kafka-server-start.sh config/server.properties
3) 新建一個TOPIC(replication-factor=num of brokers)
bin/kafka-topics.sh --create --topic test --replication-factor 3 --partitions 2 --zookeeper 192.168.1.10:2181
列出已有的topics:
$ bin/kafka-topics.sh --list --zookeeper 192.168.1.10:2181
4)假設我們在zk2上,開一個終端,發送消息至kafka(zk2模擬producer)
$ bin/kafka-console-producer.sh --broker-list 192.168.1.10:9092 --sync --topic test
在發送消息的終端輸入:Hello Kafka
5)假設我們在zk3上,開一個終端,顯示消息的消費(zk3模擬consumer)
$ bin/kafka-console-consumer.sh --zookeeper 192.168.1.10:2181 --topic test --from-beginning
在消費消息的終端顯示:Hello Kafka