解决:本地Kafka和Druid的Zookeeper端口冲突问题

2023-05-16

主要是完成本地的Kafka和Druid搭建过程中,出现的Cannot start up because port 2181 is already in use.问题

问题原因:使用brew安装的的Druid也是自带zookeeper的,所以在单机部署的时候会和brew安装的Kafka的zookeeper端口2181冲突,如果两个一起启动,那就就需要修改Druid或者Kafka中的zookeeper端口为2182了

方法1:从执行逻辑上修改

/usr/local/Cellar/apache-druid-0.20.0/bin> ./start-micro-quickstart
Cannot start up because port 2181 is already in use.

If you need to change your ports away from the defaults, check out the
configuration documentation:

  https://druid.apache.org/docs/latest/configuration/index.html

If you believe this check is in error, or if you have changed your ports away
from the defaults, you can skip this check using an environment variable:

  export DRUID_SKIP_PORT_CHECK=1

直接启动会报错,这里提示端口被占用了,直接扫执行文件

/usr/local/Cellar/apache-druid-0.20.0/bin> cat start-micro-quickstart
#!/bin/bash -eu

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

PWD="$(pwd)"
WHEREAMI="$(dirname "$0")"
WHEREAMI="$(cd "$WHEREAMI" && pwd)"

exec "$WHEREAMI/supervise" -c "$WHEREAMI/../conf/supervise/single-server/micro-quickstart.conf"

看到显示加载的conf文件是micro-quickstart.conf,直接查看该conf文件

/usr/local/Cellar/apache-druid-0.20.0/conf/supervise/single-server> cat micro-quickstart.conf
:verify bin/verify-java
:verify bin/verify-default-ports
:kill-timeout 10

!p10 zk bin/run-zk conf
coordinator-overlord bin/run-druid coordinator-overlord conf/druid/single-server/micro-quickstart
broker bin/run-druid broker conf/druid/single-server/micro-quickstart
router bin/run-druid router conf/druid/single-server/micro-quickstart
historical bin/run-druid historical conf/druid/single-server/micro-quickstart
!p90 middleManager bin/run-druid middleManager conf/druid/single-server/micro-quickstart

发现先去端口验证verify bin/verify-default-ports,然后执行in/run-zk conf,先查看bin/verify-default-ports

/usr/local/Cellar/apache-druid-0.20.0/bin> cat verify-default-ports
#!/usr/bin/env perl

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

use strict;
use warnings;
use Socket;

sub try_bind {
  my ($port, $addr) = @_;

  socket(my $sock, PF_INET, SOCK_STREAM, Socket::IPPROTO_TCP) or die "socket: $!";
  setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die "setsockopt: $!";
  if (!bind($sock, sockaddr_in($port, $addr))) {
    print STDERR <<"EOT";
Cannot start up because port $port is already in use~~.

If you need to change your ports away from the defaults, check out the
configuration documentation:

  https://druid.apache.org/docs/latest/configuration/index.html

If you believe this check is in error, or if you have changed your ports away
from the defaults, you can skip this check using an environment variable:

  export DRUID_SKIP_PORT_CHECK=1

EOT
    exit 1;
  }
  shutdown($sock, 2);
}

my $skip_var = $ENV{'DRUID_SKIP_PORT_CHECK'};
if ($skip_var && $skip_var ne "0" && $skip_var ne "false" && $skip_var ne "f") {
  exit 0;
}

my @ports = @ARGV;
if (!@ports) {
  @ports = (2181, 1527, 8081, 8082, 8083, 8090, 8091, 8100, 8200, 8888);
}

for my $port (@ports) {
  try_bind($port, INADDR_ANY);
  try_bind($port, inet_aton("127.0.0.1"));
}

可以看到这里先扫描端口,对于它要使用的端口机型遍历,如果有人占用端口了,直接抛出错误,且不在执行后续的启动,这里吧@port里面的2181改成20182即可;然后再去run-zk conf查看

