How do I use runit with zookeeper - apache-zookeeper

How do I use runit with zookeeper? Its running but I get those nasty logs.....
Here is my run file
more /etc/sv/zookeeper/run
#!/bin/sh
exec 2>&1
exec /var/chef/cache/zookeeper-3.4.5/bin/zkServer.sh start >> /tmp/zookeeper.log 2>&1
below is the tail of my log file
tail -f zookeeper.log
Using config: /var/chef/cache/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 32701.
JMX enabled by default
Using config: /var/chef/cache/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 32701.
JMX enabled by default
Using config: /var/chef/cache/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 32701.
JMX enabled by default
Using config: /var/chef/cache/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 32701.
JMX enabled by default
Using config: /var/chef/cache/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 32701.

From the look of it, zookeeper is already running in your system. Or there is a lock file which didn't get deleted due to an unclean shutdown. Check using zkServer.sh status to see if it is running properly.

Related

Kafka is failing to start. Getting the below error

ERROR Error while creating ephemeral at /brokers/ids/0, node already exists and owner '72067757872119809' does not match current session '72067836689711106' (kafka.zk.KafkaZkClient$CheckedEphemeral) 2021-05-05 02:19:44.796 [INF] [Kafka] [2021-05-05 02:19:44,786] ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
The error is saying a broker already is running with id=0, or that Zookeeper is corrupt because a broker did not previously cleanly shut down...
In the later case, you can attempt to use zookeeper-shell to rmr /brokers/ids/0, however, this might have more unintended consequences than preforming a restart of Zookeeper as well as the brokers
The only solution which works here is restart the broker and then restart the server.
Restart the zookeeper and the broker is fixed the issue for me.
If you using the docker-compose, you can restart simply by using
docker-compose restart

Can't start zookeeper server

i tried to start zookeeper with:
/opt/Kafka/kafka_2.10-0.10.0.1/bin/zookeeper-server-start.sh
/opt/Kafka/kafka_2.10-0.10.0.1/config/zookeeper.properties
but I got
ERROR Unexpected exception, exiting abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.net.BindException: Address already in use
I restarted the computer and I got the same problem
I tried netstat -nlp|grep 2181 the result:
tcp6 0 0 :::2181 :::* LISTEN
kill -9 2181 --> bash: kill: (2181) - No such process
./zookeeper-server-stop.sh # no result so it works but
./zookeeper-server-start.sh /opt/Kafka/kafka_2.10-0.10.0.1/config/zookeeper.properties # the same exception
what can I do?
Note: when starting kafka server there is no exception
kill -9 2181 --> bash: kill: (2181) - No such process
You're trying to kill a port number, not a process ID.
Address already in use
Okay, so you clearly already have something on that port.
Options:
Edit the zookeeper.properties to bind to a different port. Also edit kafka properties to use the new Zookeeper connection.
You already have a running Zookeeper, which would explain why Kafka would work when starting.
P.S. I would recommend using a later version of Kafka anyway. Lots of good upgrades.

Zookeeper install not working on windows 10

