1. http://blog.youkuaiyun.com/qq_19427739/article/details/51095463
java编译中出现了Exception in thread “main” java.lang.UnsupportedClassVersionError
起因:
StringBuilder不能赋值?不对,错误原因是因为下面报错的log:
搜了下答案,参考
百度知道:java编译中出现了Exception in thread “main” java.lang.UnsupportedClassVersionError
我打开cmd试了下,果然:
接下来,我卸载了所有jdk,然后重新装。
(ps:大家装jdk时候,jre不要装同一目录,否则覆盖了之后javac.exe就没了)
(ps:环境变量%JAVA_HOME%结尾不要加分号,不然其他相关引用后面就多了分号)
最后,花了一个小时…(都是泪)
终于可以开心的撸代码了
2. http://www.cnblogs.com/clonen/p/5284054.html
kafka集群中常见错误的解决方法:kafka.common.KafkaException: Should not set log end offset on partition
问题描述:kafka单台机器做集群操作是没有问题的,如果分布多台机器并且partitions或者备份的个数大于1都会报kafka.common.KafkaException: Should not set log end offset on partition 这个错误,如果使用kafka默认的日志等级,过不了几分钟错误日志就会把磁盘刷满,导致服务器down掉。
这个问题困扰了我几天,怎么搞都不行,开始以为是版本问题,升级到最新版本问题还是存在,后来在官方FQA中找到了一段描述,原文如下:
Why do I see error "Should not set log end offset on partition" in the broker log?
Typically, you will see errors like the following.
kafka.common.KafkaException: Should not set log end offset on partition [test,22]'s local replica 4
ERROR [ReplicaFetcherThread-0-6], Error for partition [test,22] to broker 6:class kafka.common.UnknownException(kafka.server.ReplicaFetcherThread)
A common problem is that more than one broker registered the same host/port in Zookeeper. As a result, the replica fetcher is confused when fetching data from the leader. To verify that, you can use a Zookeeper client shell to list the registration info of each broker. The Zookeeper path and the format of the broker registration is described in Kafka data structures in Zookeeper. You want to make sure that all the registered brokers have unique host/port.
这段内容的大意思是不允许在zookeeper上注册来自同一个主机+端口的brokers,开始我以为是同一台机器上挂了二个brokers的缘故,因为机器上我同时布署了solr与kafka,都用的同一个zookeeper服务,于是我把kafka的broker改成/chroot的方式,在zookeeper上加了一级节点:(原来的brokers写法:192.168.12.206:2181,192.168.12.208:2181,改为:192.168.12.206:2181,192.168.12.208:2181/kafka)
经测试还是一样的结果,我实在是没撤了,最后我又仔细看了一下错误日志,发现一个规律,都是在分区备份的时候发生的此错误,所以我就在想是不是服务器之间数据同步有问题。
接着我打开kafka的配置文件,逐一往下看,发现了host.name属性,我心中已经有一半相信是这个参数配置的问题,因为我没有启动这个参数,于是我把它改成实际的IP地址,如host.name=192.168.12.206,另一台也如是改,最后发现错误不报了,收发消息正常,于是我知道这个参数在默认不配置的时候,绑定的是当前主机127.0.0.1,所以集群中主机之间进行相互备份的时候通过127.0.0.1找不到主机了。
有二个方面的原因导致一直查不出问题,一是网上关于此问题的说明实在是少的可怜,有也都是千篇一律,查到的结果都一样,另一个原因是配置文件的注释让人误解,如host.name的注释:
# Hostname the broker will bind to. If not set, the server will bind to all interfaces
从字面意思理解不就是“如果不设置,服务器将绑定到所有接口”,所以我想应该不设置也不会有问题。
这么简单的问题,居然折腾了我几天,所以写出来,仅供参考。
1:[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
1111
22222
另外一个session有:<pre class="highlight" font-size:13px;padding:6px="" 10px;margin-top:0px;margin-bottom:10px;line-height:1.42857;color:#333333;word-break:break-all;background-color:#f8f8f8;border:1px="" solid="" #cccccc;border-radius:3px;"="" style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); font-size: 16px; background-color: rgb(255, 255, 255); box-sizing: border-box; overflow: auto;">[root@localhost bin]#bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic test
有报错:
[2016-10-09 15:36:41,877] ERROR Error when sending message to topic test with key: null, value: 4 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
解决方法:
Vi /usr/local/kafka1/config/server.properties
修改listeners=PLAINTEXT://10.33.97.111:9092
为:
listeners=PLAINTEXT://0.0.0.0:9092
问题即可解决!
但是又带来一 个问题,tomcat 日志文件里面狂报错!
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.kafka.common.network.Selector.poll(Selector.java:238)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:192)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:191)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:122)
at java.lang.Thread.run(Thread.java:745)
不得已又要找解决方法:
其实方法很简单,只要不用localhost,换成ip地址即可!
[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-producer.sh --broker-list 10.33.97.111:9092 --topic test
另外一个session:
[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-consumer.sh --zookeeper 10.33.97.111:2181 --from-beginning --topic test
为什么localhost不行,而ip地址可以,因为配置文件里面指定的是ip地址,而没使用localhost
提示:
解决方法:/etc/hosts中加入本地解析
<pre code_snippet_id="1627740" snippet_file_name="blog_20160329_9_653644" name="code" class="html" font-size:12px;padding:10px="" 20px;margin-top:20px;margin-bottom:20px;line-height:20px;color:#f8f8d4;word-break:break-all;background:#4a4a4a;border:none;border-radius:4px;font-stretch:normal;"="" style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box; overflow: auto;">10.10.11.89 kafka01