/usr/local/Cellar/apache-druid-0.20.0> cd bin
/usr/local/Cellar/apache-druid-0.20.0/bin> cat run-zk
#!/bin/bash -eu

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

if [ "$#" -gt 1 ]
then
  >&2 echo "usage: $0 [conf-dir]"
  exit 1
fi

PWD="$(pwd)"
WHEREAMI="$(dirname "$0")"

if [ "$#" -lt 1 ] || [ "x$1" = "x" ]
then
  CONFDIR="$WHEREAMI"/../conf
else
  CONFDIR="$1"
fi

CONFDIR="$(cd "$CONFDIR" && pwd)/zk"
WHEREAMI="$(cd "$WHEREAMI" && pwd)"
JAVA_BIN="$(source "$WHEREAMI"/java-util && get_java_bin_dir)"
if [ -z "$JAVA_BIN" ]; then
  >&2 echo "Could not find java - please run $WHEREAMI/verify-java to confirm it is installed."
  exit 1
fi

cd "$WHEREAMI/.."
exec "$JAVA_BIN"/java `cat "$CONFDIR"/jvm.config | xargs` \
  -cp "$WHEREAMI/../lib/*:$CONFDIR" \
  -Dzookeeper.jmx.log4j.disable=true \
  org.apache.zookeeper.server.quorum.QuorumPeerMain \
  "$CONFDIR"/zoo.cfg

继续定位到加载了zoo.cfg文件

/usr/local/Cellar/apache-druid-0.20.0/conf/zk> cat zoo.cfg
#
# Server
#

tickTime=2000
dataDir=var/zk
clientPort=2181
initLimit=5
syncLimit=2

#
# Autopurge
#

autopurge.snapRetainCount=5
autopurge.purgeInterval=1

ok,找到2181端口的使用,修改clientPort=2182

方法2:直接暴力搜索使用2181的文件

如果使用方法2,需要在全项目范围内找,如果只是找conf文件夹,会遗漏端口校验的文件

/usr/local/Cellar/apache-druid-0.20.0> find ./ -type f | xargs grep -ri "2181"
.//bin/verify-default-ports:  @ports = (2181,1527, 8081, 8082, 8083, 8090, 8091, 8100, 8200, 8888);

.//var/sv/middleManager.log:2020-12-08T10:39:12,658 INFO [main-

...

.//conf/zk/zoo.cfg:clientPort=2181

显而易见,需要修改以上两个文件中的端口;修改完之后,/usr/local/Cellar/apache-druid-0.20.0/bin> ./start-micro-quickstart启动,http://localhost:8888/起来了;然后按照Tutorial的例子,直接加载Kafka的数据就好了