Well I have my JAVA_HOME set correctly. And I am getting this error now.
C:\projects\zookeeper\zk\bin>call "C:\Program Files\Java\jdk-9"\bin\java "-Dzookeeper.log.dir=C:\projects\zookeeper\zk\bin\..\logs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=zookeeper-User-server-HUNTER-PC.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "C:\projects\zookeeper\zk\bin\..\build\classes;C:\projects\zookeeper\zk\bin\..\build\lib\*;C:\projects\zookeeper\zk\bin\..\*;C:\projects\zookeeper\zk\bin\..\lib\*;C:\projects\zookeeper\zk\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "C:\projects\zookeeper\zk\bin\..\conf\zoo.cfg" start
2017-09-29 10:44:10,183 [myid:] - INFO [main:DatadirCleanupManager#78] - autopurge.snapRetainCount set to 3
2017-09-29 10:44:10,183 [myid:] - INFO [main:DatadirCleanupManager#79] - autopurge.purgeInterval set to 0
2017-09-29 10:44:10,183 [myid:] - INFO [main:DatadirCleanupManager#101] - Purge task is not scheduled.
2017-09-29 10:44:10,183 [myid:] - WARN [main:QuorumPeerMain#122] - Either no config or no quorum defined in config, running in standalone mode
2017-09-29 10:44:10,183 [myid:] - INFO [main:ManagedUtil#46] - Log4j found with jmx enabled.
2017-09-29 10:44:10,330 [myid:] - ERROR [main:ZooKeeperServerMain#64] - Invalid arguments, exiting abnormally
java.lang.NumberFormatException: For input string: "C:\projects\zookeeper\zk\bin\..\conf\zoo.cfg"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at org.apache.zookeeper.server.ServerConfig.parse(ServerConfig.java:61)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:101)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:62)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:125)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79)
2017-09-29 10:44:10,330 [myid:] - INFO [main:ZooKeeperServerMain#65] - Usage: ZooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]
Usage: ZooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]
C:\projects\zookeeper\zk\bin>endlocal
Here is my config file: zoo.cfg
tickTime=2000
dataDir=c:/projects/zookeeper/zk/
clientPort=2181
initLimit=5
syncLimit=2
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
I have changed the dataDir repeatedly to C:/tmp to /usr/
and making sure the directories are actually there. I am at a loss. I am running this on windows 10. I have the newest JDK 9 installed and the path is accurate.
Assuming that you've renamed the conf\zoo_sample.cfg file to conf\zoo.cfg and set the dataDir property correctly, which you've done already; use the following command to start the Zookeeper server
C:\zookeeper-3.4.12\bin>.\zkServer.cmd
Not the following
C:\zookeeper-3.4.12\bin>.\zkServer.cmd start
Okay so I figured out my own answer. Everything was installed correctly. But even running from Administrator mode command prompt, zookeeper was not working. I have to actually right click on the zkServer.cmd in the bin folder and say run as Administrator. I have had this issue before with SigWebTablet software. I think its an issue with running Windows10 developer. Others around the office have this issue with Windows. Hopefully this will help someone else.
In my case, running as Administrator didn't work. I needed a way to tell Zookeeper to setup three instances according to the 3 config files. What did work, was to edit the zkServer.cmd file and remove the "%ZOOCFG%"parameter from the line that begins wil call. Now I can run bin\zkServer.cmd conf\zoo.cfg, bin\zkServer.cmd conf\zoo2.cfg, and bin\zkServer.cmd conf\zoo3.cfg in three command prompt windows and get my cluster up and running :)

Can't start zookeeper

I'm using confluent platform, the zookeeper is active with status lookup. but when I try to start kafka with confluent it shows zookeeper is down.
$ sudo service zookeeper status
Redirecting to /bin/systemctl status zookeeper.service
● zookeeper.service - Zookeeper
Loaded: loaded (/etc/systemd/system/zookeeper.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2017-08-08 17:25:34 PDT; 16h ago
Docs: http://kafka.apache.org/documentation.html
Process: 3774 ExecStop=/var/www/confluent/bin/zookeeper-server-stop (code=exited, status=1/FAILURE)
Main PID: 3785 (java)
CGroup: /system.slice/zookeeper.service
└─3785 java -Xmx512M -Xms512M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Xloggc:/var/log...
zookeeper[3785]: [2017-08-08 17:26:09,005] INFO Processed session termination for sessionid: 0x15dc460fd0c0000 (org.apache.zooke...Processor)
zookeeper[3785]: [2017-08-08 17:26:39,000] INFO Expiring session 0x15dc4364baf0004, timeout of 60000ms exceeded (org.apache.zook...perServer)
zookeeper[3785]: [2017-08-08 17:26:39,000] INFO Expiring session 0x15dc4364baf0002, timeout of 60000ms exceeded (org.apache.zook...perServer)
zookeeper[3785]: [2017-08-08 17:26:39,000] INFO Expiring session 0x15dc4364baf0003, timeout of 60000ms exceeded (org.apache.zook...perServer)
zookeeper[3785]: [2017-08-08 17:26:39,001] INFO Processed session termination for sessionid: 0x15dc4364baf0004 (org.apache.zooke...Processor)
zookeeper[3785]: [2017-08-08 17:26:39,002] INFO Processed session termination for sessionid: 0x15dc4364baf0002 (org.apache.zooke...Processor)
zookeeper[3785]: [2017-08-08 17:26:39,002] INFO Processed session termination for sessionid: 0x15dc4364baf0003 (org.apache.zooke...Processor)
zookeeper[3785]: [2017-08-09 09:56:26,711] INFO Accepted socket connection from /127.0.0.1:46446 (org.apache.zookeeper.server.NI...xnFactory)
zookeeper[3785]: [2017-08-09 09:59:14,796] WARN Exception causing close of session 0x0 due to java.io.IOException: Len error -72...erverCnxn)
zookeeper[3785]: [2017-08-09 09:59:14,796] INFO Closed socket connection for client /127.0.0.1:46446 (no session established for...erverCnxn)
Hint: Some lines were ellipsized, use -l to show in full.
$ confluent start kafka
Starting zookeeper
|Zookeeper failed to start
zookeeper is [DOWN]
Cannot start Kafka, Zookeeper is not running. Check your deployment
This is because zookeeper is already running, you can check the process with
ps aux|grep zookeeper
and kill the process manually and it is gonna work.
The most common cause for the message you are seeing when running:
confluent start kafka
and informs you that zookeeper is down, is that there's another zookeeper instance that is currently running, and the new zookeeper instance can not bind to its required port (by default this port is 2181).
A few options at your disposal to figure out what's the other zookeeper instance that is currently running when you try to issue confluent start kafka are:
run jps to see the running java processes. Zookeeper is the process named QuorumPeerMain next to its process ID. (equivalent to running ps xuaww | grep -i zookeeper or equivalent).
run lsof -i :2181 to figure out what the process that is running and has reserved the default zookeeper port (in this example 2181, but might be different in your system).
Try running confluent start kafka again after stopping the above process.
I received the same message. In my case I didn't set $JAVA_HOME variable properly.
You are mixing two installations.
confluent start kafka would depend on you running confluent start zookeeper.
Rather, it seems you already have systemctl running Zookeeper, so you should ideally just configure your server.properties and use the regular kafka-server-start script. And/or create a systemctl file for Kafka.
run $ confluent log zookeeper you will be able to see the log for any errors
there is high chance zookeeper is already running and using the port 2181,
use $ sudo lsof -i :1-2181 to see which process is using that port and try to kill and try again or
run $ sudo netstat -plten | grep java to see processes and ports they are on.
run kill -9 <pid> to kill the process.

kafka Missing required configuration "zookeeper.connect" which has no default value

I setup kafka cluster in vm.
but i have a problem.
My kafka version is kafka 2.11-0.0.0
$ bin/kafka-server-start.sh config/zookeeper.properties
[2017-01-31 09:15:55,216] FATAL (kafka.Kafka$)
org.apache.kafka.common.config.ConfigException: Missing required configuration "zookeeper.connect" which has no default value.
at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:148)
at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:49)
at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:56)
at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:702)
at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:691)
at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
at kafka.Kafka$.main(Kafka.scala:58)
at kafka.Kafka.main(Kafka.scala)
please help me .
my zookeeper.properties (down)
zookeeper.properties
dataDir=/home/kafka01/zookeeper-data
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
initLimit=5
syncLimit=2
server.1=kafka01:2888:3888
server.2=kafka02:2888:3888
server.3=kafka03:2888:3888
server.properties
zookeeper.connect=kafka01:2181,kafka02:2181,kafka03:2181
what is the problem??
You are trying to start a kafka server but you are passing the wrong config file.
Usually you want to start a kafka server using the following command:
./kafka-server-start.sh ../config/server.properties
And is in this file where you specify the address of the zookeeper:
zookeeper.connect=kafka01:2181,kafka02:2181,kafka03:2181
The quickstart guide in the kafka official documentation is quite good, I recommend you to have a look at it. You can find it here.
You are trying to start kafka server with zookeeper config properties file and that's why you are getting the above error.
Use the commands below instead:
Zookeeper:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
Kafka:
.\bin\windows\kafka-server-start.bat .\config\server.properties
You stared the wrong script. It should be:
bin/zookeeper-server-start.sh config/zookeeper.properties
There are two ways you can start Kafka server:
Start the zookeeper server separately(on your local or another machine)
Start the zookeeper server which is embedded with Kafka server (kafka_2.12/libs/zookeeper-3.4.13.jar)
In first case:
I am assuming you have started the zookeeper server already and that is running on localhost:2181
So now you are good to start kafka server using following command
bin\windows\kafka-server-start.bat ..\..\config\server.properties
In server.properties file you have to tell Kafka server where is/are the zookeeper(s) running. Using property:
## zookeeper.connect=localhost:2181 [default]
zookeeper.connect=zk1:2181, zk2:2181, localhost:2181
In second case
Start the zookeeper first (embedded with the Kafka server)
bin\windows\zookeeper-server-start.bat ..\..\config\zookeeper.properties
Then, start the Kafka server:
bin\windows\kafka-server-start.bat ..\..\config\server.properties
This is the error because there is an issue with your command.
To start zookeeper run -
zookeeper-server-start.sh config/zookeeper.properties
To start server run -
kafka-server-start.sh config/zookeeper.properties
you need to start the zookeeper with
zookeeper-server-start.sh ~/kafka/config/zookeeper.properties
then you
need to start the kafka-server using
kafka-server-start.sh ~/kafka/config/server.properties
Now you kafka will run smoothly ....