docker pull zookeeper:latest
mkdir -p /home/docker/zk-test/data
mkdir -p /home/docker/zk-test/logs
docker run --name zk-test --net=host --restart always -v /home/docker/zk-test:/data/zookeeper -e ZOO_PORT=2181 -e ZOO_DATA_DIR=/data/zookeeper/data -e ZOO_DATA_LOG_DIR=/data/zookeeper/logs -e ZOO_MY_ID=1 -e ZOO_SERVERS="server.1=192.168.0.100:2888:3888 server.2=192.168.0.101:2888:3888 server.3=192.168.0.102:2888:3888" -d zookeeper:latest
docker run --name zk-test --net=host --restart always -v /home/docker/zk-test:/data/zookeeper -e ZOO_PORT=2181 -e ZOO_DATA_DIR=/data/zookeeper/data -e ZOO_DATA_LOG_DIR=/data/zookeeper/logs -e ZOO_MY_ID=2 -e ZOO_SERVERS="server.1=192.168.0.100:2888:3888 server.2=192.168.0.101:2888:3888 server.3=192.168.0.102:2888:3888" -d zookeeper:latest
docker run --name zk-test --net=host --restart always -v /home/docker/zk-test:/data/zookeeper -e ZOO_PORT=2181 -e ZOO_DATA_DIR=/data/zookeeper/data -e ZOO_DATA_LOG_DIR=/data/zookeeper/logs -e ZOO_MY_ID=3 -e ZOO_SERVERS="server.1=192.168.0.100:2888:3888 server.2=192.168.0.101:2888:3888 server.3=192.168.0.102:2888:3888" -d zookeeper:latest
ZOO_MY_ID=[1,2,3]
参数。docker exec -it zk-test /bin/bash
zkServer.sh status
如下结果即为成功:
bash-4.4# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /conf/zoo.cfg
Mode: follower
docker pull wurstmeister/kafka:latest
docker run --name kafka-test --net=host --restart always --volume /home/docker/kafka-test/data:/data -e KAFKA_BROKER_ID=1 -e KAFKA_PORT=9092 -e KAFKA_HEAP_OPTS="-Xms2g -Xmx4g" -e KAFKA_HOST_NAME=192.168.0.100 -e KAFKA_ADVERTISED_HOST_NAME=192.168.0.100 -e KAFKA_LOG_DIRS=/data/kafka -e KAFKA_ZOOKEEPER_CONNECT="192.168.0.100:2181,192.168.0.101:2181,192.168.0.102:2181" -d wurstmeister/kafka:latest
docker run --name kafka-test --net=host --restart always --volume /home/docker/kafka-test/data:/data -e KAFKA_BROKER_ID=2 -e KAFKA_PORT=9092 -e KAFKA_HEAP_OPTS="-Xms2g -Xmx4g" -e KAFKA_HOST_NAME=192.168.0.101 -e KAFKA_ADVERTISED_HOST_NAME=192.168.0.101 -e KAFKA_LOG_DIRS=/data/kafka -e KAFKA_ZOOKEEPER_CONNECT="192.168.0.100:2181,192.168.0.101:2181,192.168.0.102:2181" -d wurstmeister/kafka:latest
docker run --name kafka-test --net=host --restart always --volume /home/docker/kafka-test/data:/data -e KAFKA_BROKER_ID=3 -e KAFKA_PORT=9092 -e KAFKA_HEAP_OPTS="-Xms2g -Xmx4g" -e KAFKA_HOST_NAME=192.168.0.102 -e KAFKA_ADVERTISED_HOST_NAME=192.168.0.102 -e KAFKA_LOG_DIRS=/data/kafka -e KAFKA_ZOOKEEPER_CONNECT="192.168.0.100:2181,192.168.0.101:2181,192.168.0.102:2181" -d wurstmeister/kafka:latest
docker exec -it kafka-test /bin/bash
/opt/kafka/bin/kafka-topics.sh --create --zookeeper 192.168.0.100:2181,192.168.0.101:2181,192.168.0.102:2181 --topic test --partitions 3 --replication-factor 2
/opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 192.168.0.101:9092 --topic test --from-beginning
/opt/kafka/bin/kafka-console-producer.sh --broker-list 192.168.0.101:9092 --topic test
docker pull probablyfine/flume:latest
mkdir -p /home/docker/flume-test
cd home/docker/flume-test
vim flume.conf
复制以下内容到flume.conf中
# Name the components on this agent
datahub101.sources = r1 r2 r3
datahub101.sinks = k1
datahub101.channels = c1
# Describe/configure the source
datahub101.sources.r1.type = exec
datahub101.sources.r1.command = tail -F /var/tmp/flume_log/test1/test1.log
datahub101.sources.r1.interceptors = i1
datahub101.sources.r1.interceptors.i1.type = static
datahub101.sources.r1.interceptors.i1.key = type
datahub101.sources.r1.interceptors.i1.value = test1
datahub101.sources.r2.type = exec
datahub101.sources.r2.command = tail -F /var/tmp/flume_log/test2/test2.log
datahub101.sources.r2.interceptors = i2
datahub101.sources.r2.interceptors.i2.type = static
datahub101.sources.r2.interceptors.i2.key = type
datahub101.sources.r2.interceptors.i2.value = test2
datahub101.sources.r3.type = exec
datahub101.sources.r3.command = tail -F /var/tmp/flume_log/test3/test3.log
datahub101.sources.r3.interceptors = i3
datahub101.sources.r3.interceptors.i3.type = static
datahub101.sources.r3.interceptors.i3.key = type
datahub101.sources.r3.interceptors.i3.value = test3
# Describe the sink
datahub101.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
datahub101.sinks.k1.kafka.topic =test
datahub101.sinks.k1.kafka.bootstrap.servers = 192.168.0.101:9092
datahub101.sinks.k1.kafka.flumeBatchSize = 20
datahub101.sinks.k1.kafka.producer.acks = 1
datahub101.sinks.k1.kafka.producer.linger.ms = 1
datahub101.sinks.ki.kafka.producer.compression.type = snappy
# Use a channel which buffers events in memory
datahub101.channels.c1.type = memory
datahub101.channels.c1.capacity = 1000
datahub101.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
datahub101.sources.r1.channels = c1
datahub101.sources.r2.channels = c1
datahub101.sources.r3.channels = c1
datahub101.sinks.k1.channel = c1
docker run --name flume-test --restart always --net=host -v /home/docker/flume-test/flume.conf:/opt/flume-config/flume.conf -v /home/docker/flume-test/flume_log:/var/tmp/flume_log -e FLUME_AGENT_NAME="AGENT-101" -d probablyfine/flume:latest
echo "test msg" >> test1.log
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.0.0
mkdir -p /home/docker/es-test/data
chmod 755 /home/docker/es-test/data
cd /home/docker/es-test
vim elasticsearch.yml
将下列参数加到elasticsearch.yml中
#集群名称,多个节点用一个名称
cluster.name: test
# es 1.0版本的默认配置是 "0.0.0.0",所以不绑定ip也可访问
network.host: 0.0.0.0
node.name: master
#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
docker run --name es-test -p 9200:9200 -p 9300:9300 -p 5601:5601 -e "discovery.type=single-node" -v /home/docker/es-test/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/docker/es-test/data:/usr/share/elasticsearch/data -d docker.elastic.co/elasticsearch/elasticsearch:7.0.0
docker pull docker.elastic.co/kibana/kibana:7.0.0
docker run -d -e ELASTICSEARCH_URL=http://192.168.0.100:9200 --name kibana-test --network=container:es-test docker.elastic.co/kibana/kibana:7.0.0
docker logs es-test
查看es启动的容器内的ip。server.name: kibana
server.host: 0.0.0.0
elasticsearch.hosts: [ "http://172.17.0.2:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
访问192.168.0.100:5601即可。