Export of a realm from a running keycloak docker container fails - docker

I am running keycloak v8.0.0 using docker compose file. I am persisting the data into a MySQL database which I am running locally.
version: '3'
services:
keycloak:
image: jboss/keycloak:8.0.0
ports:
- "9999:8080"
environment:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: <ADMIN_PASSWORD>
DB_VENDOR: mysql
DB_ADDR: <HOST>
DB_PORT: <PORT>
DB_USER: <USER>
DB_PASSWORD: <PASSWORD>
JDBC_PARAMS: "useSSL=false"
volumes:
- "./realms:/tmp"
I tried exporting a realm from the running docker container by using following command.
docker exec -it kc /opt/jboss/keycloak/bin/standalone.sh \
-Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=export \
-Dkeycloak.migration.provider=singleFile \
-Dkeycloak.migration.realmName=my_realm\
-Dkeycloak.migration.usersExportStrategy=REALM_FILE \
-Dkeycloak.migration.file=/tmp/my_realm-realm.json
Below is the stack trace of the error i am getting when I run the above command. When I am running the above command keycloak is not able to connect to database server i.e. MySQL in this case. How to specify database connection configuration in this scenario?
16:30:04,000 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 65) MSC000001: Failed to start service jboss.deployment.unit."keycloak-server.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."keycloak-server.war".undertow-deployment: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication()
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.keycloak.services.resources.KeycloakApplication()
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:164)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2784)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:364)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:277)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:89)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:119)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:585)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:556)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1504)
at io.undertow.servlet#2.0.26.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:598)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
at org.wildfly.extension.undertow#18.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
... 8 more
Caused by: java.lang.RuntimeException: Failed to connect to database
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:372)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lazyInit(LiquibaseDBLockProvider.java:65)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lambda$waitForLock$2(LiquibaseDBLockProvider.java:96)
at org.keycloak.keycloak-server-spi-private#8.0.0//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:682)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.waitForLock(LiquibaseDBLockProvider.java:94)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:178)
at org.keycloak.keycloak-server-spi-private#8.0.0//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:227)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:171)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.init(KeycloakApplication.java:162)
at org.keycloak.keycloak-services#8.0.0//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:143)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.jboss.resteasy.resteasy-jaxrs#3.9.0.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
... 31 more
Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:159)
at org.jboss.as.connector#18.0.0.Final//org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
at org.keycloak.keycloak-model-jpa#8.0.0//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.getConnection(DefaultJpaConnectionProviderFactory.java:366)
... 45 more
Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/KeycloakDS
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:690)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:440)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:151)
... 47 more
Caused by: javax.resource.ResourceException: IJ031084: Unable to create connection
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1328)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:632)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:604)
at org.jboss.ironjacamar.impl#1.4.17.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)
... 50 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 97 milliseconds ago. The last packet sent successfully to the server was 91 milliseconds ago.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:201)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4912)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1663)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
at org.jboss.ironjacamar.jdbcadapters#1.4.17.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 57 more
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at java.base/sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:169)
at java.base/sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:98)
at java.base/sun.security.ssl.TransportContext.kickstart(TransportContext.java:216)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:395)
at com.mysql.jdbc#5.1.46//com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:186)
... 73 more

The first solution did not work for me, so I had to investigate further. In my case, the reason was, that the DB_PORT environment variable was not added to the connection string, so keycloak tried to connect to the postgres DB under the dafault port 5432, as seen in this log:
11:29:10,185 ERROR [stderr] (ServerService Thread Pool -- 68) FINE: Connecting with URL: jdbc:postgresql://156149bb-0045-4086-b11a-1b55458b2a5f.blrv234f085n1l00bhrg.private.databases.appdomain.cloud/ibmclouddb?connectTimeout=30&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&loggerLevel=DEBUG
[...]
11:29:10,194 ERROR [stderr] (ServerService Thread Pool -- 68) FINE: Trying to establish a protocol version 3 connection to 156149bb-0045-4086-b11a-1b55458b2a5f.blrv234f085n1l00bhrg.private.databases.appdomain.cloud:5432
So I added the Port to the DB_ADDR variable and everything worked fine.

