Linux|CentOS7 安装 kafka

安装 JDK JDK地址

[root@localhost ~]# rpm -qa | grep java [root@localhost ~]# rpm -qa | grep jdk [root@localhost ~]# rpm -qa | grep java | xargs rpm -e --nodeps#卸载老版本[root@localhost ~]# yum install java-1.8.0-openjdk* -y [root@localhost ~]# java -version #这里为了图方便使用了 yum 安装 JDK

安装 zookeeper zookeeper地址
[root@localhost ~]# ls anaconda-ks.cfgapache-zookeeper-3.8.0-bin-bin.tar.gz kafka_2.12-3.0.1.tgz[root@localhost ~]# tar -xf apache-zookeeper-3.8.0-bin-bin.tar.gz -C /usr/local/ [root@localhost local]# ls apache-zookeeper-3.8.0-bin-binbinetcgamesincludeliblib64libexecsbinsharesrc [root@localhost local]# cd apache-zookeeper-3.8.0-bin/[root@localhost local]# mv apache-zookeeper-3.8.0-bin/ zookeeper [root@localhost local]# ls binetcgamesincludeliblib64libexecsbinsharesrczookeeper//配置环境变量 [root@localhost ~]# echo 'export PATH=/usr/local/zookeeper/bin:$PATH' > /etc/profile.d/zookeeeper.sh [root@localhost ~]# source /etc/profile.d/zookeeeper.sh [root@localhost ~]# echo $PATH /usr/local/zookeeper/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin//修改配置文件 [root@localhost ~]# cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg[root@localhost ~]# vi /usr/local/zookeeper/conf/zoo.cfg dataDir=/usr/local/zookeeper/data#修改数据存放目录 dataLogDir=/usr/local/zookeeper/log#添加存放日志 pidfile=/var/run/zookeeper.pid[root@localhost ~]# mkdir /usr/local/zookeeper/data [root@localhost ~]# mkdir /usr/local/zookeeper/log//启动 [root@localhost ~]# /usr/local/zookeeper/bin/zkServer.shstart /usr/bin/java ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [root@localhost ~]# ss -anlt | grep 2181 LISTEN050*:2181*:*//设置自启动 [root@localhost ~]# cat > /usr/lib/systemd/system/zookeeper.service <

安装 kafka 【Linux|CentOS7 安装 kafka】kafka地址
[root@localhost ~]# tar -xf kafka_2.12-3.0.1.tgz-C /usr/local/ [root@localhost ~]# cd /usr/local/ [root@localhost local]# ls binetcgamesincludekafka_2.12-3.0.1liblib64libexecsbinsharesrczookeeper [root@localhost local]# mv kafka_2.12-3.0.1/ kafka[root@localhost ~]# vi /usr/local/kafka/config/server.properties # broker 的编号,如果集群中有多个 broker,则每个 broker 的编号需要设置的不同 broker.id=0 # 31 行 listeners=PLAINTEXT://192.168.129.250:9092 # 123 行,修改 zookeeper.connect 为自己的 IP:PORT zookeeper.connect=localhost:2181/kafka[root@localhost ~]# cat > /usr/lib/systemd/system/kafka.service <

    推荐阅读