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

This commit is contained in:
Joe Stein 2015-07-07 10:09:11 -07:00
parent f77dc386c0
commit ad485e148d
3 changed files with 16 additions and 3 deletions

7
Vagrantfile vendored
View File

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

View File

@ -22,6 +22,7 @@ set -e
BROKER_ID=$1 BROKER_ID=$1
PUBLIC_ADDRESS=$2 PUBLIC_ADDRESS=$2
PUBLIC_ZOOKEEPER_ADDRESSES=$3 PUBLIC_ZOOKEEPER_ADDRESSES=$3
JMX_PORT=$4
cd /opt/kafka cd /opt/kafka
@ -35,4 +36,8 @@ echo "Killing server"
bin/kafka-server-stop.sh || true bin/kafka-server-stop.sh || true
sleep 5 # Because kafka-server-stop.sh doesn't actually wait sleep 5 # Because kafka-server-stop.sh doesn't actually wait
echo "Starting server" 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 & bin/kafka-server-start.sh /opt/kafka/config/server-$BROKER_ID.properties 1>> /tmp/broker.log 2>> /tmp/broker.log &

View File

@ -21,6 +21,7 @@ set -e
ZKID=$1 ZKID=$1
NUM_ZK=$2 NUM_ZK=$2
JMX_PORT=$3
cd /opt/kafka cd /opt/kafka
@ -37,6 +38,10 @@ echo "$ZKID" > /tmp/zookeeper/myid
echo "Killing ZooKeeper" echo "Killing ZooKeeper"
bin/zookeeper-server-stop.sh || true 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" 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 & bin/zookeeper-server-start.sh config/zookeeper-$ZKID.properties 1>> /tmp/zk.log 2>> /tmp/zk.log &