I got the same error today,and found is the JDBC_PARAMS format error;
so you can exec in the container,
docker exec -it kc bash
and modify the JDBC_PARAMS
# Append '?' in the beggining of the string if JDBC_PARAMS value isn't empty
export JDBC_PARAMS=$(echo ${JDBC_PARAMS} | sed '/^$/! s/^/?/')
Or redefine JDBC_PARAMS env
export JDBC_PARAMS='?connectTimeout=30&useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=UTF-8'
the key is prefix ? char
then exec
/opt/jboss/keycloak/bin/standalone.sh \
-Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=export \
-Dkeycloak.migration.provider=singleFile \
-Dkeycloak.migration.realmName=my_realm\
-Dkeycloak.migration.usersExportStrategy=REALM_FILE \
-Dkeycloak.migration.file=/tmp/my_realm-realm.json
everything is OK!

Related

Is there any steps to configure android-cts latest version 13 on docker?

Android CTS Failed with exception [ANDROID_PARTNER_SERVER_ERROR|500505|DEPENDENCY_ISSUE] in docker container.
Able to run the same cts on linux PC, but not from docker container.
Linux PC is Ubuntu 20.04
Configured android-cts[Android Compatibility Test Suite 13_r2 (9265165)]
on ubuntu docker image with all the basic requirement like java[jdk 11], sdk[adb[1.0.41],aapt] etc.
container network configuration is same as host [ used --network=host] with same proxy.
Executed [export JAVA_TOOL_OPTIONS='-Djava.net.useSystemProxies=true'] as running behind firewall.
To start the container: docker run -it --network host -v /var/run/docker.sock:/var/run/docker.sock ubuntu:20.04
Failed with exception
[ANDROID_PARTNER_SERVER_ERROR|500505|DEPENDENCY_ISSUE].
Traceback: 01-18 07:50:43 E/TestInvocation: Trying to access android partner remote server over internet but failed: Connection timed out (Connection timed out) com.android.tradefed.targetprep.TargetSetupError[**ANDROID_PARTNER_SERVER_ERROR|500505|DEPENDENCY_ISSUE**]: Trying to access android partner remote server over internet but failed: Connection timed out (Connection timed out) at com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher.resolveUrl(DynamicConfigPusher.java:282) at com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher.setUp(DynamicConfigPusher.java:155) at com.android.tradefed.invoker.InvocationExecution.runPreparationOnDevice(InvocationExecution.java:534) at com.android.tradefed.invoker.InvocationExecution.runPreparersSetup(InvocationExecution.java:436) at com.android.tradefed.invoker.InvocationExecution.doSetup(InvocationExecution.java:296) at com.android.tradefed.invoker.TestInvocation.prepareAndRun(TestInvocation.java:583) at com.android.tradefed.invoker.TestInvocation.performInvocation(TestInvocation.java:273) at com.android.tradefed.invoker.TestInvocation.invoke(TestInvocation.java:1308) at com.android.tradefed.command.CommandScheduler$InvocationThread.run(CommandScheduler.java:639) Caused by: java.net.ConnectException: Connection timed out (Connection timed out) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:609) at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:299) at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173) at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474) at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569) at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266) at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:203) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187) at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081) at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:189) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250) at java.base/java.net.URL.openStream(URL.java:1165) at com.android.compatibility.common.tradefed.targetprep.DynamicConfigPusher.resolveUrl(DynamicConfigPusher.java:279) ... 8 more 01-18 07:50:43 I/CommandInterrupter: Interrupt blocked
please let me know, if am missing anything.

how to run Kafka command in gitlab CI/CD pipeline?

