Mongo Java Driver Not able to connect to replica set - mongodb

when connection using mongo db driver with replica set it is giving warning that connecting to localhost as below mentioned. any idea why ?
Dec 21, 2013 2:47:49 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: localhost/127.0.0.1:10001 - java.io.IOException - message: couldn't connect to [localhost/127.0.0.1:10001] bc:java.net.ConnectException: Connection refused: connect
Dec 21, 2013 2:47:50 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: localhost/127.0.0.1:10003 - java.io.IOException - message: couldn't connect to [localhost/127.0.0.1:10003] bc:java.net.ConnectException: Connection refused: connect
Dec 21, 2013 2:47:52 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: localhost/127.0.0.1:10001 - java.io.IOException - message: couldn't connect to [localhost/127.0.0.1:10001] bc:java.net.ConnectException: Connection refused: connect
Dec 21, 2013 2:47:53 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: localhost/127.0.0.1:10003 - java.io.IOException - message: couldn't connect to [localhost/127.0.0.1:10003] bc:java.net.ConnectException: Connection refused: connect
Dec 21, 2013 2:47:54 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: localhost/127.0.0.1:10002 - java.io.IOException - message: couldn't connect to [localhost/127.0.0.1:10002] bc:java.net.ConnectException: Connection refused: connect
Exception in thread "main" com.mongodb.MongoException: can't find a master
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:514)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:174)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:155)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:249)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:205)
at com.mongodb.DBCollection.insert(DBCollection.java:57)
at com.mongodb.DBCollection.insert(DBCollection.java:100)
at mongo.Test.main(Test.java:33)

Related

couldn't connect to server 127.0.0.1:27017 while trying to start mongodb

After typing mongo
It is showing
MongoDB shell version v5.0.13
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
Also, the MongoDB campus showing connect ECONNREFUSED 127.0.0.1:27017
For mongosh
Current Mongosh Log ID: 6341cd406845432d371fc4b3
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
Mongod Service also not starting
root#jahid:/home/jahid# sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-10-09 12:48:22 +06; 9min ago
Docs: https://docs.mongodb.org/manual
Main PID: 28523 (code=exited, status=14)
Oct 09 12:48:21 jahid systemd[1]: Started MongoDB Database Server.
Oct 09 12:48:22 jahid systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Oct 09 12:48:22 jahid systemd[1]: mongod.service: Failed with result 'exit-code'.

I am not connecting to server 127.0.0.1:27017

lipon#lipon-K43U:/$ mongo
MongoDB shell version: 2.2.0
connecting to: test
Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed
lipon#lipon-K43U:/$

How do I connect to Exasol from Scala?

I want to connect to ExaSol database using Scala. I'm able to connect to the database in Python using pyodbc but I'm receiving the following error on attempting to connect using JDBC driver in Scala :
scala> :require /Users/some/path/mssql-jdbc-7.4.0.jre8.jar
scala> Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
scala> import java.sql.{Connection, DriverManager, ResultSet}
scala> val conn = DriverManager.getConnection("jdbc:sqlserver://11.11.11.11:8563;databaseName=some-db;user=user_name;password=pass_word;useUnicode=true;characterEncoding=UTF-8")
Sep 11, 2019 1:38:55 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: a03dede8-7f9c-495d-83d5-4986b859e1e9 Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
Sep 11, 2019 1:38:55 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: ea705538-c0c9-4bc3-ba66-9630e7850b58 Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
Sep 11, 2019 1:39:09 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: 5238ac7c-55cc-4ec2-a070-d7f454c6c43b Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 11.11.11.11, port 8563 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2005 or later.". ClientConnectionId:5238ac7c-55cc-4ec2-a070-d7f454c6c43b
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2924)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2913)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:2655)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2480)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2142)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1993)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1164)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:760)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
... 28 elided
Please try to use the "com.exasol.jdbc.EXADriver" driver.
The documentation is in the below url:
https://docs.exasol.com/connect_exasol/drivers/jdbc.htm

SASL authentication failed using login context 'Client'

