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:2181,192.168.1.12:2181/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:2181,192.168.1.12:2181/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:2181,192.168.1.12:2181/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:2181,192.168.1.12:2181/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:2181,192.168.1.12:2181/mesos
# 运行Java 框架 (运行任务成功后会退出)
$ ./src/examples/java/test-framework zk://192.168.1.10:2181,192.168.1.11:2181,192.168.1.12:2181/mesos
# 运行 Python 框架 (运行任务成功后会退出)
$ ./src/examples/python/test-framework zk://192.168.1.10:2181,192.168.1.11:2181,192.168.1.12:2181/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:2182,192.168.1.11:2182,192.168.1.12:2182
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:2182
列出已有的topics:
$ bin/kafka-topics.sh --list --zookeeper 192.168.1.10:2182
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:2182 --topic test --from-beginning
在消费消息的终端显示:Hello Kafka