I am new to GitLab and Kafka and do not have more ideas on how to run the Kafka command using shell script through the GitLab CI/CD pipeline.
Following configuration I am using to achieve this but getting exceptions, is there anything I am missing or configured incorrectly? Please suggest
In .gitlab-ci.yml
run_kafka:
image: confluentinc/cp-kafka
script :
- . demo.sh
In demo.sh
kafka-consumer-groups --command-config ./config.properties --bootstrap-server "pkc-6ojv2.us-west4.gcp.confluent.cloud:9092" --group my-created-consumer-group --topic SampleTopic --reset-offsets --to-current
In config.properties
bootstrap.servers=pkc-confluent.cloud:9092
ssl.endpoint.identification.algorithm=https
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="" password="";
exception getting when pipeline is running
Error: Executing consumer group command failed due to org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: describeGroups(api=FIND_COORDINATOR)
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: describeGroups(api=FIND_COORDINATOR)
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:165)
at kafka.admin.ConsumerGroupCommand$ConsumerGroupService.$anonfun$resetOffsets$1(ConsumerGroupCommand.scala:434)
at scala.collection.IterableOnceOps.foldLeft(IterableOnce.scala:675)
at scala.collection.IterableOnceOps.foldLeft$(IterableOnce.scala:669)
at scala.collection.AbstractIterable.foldLeft(Iterable.scala:933)
at kafka.admin.ConsumerGroupCommand$ConsumerGroupService.resetOffsets(ConsumerGroupCommand.scala:432)
at kafka.admin.ConsumerGroupCommand$.run(ConsumerGroupCommand.scala:76)
at kafka.admin.ConsumerGroupCommand$.main(ConsumerGroupCommand.scala:59)
at kafka.admin.ConsumerGroupCommand.main(ConsumerGroupCommand.scala)
Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: describeGroups(api=FIND_COORDINATOR)

JMX_exporter shows error in Prometheus & Grafana

I have used JMX exporter to monitor Java application deployed based on jetty .
I have downloaded the jmx_prometheus_javaagent-0.1.0.jar file
Deployed the java application with jmx_exporter command
nohup java -javaagent:./jmx_prometheus_javaagent-0.1.0.jar=7101:config.yaml -Dorg.eclipse.jetty.server.Request.maxFormContentSize=10000000 -Xms256m -Xmx256m -Djava.io.tmpdir=epoch_temp_dir -jar jetty-runner-9.0.7.v20131107.jar --log yyyy_mm_dd-java-application-1-request.log --out yyyy_mm_dd-java-application-1-output.log --port 8091 --path /java-application-1 java-app1.war >> java-application-1.log 2>&1 &
config.yaml
#cat config.yaml
---
startDelaySeconds: 0
jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:7101/jmxrmi
ssl: false
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: ".*"
Prometheus shows connection timed out in status page
output log : of the java application deployed
io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector collect
SEVERE: JMX scrape failed: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error du
ring JRMP connection establishment; nested exception is:
java.net.SocketTimeoutException: Read timed out]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxScraper.doScrape(JmxScraper.java:106)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.collect(JmxCollector.java:415)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:180)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:213)
at io.prometheus.jmx.shaded.io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:134)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer$HTTPMetricHandler.handle(HTTPServer.java:59)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketTimeoutException: Read timed out]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:136)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1955)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1922)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
... 17 more
Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketTimeoutException: Read timed out
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:304)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
Opened the 7101 ports in the client server and grant access to Prometheus server.
Prometheus Server RAM usage:
# free -h
total used free shared buff/cache available
Mem: 4.8G 1.9G 118M 256M 2.8G 2.3G
Swap: 0B 0B 0B
Client server RAM :
# free -h
total used free shared buff/cache available
Mem: 9.8G 3.7G 435M 16M 5.6G 5.7G
Swap: 0B 0B 0B
Curl localhost:7101 in the client server is not responding
Remove the jmxUrl from the config, that's not required for agent use.

neo4j-shell Connection refused java.rmi.ConnectException

