上传zabbix安装包,并安装java-gate-way: mv /data/download/zabbix-3.4.2.tar.gz /home/zabbix/ cd /home/zabbix/ tar -zxvf zabbix-3.4.2.tar.gz cd zabbix-3.4.2 ./configure --prefix=/data/zabbix --enable-java (如果zabbix-porxy或zabbix-server已安装,可指定一个新路径,gate-way与proxy、server并没有直接关系,可不必一起安装;如果都没有安装,为了管理方便,亦可放到同一目录) make && make install
安装完成之后,会在指定目录下存在以下文件:
1 2 3 4 5 6 7
ll /data/zabbix/sbin/zabbix_java/ total 12 drwxr-xr-x. 2 root root 65 Aug 23 02:41 bin drwxr-xr-x. 2 root root 177 Aug 23 02:36 lib -rw-r--r--. 1 root root 791 Aug 23 02:36 settings.sh -rwxr-xr-x. 1 root root 545 Aug 23 02:36 shutdown.sh -rwxr-xr-x. 1 root root 2025 Aug 23 02:36 startup.sh
calculate_heap_sizes() { case "`uname`" in Linux) system_memory_in_mb=`free -m | awk '/:/ {print $2;exit}'` system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` ;; FreeBSD) system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` ;; SunOS) system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` system_cpu_cores=`psrinfo | wc -l` ;; Darwin) system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` ;; *) # assume reasonable defaults for e.g. a modern desktop or # cheap server system_memory_in_mb="2048" system_cpu_cores="2" ;; esac # some systems like the raspberry pi don't report cores, use at least 1 if [ "$system_cpu_cores" -lt "1" ] then system_cpu_cores="1" fi # set max heap size based on the following # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) # calculate 1/2 ram and cap to 1024MB # calculate 1/4 ram and cap to 8192MB # pick the max half_system_memory_in_mb=`expr $system_memory_in_mb / 2` quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` if [ "$half_system_memory_in_mb" -gt "1024" ] then half_system_memory_in_mb="1024" fi if [ "$quarter_system_memory_in_mb" -gt "8192" ] then quarter_system_memory_in_mb="8192" fi if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] then max_heap_size_in_mb="$half_system_memory_in_mb" else max_heap_size_in_mb="$quarter_system_memory_in_mb" fi MAX_HEAP_SIZE="${max_heap_size_in_mb}M" # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) max_sensible_yg_per_core_in_mb="100" max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] then HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" else HEAP_NEWSIZE="${desired_yg_in_mb}M" fi } java_ver_output=`"${JAVA:-java}" -version 2>&1` jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}' | cut -d\- -f1` JVM_VERSION=${jvmver%_*} JVM_PATCH_VERSION=${jvmver#*_} if [ "$JVM_VERSION" \< "1.8" ] ; then echo "Cassandra 3.0 and later require Java 8u40 or later." exit 1; fi if [ "$JVM_VERSION" \< "1.8" ] && [ "$JVM_PATCH_VERSION" -lt 40 ] ; then echo "Cassandra 3.0 and later require Java 8u40 or later." exit 1; fi jvm=`echo "$java_ver_output" | grep -A 1 'java version' | awk 'NR==2 {print $1}'` case "$jvm" in OpenJDK) JVM_VENDOR=OpenJDK # this will be "64-Bit" or "32-Bit" JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'` ;; "Java(TM)") JVM_VENDOR=Oracle # this will be "64-Bit" or "32-Bit" JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'` ;; *) # Help fill in other JVM values JVM_VENDOR=other JVM_ARCH=unknown ;; esac JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log" JVM_OPTS_FILE=$CASSANDRA_CONF/jvm.options for opt in `grep "^-" $JVM_OPTS_FILE` do JVM_OPTS="$JVM_OPTS $opt" done echo $JVM_OPTS | grep -q Xmn DEFINED_XMN=$? echo $JVM_OPTS | grep -q Xmx DEFINED_XMX=$? echo $JVM_OPTS | grep -q Xms DEFINED_XMS=$? echo $JVM_OPTS | grep -q UseConcMarkSweepGC USING_CMS=$? echo $JVM_OPTS | grep -q UseG1GC USING_G1=$? if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" -o $USING_G1 -eq 0 ]; then calculate_heap_sizes elif [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" -a $USING_G1 -ne 0 ]; then echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs when using CMS GC (see cassandra-env.sh)" exit 1 fi if [ "x$MALLOC_ARENA_MAX" = "x" ] ; then export MALLOC_ARENA_MAX=4 fi if [ $DEFINED_XMX -ne 0 ] && [ $DEFINED_XMS -ne 0 ]; then JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}" JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}" elif [ $DEFINED_XMX -ne 0 ] || [ $DEFINED_XMS -ne 0 ]; then echo "Please set or unset -Xmx and -Xms flags in pairs on jvm.options file." exit 1 fi if [ $DEFINED_XMN -eq 0 ] && [ $DEFINED_XMX -ne 0 ]; then echo "Please set or unset -Xmx and -Xmn flags in pairs on jvm.options file." exit 1 elif [ $DEFINED_XMN -ne 0 ] && [ $USING_CMS -eq 0 ]; then JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}" fi if [ "$JVM_ARCH" = "64-Bit" ] && [ $USING_CMS -eq 0 ]; then JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark" fi JVM_OPTS="$JVM_OPTS -XX:CompileCommandFile=$CASSANDRA_CONF/hotspot_compiler" JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.0.jar" if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof" fi JVM_ON_OUT_OF_MEMORY_ERROR_OPT="-XX:OnOutOfMemoryError=kill -9 %p" JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=10.0.7.50" if [ "x$LOCAL_JMX" = "x" ]; then LOCAL_JMX=no fi JMX_PORT="7199" if [ "$LOCAL_JMX" = "yes" ]; then JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT" JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" else JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT" # if ssl is enabled the same port cannot be used for both jmx and rmi so either # pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins) JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT" # turn on JMX authentication. See below for further options JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" # jmx ssl options JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false" #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.need.client.auth=true" #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.protocols=<enabled-protocols>" #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.cipher.suites=<enabled-cipher-suites>" #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/path/to/keystore" #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=<keystore-password>" #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStore=/path/to/truststore" #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStorePassword=<truststore-password>" fi JVM_OPTS="$JVM_OPTS -Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin" JVM_OPTS="$JVM_OPTS $MX4J_ADDRESS" JVM_OPTS="$JVM_OPTS $MX4J_PORT" JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
主要修改一下内容,默认LOCAL_JMX=yes
1 2 3
if [ "x$LOCAL_JMX" = "x" ]; then LOCAL_JMX=no fi
将true改为false,修改远程访问认证无需密码:
1 2 3 4 5 6 7 8 9 10
if [ "$LOCAL_JMX" = "yes" ]; then JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT" JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" else JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT" # if ssl is enabled the same port cannot be used for both jmx and rmi so either # pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins) JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT" # turn on JMX authentication. See below for further options JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"