Browse Source

KAFKA-2304 Supported enabling JMX in Kafka Vagrantfile patch by Stevo Slavic reviewed by Ewen Cheslack-Postava

pull/72/merge
Joe Stein 9 years ago
parent
commit
ad485e148d
  1. 7
      Vagrantfile
  2. 5
      vagrant/broker.sh
  3. 7
      vagrant/zk.sh

7
Vagrantfile vendored

@ -22,6 +22,7 @@ VAGRANTFILE_API_VERSION = "2" @@ -22,6 +22,7 @@ VAGRANTFILE_API_VERSION = "2"
# General config
enable_dns = false
enable_jmx = false
num_zookeepers = 1
num_brokers = 3
num_workers = 0 # Generic workers that get the code, but don't start any services
@ -135,7 +136,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| @@ -135,7 +136,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ip_address = "192.168.50." + (10 + i).to_s
assign_local_ip(zookeeper, ip_address)
zookeeper.vm.provision "shell", path: "vagrant/base.sh"
zookeeper.vm.provision "shell", path: "vagrant/zk.sh", :args => [i.to_s, num_zookeepers]
zk_jmx_port = enable_jmx ? (8000 + i).to_s : ""
zookeeper.vm.provision "shell", path: "vagrant/zk.sh", :args => [i.to_s, num_zookeepers, zk_jmx_port]
end
}
@ -151,7 +153,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| @@ -151,7 +153,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# used to support clients running on the host.
zookeeper_connect = zookeepers.map{ |zk_addr| zk_addr + ":2181"}.join(",")
broker.vm.provision "shell", path: "vagrant/base.sh"
broker.vm.provision "shell", path: "vagrant/broker.sh", :args => [i.to_s, enable_dns ? name : ip_address, zookeeper_connect]
kafka_jmx_port = enable_jmx ? (9000 + i).to_s : ""
broker.vm.provision "shell", path: "vagrant/broker.sh", :args => [i.to_s, enable_dns ? name : ip_address, zookeeper_connect, kafka_jmx_port]
end
}

5
vagrant/broker.sh

@ -22,6 +22,7 @@ set -e @@ -22,6 +22,7 @@ set -e
BROKER_ID=$1
PUBLIC_ADDRESS=$2
PUBLIC_ZOOKEEPER_ADDRESSES=$3
JMX_PORT=$4
cd /opt/kafka
@ -35,4 +36,8 @@ echo "Killing server" @@ -35,4 +36,8 @@ echo "Killing server"
bin/kafka-server-stop.sh || true
sleep 5 # Because kafka-server-stop.sh doesn't actually wait
echo "Starting server"
if [[ -n $JMX_PORT ]]; then
export JMX_PORT=$JMX_PORT
export KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=$PUBLIC_ADDRESS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
fi
bin/kafka-server-start.sh /opt/kafka/config/server-$BROKER_ID.properties 1>> /tmp/broker.log 2>> /tmp/broker.log &

7
vagrant/zk.sh

@ -21,6 +21,7 @@ set -e @@ -21,6 +21,7 @@ set -e
ZKID=$1
NUM_ZK=$2
JMX_PORT=$3
cd /opt/kafka
@ -37,6 +38,10 @@ echo "$ZKID" > /tmp/zookeeper/myid @@ -37,6 +38,10 @@ echo "$ZKID" > /tmp/zookeeper/myid
echo "Killing ZooKeeper"
bin/zookeeper-server-stop.sh || true
sleep 5 # Because kafka-server-stop.sh doesn't actually wait
sleep 5 # Because zookeeper-server-stop.sh doesn't actually wait
echo "Starting ZooKeeper"
if [[ -n $JMX_PORT ]]; then
export JMX_PORT=$JMX_PORT
export KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=zk$ZKID -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
fi
bin/zookeeper-server-start.sh config/zookeeper-$ZKID.properties 1>> /tmp/zk.log 2>> /tmp/zk.log &

Loading…
Cancel
Save