I correctly start server:
~/Downloads/neo4j-community-3.2.1/bin $ ./neo4j start Active database:
graph.db Directories in use: home:
/home/user/Downloads/neo4j-community-3.2.1 config:
/home/user/Downloads/neo4j-community-3.2.1/conf logs:
/home/user/Downloads/neo4j-community-3.2.1/logs plugins:
/home/user/Downloads/neo4j-community-3.2.1/plugins import:
/home/user/Downloads/neo4j-community-3.2.1/import data:
/home/user/Downloads/neo4j-community-3.2.1/data certificates:
/home/user/Downloads/neo4j-community-3.2.1/certificates run:
/home/user/Downloads/neo4j-community-3.2.1/run Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended.
See the Neo4j manual. Started neo4j (pid 29246). It is available at
http://localhost:7474/ There may be a short delay until the server is
ready. See /home/user/Downloads/neo4j-community-3.2.1/logs/neo4j.log
for current status.
then when I try to launch the neo4j-shell:
~/Downloads/neo4j-community-3.2.1/bin $ ./neo4j-shell -v ERROR (-v for expanded information): Connection
refused java.rmi.ConnectException: Connection refused to host:
localhost; nested exception is: java.net.ConnectException:
Connection refused at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342) at
sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at
java.rmi.Naming.lookup(Naming.java:101) at
org.neo4j.shell.impl.RmiLocation.getBoundObject(RmiLocation.java:191)
at
org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:72)
at org.neo4j.shell.impl.RemoteClient.(RemoteClient.java:65) at
org.neo4j.shell.impl.RemoteClient.(RemoteClient.java:46) at
org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:204) at
org.neo4j.shell.StartClient.startRemote(StartClient.java:358) at
org.neo4j.shell.StartClient.start(StartClient.java:229) at
org.neo4j.shell.StartClient.main(StartClient.java:147) Caused by:
java.net.ConnectException: Connection refused at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at
java.net.Socket.connect(Socket.java:589) at
java.net.Socket.connect(Socket.java:538) at
java.net.Socket.(Socket.java:434) at
java.net.Socket.(Socket.java:211) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 13 more
-host Domain name or IP of host to connect to (default:
localhost) -port Port of host to connect to (default: 1337)
-name RMI name, i.e. rmi://:/ (default: shell) -pid Process ID to connect to -c Command line to execute. After executing it the shell exits -file File
containing commands to execute, or '-' to read from stdin. After
executing it the shell exits -readonly Connect in readonly mode
(only for connecting with -path) -path Points to a neo4j db path
so that a local server can be started there -config Points to a
config file when starting a local server
Example arguments for remote: -port 1337 -host 192.168.1.234 -port
1337 -name shell -host localhost -readonly ...or no arguments for
default values Example arguments for local: -path /path/to/db -path
/path/to/db -config /path/to/neo4j.config -path /path/to/db -readonly
the server is in its default initial configuration, the only thing I changed is the graph username and password.
neo4j-shell is deprecated since version 3.1, you should use cypher-shell instead.
But you can enable it by adding this configuration : dbms.shell.enabled=true
Cheers.

Not able to connect to cassandra from host machine

