一、异常描述
安装kafka时报"Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/kafka/common/utils/KafkaThread : Unsupported major.minor version 52.0"异常错误,详情日志如下>>
[root@centos6 bin]# sh kafka-server-start.sh ../config/server.properties @b@Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/kafka/common/utils/KafkaThread : Unsupported major.minor version 52.0@b@ at java.lang.ClassLoader.defineClass1(Native Method)@b@ at java.lang.ClassLoader.defineClass(ClassLoader.java:800)@b@ at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)@b@ at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)@b@ at java.net.URLClassLoader.access$100(URLClassLoader.java:71)@b@ at java.net.URLClassLoader$1.run(URLClassLoader.java:361)@b@ at java.net.URLClassLoader$1.run(URLClassLoader.java:355)@b@ at java.security.AccessController.doPrivileged(Native Method)@b@ at java.net.URLClassLoader.findClass(URLClassLoader.java:354)@b@ at java.lang.ClassLoader.loadClass(ClassLoader.java:425)@b@ at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)@b@ at java.lang.ClassLoader.loadClass(ClassLoader.java:358)@b@ at kafka.utils.Log4jControllerRegistration$.<init>(Logging.scala:30)@b@ at kafka.utils.Log4jControllerRegistration$.<clinit>(Logging.scala)@b@ at kafka.utils.Logging$class.$init$(Logging.scala:47)@b@ at kafka.Kafka$.<init>(Kafka.scala:30)@b@ at kafka.Kafka$.<clinit>(Kafka.scala)@b@ at kafka.Kafka.main(Kafka.scala)
二、解决方法
因系统环境原安装jdk版本是1.7的,安装kafka版本是kafka_2.12-2.1.0.tgz,解决方法有两个:方法一:对于kafka_2.12-2.1.0.tgz,需按照jdk1.8版本;方法二:安装kafka_2.11-0.9.0.1.tgz版本,匹配jdk1.7
[root@centos6 kafka_2.11-0.9.0.1]# bin/kafka-server-start.sh config/server.properties @b@[2019-03-17 12:27:43,910] INFO KafkaConfig values: @b@ request.timeout.ms = 30000@b@ log.roll.hours = 168@b@ inter.broker.protocol.version = 0.9.0.X@b@ log.preallocate = false@b@ security.inter.broker.protocol = PLAINTEXT@b@ controller.socket.timeout.ms = 30000@b@ broker.id.generation.enable = true@b@ ssl.keymanager.algorithm = SunX509@b@ ssl.key.password = null@b@ log.cleaner.enable = true@b@ ssl.provider = null@b@ num.recovery.threads.per.data.dir = 1@b@ background.threads = 10@b@ unclean.leader.election.enable = true@b@ sasl.kerberos.kinit.cmd = /usr/bin/kinit@b@ replica.lag.time.max.ms = 10000@b@ ssl.endpoint.identification.algorithm = null@b@ auto.create.topics.enable = true@b@ zookeeper.sync.time.ms = 2000@b@ ssl.client.auth = none@b@ ssl.keystore.password = null@b@ log.cleaner.io.buffer.load.factor = 0.9@b@ offsets.topic.compression.codec = 0@b@ log.retention.hours = 168@b@ log.dirs = /tmp/kafka-logs@b@ ssl.protocol = TLS@b@ log.index.size.max.bytes = 10485760@b@ sasl.kerberos.min.time.before.relogin = 60000@b@ log.retention.minutes = null@b@ connections.max.idle.ms = 600000@b@ ssl.trustmanager.algorithm = PKIX@b@ offsets.retention.minutes = 1440@b@ max.connections.per.ip = 2147483647@b@ replica.fetch.wait.max.ms = 500@b@ metrics.num.samples = 2@b@ port = 9092@b@ offsets.retention.check.interval.ms = 600000@b@ log.cleaner.dedupe.buffer.size = 134217728@b@ log.segment.bytes = 1073741824@b@ group.min.session.timeout.ms = 6000@b@ producer.purgatory.purge.interval.requests = 1000@b@ min.insync.replicas = 1@b@ ssl.truststore.password = null@b@ log.flush.scheduler.interval.ms = 9223372036854775807@b@ socket.receive.buffer.bytes = 102400@b@ leader.imbalance.per.broker.percentage = 10@b@ num.io.threads = 8@b@ zookeeper.connect = 192.168.1.199:2181@b@ queued.max.requests = 500@b@ offsets.topic.replication.factor = 3@b@ replica.socket.timeout.ms = 30000@b@ offsets.topic.segment.bytes = 104857600@b@ replica.high.watermark.checkpoint.interval.ms = 5000@b@ broker.id = 0@b@ ssl.keystore.location = null@b@ listeners = PLAINTEXT://:9092@b@ log.flush.interval.messages = 9223372036854775807@b@ principal.builder.class = class org.apache.kafka.common.security.auth.DefaultPrincipalBuilder@b@ log.retention.ms = null@b@ offsets.commit.required.acks = -1@b@ sasl.kerberos.principal.to.local.rules = [DEFAULT]@b@ group.max.session.timeout.ms = 30000@b@ num.replica.fetchers = 1@b@ advertised.listeners = null@b@ replica.socket.receive.buffer.bytes = 65536@b@ delete.topic.enable = false@b@ log.index.interval.bytes = 4096@b@ metric.reporters = []@b@ compression.type = producer@b@ log.cleanup.policy = delete@b@ controlled.shutdown.max.retries = 3@b@ log.cleaner.threads = 1@b@ quota.window.size.seconds = 1@b@ zookeeper.connection.timeout.ms = 6000@b@ offsets.load.buffer.size = 5242880@b@ zookeeper.session.timeout.ms = 6000@b@ ssl.cipher.suites = null@b@ authorizer.class.name = @b@ sasl.kerberos.ticket.renew.jitter = 0.05@b@ sasl.kerberos.service.name = null@b@ controlled.shutdown.enable = true@b@ offsets.topic.num.partitions = 50@b@ quota.window.num = 11@b@ message.max.bytes = 1000012@b@ log.cleaner.backoff.ms = 15000@b@ log.roll.jitter.hours = 0@b@ log.retention.check.interval.ms = 300000@b@ replica.fetch.max.bytes = 1048576@b@ log.cleaner.delete.retention.ms = 86400000@b@ fetch.purgatory.purge.interval.requests = 1000@b@ log.cleaner.min.cleanable.ratio = 0.5@b@ offsets.commit.timeout.ms = 5000@b@ zookeeper.set.acl = false@b@ log.retention.bytes = -1@b@ offset.metadata.max.bytes = 4096@b@ leader.imbalance.check.interval.seconds = 300@b@ quota.consumer.default = 9223372036854775807@b@ log.roll.jitter.ms = null@b@ reserved.broker.max.id = 1000@b@ replica.fetch.backoff.ms = 1000@b@ advertised.host.name = null@b@ quota.producer.default = 9223372036854775807@b@ log.cleaner.io.buffer.size = 524288@b@ controlled.shutdown.retry.backoff.ms = 5000@b@ log.dir = /tmp/kafka-logs@b@ log.flush.offset.checkpoint.interval.ms = 60000@b@ log.segment.delete.delay.ms = 60000@b@ num.partitions = 1@b@ num.network.threads = 3@b@ socket.request.max.bytes = 104857600@b@ sasl.kerberos.ticket.renew.window.factor = 0.8@b@ log.roll.ms = null@b@ ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]@b@ socket.send.buffer.bytes = 102400@b@ log.flush.interval.ms = null@b@ ssl.truststore.location = null@b@ log.cleaner.io.max.bytes.per.second = 1.7976931348623157E308@b@ default.replication.factor = 1@b@ metrics.sample.window.ms = 30000@b@ auto.leader.rebalance.enable = true@b@ host.name = @b@ ssl.truststore.type = JKS@b@ advertised.port = null@b@ max.connections.per.ip.overrides = @b@ replica.fetch.min.bytes = 1@b@ ssl.keystore.type = JKS@b@ (kafka.server.KafkaConfig)@b@[2019-03-17 12:27:43,960] INFO starting (kafka.server.KafkaServer)@b@[2019-03-17 12:27:43,963] INFO Connecting to zookeeper on 192.168.1.199:2181 (kafka.server.KafkaServer)@b@[2019-03-17 12:27:43,972] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)@b@[2019-03-17 12:27:43,977] INFO Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:host.name=localhost (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.version=1.7.0_80 (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.home=/home/app/jdk7/jre (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.class.path=:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-http-9.2.12.v20150709.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javax.ws.rs-api-2.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javax.inject-1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/connect-file-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/validation-api-1.1.0.Final.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/connect-json-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/zookeeper-3.4.6.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javassist-3.18.1-GA.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-annotations-2.5.0.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/slf4j-log4j12-1.7.6.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-client-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-container-servlet-core-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka_2.11-0.9.0.1-test.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-jaxrs-json-provider-2.5.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jopt-simple-3.2.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-guava-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-module-jaxb-annotations-2.5.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-media-jaxb-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-core-2.5.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka_2.11-0.9.0.1-sources.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javax.inject-2.4.0-b31.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/connect-api-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/hk2-utils-2.4.0-b31.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-security-9.2.12.v20150709.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/zkclient-0.7.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka_2.11-0.9.0.1-javadoc.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/hk2-api-2.4.0-b31.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/scala-parser-combinators_2.11-1.0.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-io-9.2.12.v20150709.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javax.annotation-api-1.2.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/lz4-1.2.0.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-databind-2.5.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jackson-jaxrs-base-2.5.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/argparse4j-0.5.0.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-server-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/scala-library-2.11.7.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-server-9.2.12.v20150709.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/slf4j-api-1.7.6.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-container-servlet-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka-clients-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka-tools-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/osgi-resource-locator-1.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/log4j-1.2.17.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka-log4j-appender-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka_2.11-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-util-9.2.12.v20150709.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/kafka_2.11-0.9.0.1-scaladoc.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/snappy-java-1.1.1.7.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/metrics-core-2.2.0.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/hk2-locator-2.4.0-b31.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/javax.servlet-api-3.1.0.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/aopalliance-repackaged-2.4.0-b31.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/connect-runtime-0.9.0.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jersey-common-2.22.1.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/scala-xml_2.11-1.0.4.jar:/home/soft/kafka_2.11-0.9.0.1/bin/../libs/jetty-servlet-9.2.12.v20150709.jar (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:os.version=2.6.32-573.el6.x86_64 (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,977] INFO Client environment:user.dir=/home/soft/kafka_2.11-0.9.0.1 (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,978] INFO Initiating client connection, connectString=192.168.1.199:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@5b35f282 (org.apache.zookeeper.ZooKeeper)@b@[2019-03-17 12:27:43,988] INFO Waiting for keeper state SyncConnected (org.I0Itec.zkclient.ZkClient)@b@[2019-03-17 12:27:43,990] INFO Opening socket connection to server 192.168.1.199/192.168.1.199:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)@b@[2019-03-17 12:27:43,993] INFO Socket connection established to 192.168.1.199/192.168.1.199:2181, initiating session (org.apache.zookeeper.ClientCnxn)@b@[2019-03-17 12:27:44,001] INFO Session establishment complete on server 192.168.1.199/192.168.1.199:2181, sessionid = 0x1698bd640b00003, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)@b@[2019-03-17 12:27:44,003] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)@b@[2019-03-17 12:27:44,039] INFO Loading logs. (kafka.log.LogManager)@b@[2019-03-17 12:27:44,044] INFO Logs loading complete. (kafka.log.LogManager)@b@[2019-03-17 12:27:44,077] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)@b@[2019-03-17 12:27:44,079] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)@b@[2019-03-17 12:27:44,111] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)@b@[2019-03-17 12:27:44,114] INFO [Socket Server on Broker 0], Started 1 acceptor threads (kafka.network.SocketServer)@b@[2019-03-17 12:27:44,128] INFO [ExpirationReaper-0], Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)@b@[2019-03-17 12:27:44,129] INFO [ExpirationReaper-0], Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)@b@[2019-03-17 12:27:44,178] INFO Creating /controller (is it secure? false) (kafka.utils.ZKCheckedEphemeral)@b@[2019-03-17 12:27:44,184] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)@b@[2019-03-17 12:27:44,184] INFO 0 successfully elected as leader (kafka.server.ZookeeperLeaderElector)@b@[2019-03-17 12:27:44,250] INFO [GroupCoordinator 0]: Starting up. (kafka.coordinator.GroupCoordinator)@b@[2019-03-17 12:27:44,254] INFO [ExpirationReaper-0], Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)@b@[2019-03-17 12:27:44,274] INFO [ExpirationReaper-0], Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)@b@[2019-03-17 12:27:44,274] INFO [GroupCoordinator 0]: Startup complete. (kafka.coordinator.GroupCoordinator)@b@[2019-03-17 12:27:44,293] INFO [Group Metadata Manager on Broker 0]: Removed 0 expired offsets in 41 milliseconds. (kafka.coordinator.GroupMetadataManager)@b@[2019-03-17 12:27:44,301] INFO [ThrottledRequestReaper-Produce], Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)@b@[2019-03-17 12:27:44,302] INFO [ThrottledRequestReaper-Fetch], Starting (kafka.server.ClientQuotaManager$ThrottledRequestReaper)@b@[2019-03-17 12:27:44,309] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)@b@[2019-03-17 12:27:44,324] INFO Creating /brokers/ids/0 (is it secure? false) (kafka.utils.ZKCheckedEphemeral)@b@[2019-03-17 12:27:44,328] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)@b@[2019-03-17 12:27:44,329] INFO Registered broker 0 at path /brokers/ids/0 with addresses: PLAINTEXT -> EndPoint(localhost,9092,PLAINTEXT) (kafka.utils.ZkUtils)@b@[2019-03-17 12:27:44,348] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)@b@[2019-03-17 12:27:44,367] INFO Kafka version : 0.9.0.1 (org.apache.kafka.common.utils.AppInfoParser)@b@[2019-03-17 12:27:44,367] INFO Kafka commitId : 23c69d62a0cabf06 (org.apache.kafka.common.utils.AppInfoParser)@b@[2019-03-17 12:27:44,367] INFO [Kafka Server 0], started (kafka.server.KafkaServer)