另类--kafka集群中jmx端口设置

# 监控kafka集群
# 有一个问题,需要在kafka-server-start.sh文件中配置端口,有如下三种办法
# 第一种:复制并修改kafka目录,比如kafka-1,kafka-2,kafka-3,然后再每个目录下修改kafka-server-start.sh文件
# 第二种:在启动脚本start.sh中添加指定端口
# 第三种:多复制几个kafka-server-start.sh文件,然后进行修改,最后在start.sh中修改一下

# 以下三种方法任选其一即可

# 第一种方式办法,相应行修改成如下形式,注意端口号不同
# 使用的是不同目录下的不同kafka-server-start.sh文件
# start.sh文件也需要做相应的修改
# kafka-1/bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
    export JMX_PORT="9997"
fi
# kafka-2/bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
    export JMX_PORT="9998"
fi
# kafka-3/bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
    export JMX_PORT="9999"
fi

# start.sh
	#!/bin/bash
	bash kafka-1/bin/kafka-server-start.sh -daemon config/server-1.properties
	bash kafka-2/bin/kafka-server-start.sh -daemon config/server-2.properties
	bash kafka-3/bin/kafka-server-start.sh -daemon config/server-3.properties

# 第二种方法
# 使用的用一个目录下的同一个文件,只是在每个命令前指定端口号
vim start.sh
	#!/bin/bash

	JMX_PORT=9997 bash bin/kafka-server-start.sh -daemon config/server-1.properties
	JMX_PORT=9998 bash bin/kafka-server-start.sh -daemon config/server-2.properties
	JMX_PORT=9999 bash bin/kafka-server-start.sh -daemon config/server-3.properties

# 第三种方法
# 使用的是同一个目录下的不同kafka-server-start文件
# start.sh文件也需要做相应的修改
cp kafka-server-start.sh kafka-server-start-1.sh
cp kafka-server-start.sh kafka-server-start-2.sh
cp kafka-server-start.sh kafka-server-start-3.sh

vim kafka-server-start-1.sh
	if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
	   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
	    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
	    export JMX_PORT="9997"
	fi
vim kafka-server-start-2.sh
	if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
	   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
	    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
	    export JMX_PORT="9998"
	fi
vim kafka-server-start-3.sh
	if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
	   # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
	    export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
	    export JMX_PORT="9999"
	fi

vim start.sh 
	#!/bin/bash

	bash bin/kafka-server-start-1.sh -daemon config/server-1.properties
	bash bin/kafka-server-start-2.sh -daemon config/server-2.properties
	bash bin/kafka-server-start-3.sh -daemon config/server-3.properties
posted @ 2019-09-20 14:12  哈喽哈喽111111  阅读(915)  评论(0编辑  收藏  举报