I have configured a cassandra node on my mac book pro using docker as follows
VBoxManage modifyvm "default" --natpf1 "tcp-port7191,tcp,,7191,,7191"
VBoxManage modifyvm "default" --natpf1 "tcp-port7000,tcp,,7000,,7000"
VBoxManage modifyvm "default" --natpf1 "tcp-port7001,tcp,,7001,,7001"
VBoxManage modifyvm "default" --natpf1 "tcp-port9160,tcp,,7160,,7160"
VBoxManage modifyvm "default" --natpf1 "tcp-port9042,tcp,,9042,,9042"
(restart machine)
docker run --name c1 -v /Users/MyProjects/scripts/:/script -d cassandra:latest -p "7191:7191" -p "7000:7000" -p "7001:7001" -p "9160:9160" -p "9042:9042"
I can easily do
docker exec -it c1 cqlsh
it says
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
Now I get the IP address of my virtual box vm using
docker-machine env default
I can see the IP address of 192.168.99.100
But when I run my java program to connect to the same cassandra instance using the IP address above. I get an error
00:00:56.611 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Connection - Connection[/192.168.99.100:9042-1, inFlight=0, closed=false] Error connecting to /192.168.99.100:9042 (Connection refused: /192.168.99.100:9042)
00:00:56.615 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - Defuncting Connection[/192.168.99.100:9042-1, inFlight=0, closed=false] because: [/192.168.99.100] Cannot connect
00:00:56.616 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Connection - Connection[/192.168.99.100:9042-1, inFlight=0, closed=true] closing connection
00:00:56.617 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - [/192.168.99.100:9042] preventing new connections for the next 1000 ms
00:00:56.617 [cluster1-nio-worker-0] DEBUG com.datastax.driver.core.Host.STATES - [/192.168.99.100:9042] Connection[/192.168.99.100:9042-1, inFlight=0, closed=true] failed, remaining = 0
00:00:56.624 [run-main-0] DEBUG c.d.driver.core.ControlConnection - [Control connection] error on /192.168.99.100:9042 connection, no more host to try
com.datastax.driver.core.exceptions.TransportException: [/192.168.99.100] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:157) ~[cassandra-driver-core-3.0.0.jar:na]
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:140) ~[cassandra-driver-core-3.0.0.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:603) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:563) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:424) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:276) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:292) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) ~[netty-common-4.0.33.Final.jar:4.0.33.Final]
at java.lang.Thread.run(Thread.java:745) ~[na:1.7.0_79]
Caused by: java.net.ConnectException: Connection refused: /192.168.99.100:9042
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_79]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_79]
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289) ~[netty-transport-4.0.33.Final.jar:4.0.33.Final]
... 6 common frames omitted
00:00:56.625 [run-main-0] DEBUG com.datastax.driver.core.Cluster - Shutting down
[error] (run-main-0) java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at com.abhi.connector.CassandraConnector$class.$init$(CassandraConnector.scala:8)
at com.abhi.models.Movies$.<init>(Movies.scala:25)
at com.abhi.models.Movies$.<clinit>(Movies.scala)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at scala.collection.immutable.List.foreach(List.scala:381)
at com.abhi.MovieLensDataPreperation$.storeInCassandra(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$.main(MovieLensDataPreperation.scala:51)
at com.abhi.MovieLensDataPreperation.main(MovieLensDataPreperation.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /192.168.99.100:9042 (com.datastax.driver.core.exceptions.TransportException: [/192.168.99.100] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:231)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:77)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1414)
at com.datastax.driver.core.Cluster.init(Cluster.java:162)
at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:333)
at com.datastax.driver.core.Cluster.connect(Cluster.java:283)
at com.abhi.connector.Connector$.<init>(CassandraConnector.scala:22)
at com.abhi.connector.Connector$.<clinit>(CassandraConnector.scala)
at com.abhi.connector.CassandraConnector$class.$init$(CassandraConnector.scala:8)
at com.abhi.models.Movies$.<init>(Movies.scala:25)
at com.abhi.models.Movies$.<clinit>(Movies.scala)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$$anonfun$storeInCassandra$1.apply(MovieLensDataPreperation.scala:55)
at scala.collection.immutable.List.foreach(List.scala:381)
at com.abhi.MovieLensDataPreperation$.storeInCassandra(MovieLensDataPreperation.scala:55)
at com.abhi.MovieLensDataPreperation$.main(MovieLensDataPreperation.scala:51)
at com.abhi.MovieLensDataPreperation.main(MovieLensDataPreperation.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
This is my code to configure the java connection
Cluster.builder()
.addContactPoints("192.168.99.100").withPort(9042)
.build()
Edit: I also replaced the above IP address with the IP address of docker guest VM... but that did not resolve the issue.
I was able to solve the problem by using CASSANDRA_BROADCAST_ADDRESS when creating the docker container
This is the command I used
docker run --name c1 -v /Users/MyProjects/scripts/:/script -d -p "7191:7191"
-p "7000:7000" -p "7001:7001" -p "9160:9160" -p "9042:9042" -e
CASSANDRA_BROADCAST_ADDRESS=192.168.99.100 cassandra:latest
After creating the container like this. I am able to connect from my Scala application with this code
val keyspace: KeySpace = new KeySpace("foo")
val cluster =
Cluster.builder()
.addContactPoint("192.168.99.100").withPort(9042)
.build()
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(100000);
val session: Session = cluster.connect(keyspace.name)

Resources