1. 下载二进制版本
http://kafka.apache.org/downloads.html
kafka_2.10-0.10.0.1.tgz 解压到 /home/deploy/tar/kafka_2.10-0.10.0.1
2. 启动
./bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
./bin/kafka-server-start.sh -daemon config/server.properties
3. 安装librdkafka
https://github.com/edenhill/librdkafka git clone https://github.com/edenhill/librdkafka.git
./configure
make
make install
4. 安装php-rdkafka
https://github.com/arnaud-lb/php-rdkafka
$ git clone https://github.com/arnaud-lb/php-rdkafka.git $ cd php-rdkafka $ # For PHP 7, checkout the php7 branch: $ # git checkout php7 $ phpize $ ./configure $ make all -j 5 $ sudo make install
5. 配置扩展环境
https://arnaud-lb.github.io/php-rdkafka/phpdoc/rdkafka.installation.manual.html
下午发现kafka启动没有成功,看了下启动脚本,因为jmx服务的原因。注释掉bin/kafka-run-class.sh 下的这几行就ok,已经测试ok了,邮件记录一下。
# JMX settings #if [ -z “$KAFKA_JMX_OPTS” ]; then # KAFKA_JMX_OPTS=”-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false “ #fi
# JMX port to use #if [ $JMX_PORT ]; then # KAFKA_JMX_OPTS=”$KAFKA_JMX_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT “ #fi
另外,kafka需要java环境环境,如果发现没有安装java,需要安装下
1. apt-get install software-properties-common
2. apt-get install default-jre.
代码语言:javascript复制$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk
多个jdk切换方法 首先我们看下系统已经安装的或在用的JDK
$ update-java-alternatives -l java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64 现在安装jdk8之后变成 $ update-java-alternatives -l java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64 java-1.8.0-openjdk-amd64 1069 /usr/lib/jvm/java-1.8.0-openjdk-amd64 下面我们用“update-alternatives –config java” 指令切换默认jdk
$ sudo update-alternatives –config java There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ———————————————————— 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode * 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode Press enter to keep the current choice[*], or type selection number: 选择你要使用的JDK:比如1然后回车java就ok了,同上方法将javac、javap、javadoc更换即可: $ sudo update-alternatives –config javac $ sudo update-alternatives –config javap $ sudo update-alternatives –config javadoc