企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
1、部署kafka 部署机器HDSS7-11.host.com 下载安装包 ``` cd /opt/src wget https://archive.apache.org/dist/kafka/2.2.0/kafka_2.12-2.2.0.tgz tar xf kafka_2.12-2.2.0.tgz -C /opt/ ln -s /opt/kafka_2.12-2.2.0/ /opt/kafka cd /opt/kafka ``` 修改配置 ``` mkdir /data/kafka/logs -p cat >config/server.properties <<'EOF' log.dirs=/data/kafka/logs zookeeper.connect=localhost:2181 log.flush.interval.messages=10000 log.flush.interval.ms=1000 delete.topic.enable=true host.name=hdss7-11.host.com EOF ``` 启动kafka ``` bin/kafka-server-start.sh -daemon config/server.properties ]# netstat -luntp|grep 9092 tcp6 0 0 10.4.7.11:9092 :::* LISTEN 34240/java ``` 2、部署kafka-manager 运维主机`HDSS7-200.host.com`上 方法一 通过dockerfile获取 ``` cat >/data/dockerfile/kafka-manager/Dockerfile <<'EOF' FROM hseeberger/scala-sbt ENV ZK_HOSTS=10.4.7.11:2181 \ KM_VERSION=2.0.0.2 RUN mkdir -p /tmp && \ cd /tmp && \ wget https://github.com/yahoo/kafka-manager/archive/${KM_VERSION}.tar.gz && \ tar xxf ${KM_VERSION}.tar.gz && \ cd /tmp/kafka-manager-${KM_VERSION} && \ sbt clean dist && \ unzip -d / ./target/universal/kafka-manager-${KM_VERSION}.zip && \ rm -fr /tmp/${KM_VERSION} /tmp/kafka-manager-${KM_VERSION} WORKDIR /kafka-manager-${KM_VERSION} EXPOSE 9000 ENTRYPOINT ["./bin/kafka-manager","-Dconfig.file=conf/application.conf"] EOF ``` 制作docker镜像 ``` cd /data/dockerfile/kafka-manager docker build . -t harbor.od.com/infra/kafka-manager:v2.0.0.2 ``` 方法二:直接下载docker镜像 ``` docker pull sheepkiller/kafka-manager:latest docker images|grep kafka-manager docker tag 4e4a8c5dabab harbor.zq.com/infra/kafka-manager:latest docker push harbor.zq.com/infra/kafka-manager:latest ``` 部署kafka-manager ``` mkdir /data/k8s-yaml/kafka-manager cd /data/k8s-yaml/kafka-manager ``` 准备资源配置清单 准备dp清单 ``` cat >deployment.yaml <<'EOF' kind: Deployment apiVersion: extensions/v1beta1 metadata: name: kafka-manager namespace: infra labels: name: kafka-manager spec: replicas: 1 selector: matchLabels: name: kafka-manager template: metadata: labels: app: kafka-manager name: kafka-manager spec: containers: - name: kafka-manager image: harbor.zq.com/infra/kafka-manager:latest ports: - containerPort: 9000 protocol: TCP env: - name: ZK_HOSTS value: zk1.od.com:2181 - name: APPLICATION_SECRET value: letmein imagePullPolicy: IfNotPresent imagePullSecrets: - name: harbor restartPolicy: Always terminationGracePeriodSeconds: 30 securityContext: runAsUser: 0 schedulerName: default-scheduler strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 revisionHistoryLimit: 7 progressDeadlineSeconds: 600 EOF ``` 准备svc资源清单 ``` cat >service.yaml <<'EOF' kind: Service apiVersion: v1 metadata: name: kafka-manager namespace: infra spec: ports: - protocol: TCP port: 9000 targetPort: 9000 selector: app: kafka-manager EOF ``` 准备ingress资源清单 ``` cat >ingress.yaml <<'EOF' kind: Ingress apiVersion: extensions/v1beta1 metadata: name: kafka-manager namespace: infra spec: rules: - host: km.zq.com http: paths: - path: / backend: serviceName: kafka-manager servicePort: 9000 EOF ``` 应用资源配置清单 ``` kubectl apply -f http://k8s-yaml.od.com/kafka-manager/deployment.yaml kubectl apply -f http://k8s-yaml.od.com/kafka-manager/service.yaml kubectl apply -f http://k8s-yaml.od.com/kafka-manager/ingress.yaml ``` 解析域名`HDSS7-11.host.com`上 ``` vim /var/named/zq.com.zone km A 10.4.7.10 systemctl restart named dig -t A km.od.com @10.4.7.11 +short 10.4.7.10 ``` 浏览器访问:http://km.zq.com 添加集群 ![](https://img.kancloud.cn/0b/7a/0b7ac3abb905e6c868987e1518c8895d_765x554.png) ![](https://img.kancloud.cn/39/5a/395a883458de27804f1b9595b543eb4a_890x548.png)