1. 目录规划
目录 | 存放地址说明 | 备注 |
---|---|---|
/application | 应用安装目录 | |
/mnt/tool | 软件存放目录 | |
##关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
#关闭selinux
##修改文件打开数
cat <<EOF>>/etc/systemd/system.conf
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
EOF
cat <<EOF>>/etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
* soft nproc 4096
* hard nproc 4096
EOF
1.1 zookeeper 集群部署
JDK 的安装
export JAVA_HOME=/home/application/jdk1.8.0_121/
export JRE_HOME=/home/application/jdk1.8.0_121/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
vim /application/apache-zookeeper-3.8.0-bin/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/application/data/zookeeper
dataLogDir=/home/application/data/zookeeper/logs
clientPort=2181
server.1=192.168.101.65:2887:3887
server.2=192.168.101.66:2887:3887
server.3=192.168.101.67:2887:3887
autopurge.purgeInterval=1
autopurge.snapRetainCount=5
####以下单独执行
##192.168.101.65执行
echo "1" > /home/application/data/zookeeper/myid
##192.168.101.66执行
echo "2" > /home/application/data/zookeeper/myid
##192.168.101.67执行
echo "3" > /home/application/data/zookeeper/myid
vim /home/application/apache-zookeeper-3.8.0-bin/bin/zkEnv.sh
##添加JDK 的目录
JAVA_HOME="/home/application/jdk1.8.0_121/"
配置启动文件
vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper Server Service
After=network.target
[Service]
Type=forking
UMask=0027
User=root
Group=root
ExecStart=/home/application/apache-zookeeper-3.8.0-bin/bin/zkServer.sh start
ExecStop=/home/application/apache-zookeeper-3.8.0-bin/bin/zkServer.sh stop
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
#启动
systemctl start zookeeper
#netstat -lntp
1.2 kafka 集群的部署
tar xvf kafka_2.12-2.4.1.tgz -C /home/application/
cd /home/application/kafka_2.12-2.4.1/
vim server.properties
broker.id=1 # 其他节点不一样,修改配置然后启动
listeners=PLAINTEXT://192.168.101.67:9092
num.network.threads=9
num.io.threads=16
socket.send.buffer.bytes=1024000
socket.receive.buffer.bytes=1024000
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=30
num.recovery.threads.per.data.dir=1
log.retention.hours=24
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.101.65:2181,192.168.101.66:2181,192.168.101.67:2181
zookeeper.connection.timeout.ms=6000
delete.topic.enable = true
auto.create.topics.enable=true
message.max.bytes=20000000
replica.fetch.max.bytes=20485760
acks=1
log.cleanup.policy=delete
启动
/home/application/kafka_2.12-2.4.1/bin/kafka-server-start.sh -daemon /home/application/kafka_2.12-2.4.1/config/server.properties &