No Brokers available when trying to connect to Kafka through Cloudera Data Science Workbench - apache-kafka

I am trying to implement the GitHub project (https://github.com/tomatoTomahto/CDH-Sensor-Analytics) on our internal Hadoop cluster via Cloudera Data Science Workbench.
On running the project on Cloudera Data Science Workbench, I get the error "No Brokers available" when trying to connect to Kafka through Python api KafkaProducer(bootstrap_servers='broker1:9092') [Code can be found in https://github.com/tomatoTomahto/CDH-Sensor-Analytics/blob/master/datagenerator/KafkaConnection.py].
I have authenticated using Kerberos. I have tried giving broker node without port number, and also as a list. But, nothing has worked so far.
Below is the stack trace.
NoBrokersAvailable: NoBrokersAvailable
NoBrokersAvailable Traceback (most recent call
last)
in engine
----> 1 dgen = DataGenerator(config)
/home/cdsw/datagenerator/DataGenerator.py in __init__(self, config)
39
40 self._kudu = KuduConnection(self._config['kudu_master'],
self._config['kudu_port'], spark)
---> 41 self._kafka =
KafkaConnection(self._config['kafka_brokers'],
self._config['kafka_topic'])
42
43 #self._kafka
/home/cdsw/datagenerator/KafkaConnection.py in __init__(self, brokers,
topic)
4 class KafkaConnection():
5 def __init__(self, brokers, topic):
----> 6 self._kafka_producer =
KafkaProducer(bootstrap_servers=brokers)
7 self._topic = topic
8
/home/cdsw/.local/lib/python3.6/site-packages/kafka/producer/kafka.py
in __init__(self, **configs)
333
334 client = KafkaClient(metrics=self._metrics,
metric_group_prefix='producer',
--> 335 **self.config)
336
337 # Get auto-discovered version from client if necessary
/home/cdsw/.local/lib/python3.6/site-packages/kafka/client_async.py in
__init__(self, **configs)
208 if self.config['api_version'] is None:
209 check_timeout =
self.config['api_version_auto_timeout_ms'] / 1000
--> 210 self.config['api_version'] =
self.check_version(timeout=check_timeout)
211
212 def _bootstrap(self, hosts):
/home/cdsw/.local/lib/python3.6/site-packages/kafka/client_async.py in
check_version(self, node_id, timeout, strict)
806 try_node = node_id or self.least_loaded_node()
807 if try_node is None:
--> 808 raise Errors.NoBrokersAvailable()
809 self._maybe_connect(try_node)
810 conn = self._conns[try_node]
NoBrokersAvailable: NoBrokersAvailable
I also tried connecting outside of workbench through CLI by having VPN connection. I got the same error.
Any pointers on what am I missing? Thanks in advance!

The first step is establishing whether the network route is open and the broker is up and listening on that port. After that you can check authentication, etc.
Did you try telnet <broker host> 9092?
You may need to explicitly set advertised.listeners in addition to listeners, I've occasionally seen a weird quirk with Java where it wasn't binding to the expected network interface (or at least the one I expected!) and I had to force it using advertised.listeners.

Related

gcloud error 500 on strapi deployment (EROFS: read-only file system, mkdir '/srv/.tmp' A )

I followed strap's guide to an google app engine deployment however when I pushed it to gcloud I get an error 500. It's on postgresql, Standard Environment. I don't know what other informations to include. Here's the error from gcloud.
2020-07-11T21:37:04.742759Z at DatabaseManager.initialize (/srv/node_modules/strapi-database/lib/database-manager.js:36:27) A
2020-07-11T21:37:04.742769Z at Strapi.load (/srv/node_modules/strapi/lib/Strapi.js:274:19) A
2020-07-11T21:55:09.103534Z GET 500 0 B 11.3 s Chrome 83 / I GET 500 0 B 11.3 s Chrome 83 5f0a353d00ff01946e3ca1b9ce0001737e736b756c70740001323032303037313174313635323139000100
2020-07-11T21:55:19.559829Z [2020-07-11T21:55:19.558Z] debug ⛔️ Server wasn't able to start properly. A
2020-07-11T21:55:19.562896Z [2020-07-11T21:55:19.562Z] error Error: EROFS: read-only file system, mkdir '/srv/.tmp' A
2020-07-11T21:55:19.562935Z at Object.mkdirSync (fs.js:757:3) A
2020-07-11T21:55:19.562956Z at _.forEach (/srv/node_modules/strapi-connector-bookshelf/lib/knex.js:152:16) A
2020-07-11T21:55:19.562972Z at /srv/node_modules/lodash/lodash.js:4925:15 A
2020-07-11T21:55:19.562987Z at baseForOwn (/srv/node_modules/lodash/lodash.js:2990:24) A
2020-07-11T21:55:19.563012Z at /srv/node_modules/lodash/lodash.js:4894:18 A
2020-07-11T21:55:19.563025Z at Function.forEach (/srv/node_modules/lodash/lodash.js:9368:14) A
2020-07-11T21:55:19.563034Z at module.exports.strapi (/srv/node_modules/strapi-connector-bookshelf/lib/knex.js:37:5) A
2020-07-11T21:55:19.563043Z at Object.initialize (/srv/node_modules/strapi-connector-bookshelf/lib/index.js:39:5) A
2020-07-11T21:55:19.563058Z at Object.initialize (/srv/node_modules/strapi-database/lib/connector-registry.js:30:25) A
2020-07-11T21:55:19.563071Z at DatabaseManager.initialize (/srv/node_modules/strapi-database/lib/database-manager.js:36:27) A
2020-07-11T21:55:19.563080Z at Strapi.load (/srv/node_modules/strapi/lib/Strapi.js:274:19) A
2020-07-11T21:55:20.688345Z GET 500 0 B 4.5 s Chrome 83 /favicon.ico I GET 500 0 B 4.5 s Chrome 83 5f0a354800ff0a80d9edd664c60001737e736b756c70740001323032303037313174313635323139000100
I tried launching it multiple times but same error. All of the postgresql information are correct as well. What is causing this?
Edit:
this is the instructions that I followed. https://strapi.io/documentation/v3.x/deployment/google-app-engine.html
I got up to deploy the project with gcloud app deploy

kafka streams - number of open file descriptors keeps going up

Our kafka streaming app keeps opening new file descriptors as long as they are new incoming messages without ever closing old ones. It eventually leads to exception. We've raised the limit of open fds to 65k but it doesn't seem to help.
Both Kafka broker and Kafka streams library is version 2.1
The error message that keeps showing up in the logs is:
org.apache.kafka.streams.processor.internals.StreamThread.run
StreamThread.java: 747
org.apache.kafka.streams.processor.internals.StreamThread.runLoop
StreamThread.java: 777
org.apache.kafka.streams.processor.internals.StreamThread.runOnce
StreamThread.java: 883
org.apache.kafka.streams.processor.internals.StreamThread.maybeCommit
StreamThread.java: 1029
org.apache.kafka.streams.processor.internals.TaskManager.commitAll
TaskManager.java: 405
org.apache.kafka.streams.processor.internals.AssignedTasks.commit
AssignedTasks.java: 346
org.apache.kafka.streams.processor.internals.StreamTask.commit
StreamTask.java: 431
org.apache.kafka.streams.processor.internals.StreamTask.commit
StreamTask.java: 443
org.apache.kafka.streams.processor.internals.StreamTask.flushState
StreamTask.java: 491
org.apache.kafka.streams.processor.internals.AbstractTask.flushState
AbstractTask.java: 204
org.apache.kafka.streams.processor.internals.ProcessorStateManager.flush
ProcessorStateManager.java: 217
org.apache.kafka.streams.state.internals.MeteredKeyValueStore.flush
MeteredKeyValueStore.java: 226
org.apache.kafka.streams.state.internals.WrappedStateStore$AbstractStateStore.flush
WrappedStateStore.java: 85
org.apache.kafka.streams.state.internals.RocksDBStore.flush
RocksDBStore.java: 388
org.apache.kafka.streams.state.internals.RocksDBStore.flushInternal
RocksDBStore.java: 395 org.rocksdb.RocksDB.flush RocksDB.java: 1743
org.rocksdb.RocksDB.flush RocksDB.java org.rocksdb.RocksDBException:
While open a file for appending:
/tmp/kafka-streams/s4l-notifications-test/5_1/rocksdb/main-store/002052.sst:
Too many open files status: #object[org.rocksdb.Status 0x1cca4c5c
"org.rocksdb.Status#1cca4c5c"]
org.apache.kafka.streams.errors.ProcessorStateException: Error while
executing flush from store main-store
Any ideas how to debug it?

pgbouncer free_servers - how to increase them

current setting of a pgbouncer server is the following - and what I don't understand is the 'free_servers' info given by the show lists command when connecting to pgbouncer. Is it a (soft or hard) limit on the number of connexion to the postgresql databases used with this instance of pgbouncer ?
configuration :
max_client_conn = 2048
default_pool_size = 1024
min_pool_size = 10
reserve_pool_size = 500
reserve_pool_timeout = 1
server_idle_timeout = 600
listen_backlog = 1024
show lists gives :
pgbouncer=# show lists ;
list | items
---------------+--------
databases | 6
pools | 3
free_clients | 185
used_clients | 15
free_servers | 70
used_servers | 30
it seems that there is a limit at 30 + 70 = 100 servers, but couldn't find it even review configuration values with show config, and documentation doesn't explicit which configuration to change / increase free_servers.
pgbouncer version : 1.7.2
EDIT :
I've just discover that, for a pool of 6 webservers configured to hit the same PG database, 3 of them can have 200 backend connexions (server connexion), and 3 of them can only make and maintain 100 connexions (as described in the first part). But, .. the configuration is exactly the same in pgbouncer configuration file, and the servers are cloned VM. The version of pgbouncer is also the same..
So far, I still haven't found documentation on internet where this limitation come from...
This data is just some internal information for PgBouncer.
Servers information is stored inside an array list data structure which is pre-allocated up to a certain size, in this case that is 100 slots. used_servers = 30, free_servers = 70 means there are 30 slots currently in used, and 70 slots free. PgBouncer will automatically increase the size of the list when it's full, hence there's no configuration for this.

Cloudera Manager add services failed with ArithmeticException

I've installed Cloudera Manager in a three-machine cluster. While I added CDH5 services (including Hive,Spark,Yarn...) to cluster, it then failed with "ArithmeticException: / by zero".
version: Cloudera Enterprise Data Hub Edition trail 5.4.5 (#5 built by jenkins on 20150728-0320 git: ...)
org.drools.runtime.rule.ConsequenceException:Exception executing consequence for rule "Compute hiveserver2_spark_executor_cores" in com.cloudera.cmf.rules: org.drools.RuntimeDroolsException: java.lang.ArithmeticException: / by zero
at DefaultConsequenceExceptionHandler.java line 39
in org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler handleException()
Last caused-by is:
Caused by: java.lang.ArithmeticException:/ by zero
at ComputationFunctions.java line 278
in com.cloudera.cmf.rules.ComputationFunctions calculateHiveSparkExecutorMemoryTotal()
1. ComputationFunctions.java line 278
in com.cloudera.cmf.rules.ComputationFunctions calculateHiveSparkExecutorMemoryTotal()
2. Rule_Compute_HiveServer2_executor_and_driver_memory_and_overehead_25364fb53f7d4bf08ec8a11bca01bcf8.java line 16
in com.cloudera.cmf.rules.Rule_Compute_HiveServer2_executor_and_driver_memory_and_overehead_25364fb53f7d4bf08ec8a11bca01bcf8 accumulateExpression1()
3. Rule_Compute_HiveServer2_executor_and_driver_memory_and_overehead_25364fb53f7d4bf08ec8a11bca01bcf8AccumulateExpression1Invoker.java line 31
in com.cloudera.cmf.rules.Rule_Compute_HiveServer2_executor_and_driver_memory_and_overehead_25364fb53f7d4bf08ec8a11bca01bcf8AccumulateExpression1Invoker evaluate()
4. JavaAccumulatorFunctionExecutor.java line 107
in org.drools.base.accumulators.JavaAccumulatorFunctionExecutor accumulate()
5. Accumulate.java line 173
in org.drools.rule.Accumulate accumulate()
......
Anybody help? Or tells me where these compiled class such as "Rule_Compute_HiveServer2_executor_and_driver_memory_and_overehead_25364fb53f7d4bf08ec8a11bca01bcf8.java" is placed. I attempt to replace this class with more debug message.
Many thanks,

MongoDB and Multiple C# Client Threads

I have a single primary instance of a MongoDB to connect to. I am using the C# driver (latest revision) to connect and utilise MongoDB.
My client application is multi-threaded whereby processes will run periodically at different intervals to produce reports. When more than one thread is running, and I call various functions on the driver (e.g server.DatabaseExists(...)), I am consistently met with an exception.
"The requested name is valid, but no data of the requested type was found"
at System.Net.Dns.GetAddrInfo(String name)
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at MongoDB.Driver.MongoServerAddress.ToIPEndPoint(AddressFamily addressFamily) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoServerAddress.cs:line 195
at MongoDB.Driver.MongoServerInstance.GetIPEndPoint() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoServerInstance.cs:line 339
at MongoDB.Driver.Internal.MongoConnection.Open() in C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 368
at MongoDB.Driver.Internal.MongoConnection.GetNetworkStream() in C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 574
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode, String databaseName) in C:\work\rstam\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 555
at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 295
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 253
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 141
at MongoDB.Driver.MongoDatabase.GetCollectionNames() in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 645
at MongoDB.Driver.MongoDatabase.CollectionExists(String collectionName) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 297
Running one thread does not cause this issue. I am of the understanding that MongoDB is thread-safe, so I am at loss to understand the cause and the remedy.
The only "solution" I've found was to recycle the Application Pool that's hosting my website\service calling the mongo client.