相关

  • Druid-quick-start:https://druid.apache.org/docs/latest/tutorials/index.html
  • Druid- Load streaming data from Apache Kafka:https://druid.apache.org/docs/latest/tutorials/tutorial-kafka.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决:本地Kafka和Druid的Zookeeper端口冲突问题 的相关文章

  • 对一个整数进行因式分解,求出所有质因数

    1 题目描述 给定一个正整数N xff0c 对N进行质因数分解 xff0c 求解N的所有质因数 2 解题思路 xff08 1 xff09 2 是很特殊的 xff0c 必须单独列出 xff08 2 xff09 必须先判断是否质数 因为如果是质
  • Windows10下安装Ubuntu18.04LTS详细教程

    这篇文章分享自己在Windows10系统下安装VMware虚拟机 xff0c 然后在VMware中安装Ubuntu 18 04 LTS的详细过程 之所以选择在虚拟机中安装Ubuntu xff0c 主要是可以不影响自己电脑的正常使用 xff0
  • 我的2011 写给小白

    许久前就想写这篇日志了 xff0c 但是一直以各种理由搪塞着 xff0c 没空闲 xff0c 再加上该死的期末考试 xff0c 唉 xff0c 真是愁煞人也 xff0c 现在好了 xff0c 什么都完事了 xff0c 也淡定了 xff0c
  • Pixhawk的历史

    发展历程 xff1a APM gt PX4FMU IO gt Pixhawk xff1a 1 Arduino简介 Arduino就是主要以以AVR单片机为核心控制器的单片机应用开发板 xff08 当然也有其他核心的例如STM32版本的但是不
  • 姿态解算基础:欧拉角、方向余弦、四元数

    什么是姿态解算 xff1a 飞行器的姿态解算过程涉及到两个坐标系 xff0c 一个是运载体的机体坐标系 xff0c 该坐标系与运载体固连 xff0c 当运载体转动的时候 xff0c 这个坐标系也跟着转动 xff0c 我们假设运载体的坐标系为
  • 姿态解算进阶:互补滤波(陀螺仪、加速度计、地磁计数据融合)

    互补滤波原理 xff1a 在四轴入门理论知识那节我们说 xff0c 加速度计和磁传感器都是极易受外部干扰的传感器 xff0c 都只能得到2维的角度关系 xff0c 但是测量值随时间的变化相对较小 xff0c 结合加速度计和磁传感器可以得到3
  • C++实现线程池

    本文转载自 xff1a https blog csdn net caoshangpa article details 80374651 1 为什么需要线程池技术 目前的大多数网络服务器 xff0c 包括Web服务器 Email服务器以及数据
  • 详解coredump

    1 什么是coredump xff1a 2 开启或关闭core文件的生成 xff1a 3 core文件的存储位置和文件名 xff1a 4 造成程序core的原因 xff08 参考 xff09 xff1a 5 用GDB调试coredump x
  • C++中二进制、字符串、十六进制、十进制之间的转换

    1 十进制和二进制相互转换 2 字符串和二进制相互转换 3 字符串和十进制相互转换 4 十进制和十六进制相互转换 5 二进制和十六进制 1 十进制和二进制相互转换 xff08 1 xff09 十进制转二进制 int a 61 10 bits
  • 解决 docker: Invalid containerPort: 5000 .

    复制粘贴的命令报这个错误 xff0c 结果手敲了一下就好了 可能就是 v 那里字符有点问题 xff0c 或者多个空格之类的 看了下其他人说的解决办法 xff0c 说也有可能是大写字母的问题 学习不要图省事 xff0c 真的 xff01
  • linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方法

    一 首先了解Linux系统下这两个命令的区别 yum xff1a 属于 xff1a RedHat系列 常见系统有 xff1a Redhat Centos Fedora等 apt get xff1a 属于 xff1a Debian系列 常见系
  • OpenCV矩形检测

    点击我爱计算机视觉标星 xff0c 更快获取CVML新技术 今天在52CV交流群里有朋友问到矩形检测的问题 xff0c 恰好前几天做了一个与此相关的项目 xff0c 调研了一下相关的算法 xff08 期间被某带bug的开源代码坑了很久 xf
  • 修改树莓派系统的虚拟内存大小(SWAP)

    树莓派默认的虚拟内存大小才100M xff0c 有时候我们需要扩大它 xff0c 树莓派的虚拟内存配置文件和debian默认的位置不一样 xff0c 所以这里我们修改的是 etc dphys swapfile sudo nano etc d
  • Python爬虫—request模块与验证码识别

    相关文章链接 xff1a Python爬虫 爬虫基础简介 Python爬虫 数据解析及案例 xff08 4K图片爬取 xff09 一 request模块 1 1 概念 python中原生的一种基于网络请求的模块 xff0c 功能非常强大 x
  • 学习 ROS 机器人没有前途?!

    点击蓝字 关注我们 本文转载自蓝桥云课合作作者 xff1a 机器马 xff0c 文末有小惊喜哦 01 ROS 是什么 机器人操作系统 xff08 ROS xff09 是一种用于编写机器人软件的灵活框架 它是工具 xff0c 库和协议的集合
  • 运维必学的监控系统——Prometheus,大牛免费直播带你入门~

    关注 实验楼 xff0c 每天分享一个项目教程 实验1小时 明晚开启 xff0c 腾讯大牛天火老师带你入门Promentheus xff08 普罗米修斯 xff09 这一当下超火的监控系统 提到监控系统 xff0c 人们往往会想到Zabbi
  • VINS-Mono代码阅读笔记(十一):进入pose_graph节点代码分析

    本篇笔记紧接着上一篇VINS Mono代码阅读笔记 xff08 十 xff09 xff1a vins estimator中的非线性优化 xff0c 来接着学习VINS Mono系统中重定位和全局优化部部分的代码 这部分代码在pose gra
  • ROS中插件plugin的简单使用方法

    插件 xff0c 如同其名字一样 xff0c 第一次接触的时候让我想到了U盘或者USB线这类东西 xff0c 它们和电脑没有关系 xff0c 但是插入 xff08 挂载 xff09 电脑USB口后却可以正常使用 xff0c 仿佛扩展了电脑的
  • ROS中的roslaunch命令和launch文件(ROS入门学习笔记四)

    ROS中的基本对象和概念学习笔记 ROS入门学习笔记一 ROS中创建工作区和包 ROS入门学习笔记二 ROS功能包中CMakeLists txt的说明 ROS入门学习笔记三 1 roslaunch命令 我们知道 xff0c rosrun命令
  • 嵌入式软件面试题整理

    基础试题 1 用预处理指令 define 声明一个常数 xff0c 用以表明1年中有多少秒 xff08 忽略闰年问 define SECONDS PER YEAR 60 60 24 365 UL 说明 xff1a define 语法的基本知

