首页 > 代码库 > [Hadoop][Kafka]
[Hadoop][Kafka]
tar -C /opt -xf /tmp/kafka_2.12-0.10.2.1.tar
ln -s /opt/kafka_2.12-0.10.2.1 /opt/kafka
# 创建组和用户
groupadd kafka
useradd -g kafka kafka -s /sbin/nologin
# 文件存放目录
mkdir -p /mnt/kafka/data
mkdir -p /var/log/kafka
chown kafka:kafka -R /mnt/kafka/data
chown kafka:kafka -R /var/log/kafka
chown kafka:kafka -R /opt/kafka_2.12-0.10.2.1
chown kafka:kafka -R /opt/kafka
#修改配置文件
sed -i ‘s/broker.id=0/broker.id=1/‘ /opt/kafka/config/server.properties
sed -i ‘s/log.dirs=\/tmp\/kafka-logs/log.dirs=\/var\/log\/kafka/‘ /opt/kafka/config/server.properties
sed -i ‘s/zookeeper.connect=localhost:2181/zookeeper.connect=zookeeper01:2181,zookeeper02:2181,zookeeper03:2181/‘ /opt/kafka/config/server.properties
#systemd开机配置
cat <<EOF | tee /usr/lib/systemd/system/kafka.service
[Unit]
Description=Kafka
After=network.target
#After=zookeeper.service
[Service]
Type=forking
Restart=on-failure
ExecStart=/opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties
User=kafka
Group=kafka
[Install]
WantedBy=multi-user.target
EOF
systemctl enable kafka
systemctl start kafka
[Hadoop][Kafka]