I am working in securing Kafka with Kerberos in CDH 5.5
Kafka version: 2.0.1
Kerberos is enabled and works fine
when i enable sasl in kafka using cloudera maneger, i get the error:
Jun 29, 3:02:42.875 PM INFO org.apache.zookeeper.ClientCnxn
Opening socket connection to server brahim.localhost/127.0.0.1:2181. Will attempt to SASL-authenticate using Login Context section 'Client'
Jun 29, 3:02:42.879 PM INFO org.apache.zookeeper.ClientCnxn
Socket connection established to brahim.localhost/127.0.0.1:2181, initiating session
Jun 29, 3:02:42.906 PM INFO org.apache.zookeeper.ClientCnxn
Session establishment complete on server brahim.localhost/127.0.0.1:2181, sessionid = 0x1559c20b6110007, negotiated timeout = 30000
Jun 29, 3:02:42.910 PM INFO org.I0Itec.zkclient.ZkClient
zookeeper state changed (SyncConnected)
Jun 29, 3:02:42.942 PM ERROR org.apache.zookeeper.client.ZooKeeperSaslClient
SASL authentication failed using login context 'Client'.
Jun 29, 3:02:42.942 PM INFO org.I0Itec.zkclient.ZkClient
zookeeper state changed (AuthFailed)
Jun 29, 3:02:48.551 PM INFO org.I0Itec.zkclient.ZkEventThread
Terminate ZkClient event thread.
Jun 29, 3:02:48.554 PM FATAL kafka.Kafka$
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1223)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:155)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:129)
at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:80)
at kafka.utils.ZkUtils$.apply(ZkUtils.scala:62)
at nl.techop.kafka.dao.zookeeper.KafkaZkClient.(KafkaZkClient.scala:52)
at nl.techop.kafka.KafkaHttpMetricsServer.init(KafkaHttpMetricsServer.scala:43)
at nl.techop.kafka.KafkaHttpMetricsServer.(KafkaHttpMetricsServer.scala:28)
at nl.techop.kafka.KafkaHttpMetricsReporter.init(KafkaHttpMetricsReporter.scala:41)
at kafka.metrics.KafkaMetricsReporter$$anonfun$startReporters$1.apply(KafkaMetricsReporter.scala:60)
at kafka.metrics.KafkaMetricsReporter$$anonfun$startReporters$1.apply(KafkaMetricsReporter.scala:58)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:35)
at kafka.metrics.KafkaMetricsReporter$.startReporters(KafkaMetricsReporter.scala:58)
at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:27)
at kafka.Kafka$.main(Kafka.scala:58)
at com.cloudera.kafka.wrap.Kafka$.main(Kafka.scala:76)
at com.cloudera.kafka.wrap.Kafka.main(Kafka.scala)
Regenerating keytabs for zookeeper and kafka solved my problem

error during mongo db.shutdownServer()

I got the following error when I try to shutdown mongodb in my VM Ubuntu.
I am running 12.10 Ubuntu headless server.
The current Mongodb Shell Version is 2.0.6
use admin
switched to db admin
> db.shutdownServer()
Tue Dec 10 14:17:03 DBClientCursor::init call() failed
Tue Dec 10 14:17:03 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1
server should be down...
Tue Dec 10 14:17:03 trying reconnect to 127.0.0.1
Tue Dec 10 14:17:03 reconnect 127.0.0.1 ok
Tue Dec 10 14:17:03 Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
Tue Dec 10 14:17:03 SocketException: remote: 127.0.0.1:27017 error: 9001 socket exception [1] server [127.0.0.1:27017]
Tue Dec 10 14:17:03 DBClientCursor::init call() failed
Tue Dec 10 14:17:03 query failed : admin.$cmd { getlasterror: 1.0, w: 1.0 } to: 127.0.0.1
Tue Dec 10 14:17:03 Error: error doing query: failed shell/collection.js:151
What should I do?
My reason for trying to shut it down is because I want to update to mongo 2.2.
Please advise.
Although the messaging is confusing, this is actually expected behaviour if you shutdown via the mongo shell. Since you ran the db.shutdownServer() command through the mongo shell it can no longer connect to the server and this is essentially indicating the shell has been disconnected.
The mongo shell tries to automatically reconnect when you hit enter, which results in the messages like "trying to reconnect ...".
There is an open issue to improve this behaviour/messaging if you'd like to upvote/watch it: SERVER-5467.