随机推荐

  • 硬件在环仿真(HiL)测试介绍

    一 HiL是什么 xff1f 硬件在环仿真 xff08 Hardware in the Loop xff0c 简称HIL xff09 是真 的控制器连接假 的被控对象 xff0c 以一种高效低成本的方式对控制器进行全面测试 它是一种用于复杂
  • Docker Dockerfile详解

    dockerfike快速创建自定义的Docker镜像 一 目录 1 docker典型结构 2 指令介绍 3 创建docker镜像 二 结构 DockerFile分为四部分组成 xff1a 基础镜像信 维护者信息 镜像操作指令和容器启动时执行
  • 树莓派3B+(Raspberry Pi 3 Model B+)安装Ubuntu MATE 18.04及简单配置

    树莓派3B 43 安装Ubuntu MATE 18 04及简单配置 安装Ubuntu18 04 MATE下载Ubuntu 18 04 MATE准备Raspberry Pi Imager镜像烧录工具开机启动 简单配置设置root密码更新列表配
  • OpenCV之getOptimalNewCameraMatrix

    去畸变后的图像四周会出现黑色区域 xff0c 如果畸变较大 xff0c 如鱼眼镜头 xff0c 四周黑色区域将会更大 opencv中给我们提供了一个函数getOptimalNewCameraMatrix xff0c 用于去除畸变矫正后图像四
  • 【深度学习小常识】什么是mAP?

    目录 一 mAP相关概念 1 正例与负例 2 P xff08 精确率 xff09 3 R xff08 召回率 xff09 4 ACC xff08 准确率 xff09 5 AP xff08 平均精确度 xff09 6 示例 二 mAP 1 m
  • STM32CubeMX 下载和安装 详细教程

    HAL库 STM32CubeMX开发 STM32F407 目录 STM32CubeMX安装包 Win 6 6 1 下载链接 STM32CubeMX 下载 步骤1 xff1a 点击官网链接下载 官网下载地址 xff1a https www s
  • Keil5----跳转定义和查找功能

    一 Keil5 跳转定义 跳转定义 鼠标左键点击要查找的变量 方法1 xff1a 点击鼠标右键 xff0c 功能栏中有跳转定义的选项 方法2 xff1a 按快捷键 F12 具体操作如下图所示 xff1a 跳转结果 二 Keil5 查找功能
  • 使用WIFI模块AT指令进行MQTT协议通信

    劢领系列模组 xff0c 经过1年多的演化后 xff0c 已存在多套标准的固件程序 如果用户需要使用MQTT方式进行通信 xff0c 则需要选择标准AT指令 43 MQTT的版本 此版本不仅可以支持标准AT指令的SOCKET通信 xff0c
  • ActiveMQ配置wss

    最近把前端页面由原来的http升级为了https xff0c 发现之前ActiveMQ提供的ws不能强求了 xff0c https服务下要求升级到wss 全网搜索了下 xff0c 没有找到一个靠谱的文档 一 证书准备 使用wss连接服务必须
  • stm32使用HAL库快速编写智能寻迹避障小车(附代码)

    最近学校安排了一节用stm32编写寻迹避障小车的课 xff0c 但无奈学校老师教的方法让作者觉得无法理解 xff0c 但课程答辩时间快到了 xff0c 组内小组成员又做的磕磕绊绊 xff0c 于是身为组长的我就决定尝试一下用刚学的cubem
  • [hal库]使用 CubeMX 快速生成 FreeRTOS 系统并实现多任务处理

    由于项目需求 xff0c 需要使用FREERTOS搭载轻量系统 xff0c 因此写此博客给大家提供一个快速搭建RTOS系统的方法 xff0c 通过cubemx快速生成 以下内容包括 xff1a FreeRTOS 简介 程序框图所需要的元器件
  • Windows C/C++ CLion 开发环境搭建

    博文目录 文章目录 IDE CLion安装设置MinGW 插件测试 特殊配置 使用 CLion 开发 C 43 43 CUDA 应用注意不要走如下弯路 IDE CLion 安装 官网 官方全版本下载 CLion 2021 2 3 exe 或
  • git常见报错解决办法,fatal: the remote end hung up unexpectedly

    问题一 xff1a 上传GIT项目报fatal the remote end hung up unexpectedly错误 上传项目报fatal the remote end hung up unexpectedly的错误 xff0c 应该
  • AtCoder从小白到大神的进阶攻略

    摘自https www cnblogs com LHYLHY p 11572011 html 在此对作者表示感谢 AtCoder从小白到大神的进阶攻略 前言 现在全球最大的编程比赛记分网站非CodeForces和AtCoder莫属了 xff
  • 2020java面试总结

    博主背景 xff1a 92年生 xff0c 渣本毕业 xff0c java岗 xff0c 经验接近6年 xff0c base上海 本文宗旨 xff1a 本文旨在将博主最近的面试经历分享给大家 xff0c 并作些总结 xff0c 尽量为在准备
  • odroid上mavros指定版本安装

    mavros 安装 指定版本 xff1a 0 16 0 https github com mavlink mavros 以下是可能出现的错误 error1 can t find mavlinkConfig cmake solution ht
  • FreeRTOS源码解析 -> vTaskDelete()

    vTaskDelete API 函数 任务可以使用API函数vTaskDelete 删除自己或其它任务 任务被删除后就不复存在 xff0c 也不会再进入运行态 空闲任务的责任是要将分配给已删除任务的内存释放掉 因此有一点很重要 xff0c
  • 设置华为交换机使用账号密码方式进行SSH登录

    1 创建rsa本地密钥对与创建账号 Huawei rsa local key pair create The key name will be Huawei Host The range of public key size is 512
  • java中反射有什么作用?

    前言 反射blog有很多 xff0c 不再赘述 xff0c 但是反射的作用具体实现场景就会比较少 xff0c 这里举个例子 一个需求 使用参数的方式传入需要执行的类名 xff0c 然后执行相应类的同名方法 普通的实现方法 静态加载 因为需要
  • 解决:本地Kafka和Druid的Zookeeper端口冲突问题

    主要是完成本地的Kafka和Druid搭建过程中 xff0c 出现的Cannot start up because port 2181 is already in use 问题 问题原因 xff1a 使用brew安装的的Druid也是自带z