启动Cassandra出现UnknownHost错误

本文介绍了如何解决Cassandra启动过程中遇到的UnknownHostException错误。通过在/etc/hosts文件中添加本机名称,可以有效解决该问题并成功启动Cassandra。

启动Cassandra出现类似:

java.net.UnknownHostException

 

编辑/etc/hosts文件,增加本机名称:

127.0.0.1   localhost HostName
::1         localhost HostName

 

保存后,再次启动Cassandra,成功

error: No nodes present in the cluster. Has this node finished starting up? -- StackTrace -- java.lang.RuntimeException: No nodes present in the cluster. Has this node finished starting up? at org.apache.cassandra.dht.Murmur3Partitioner.describeOwnership(Murmur3Partitioner.java:294) at org.apache.cassandra.service.StorageService.getOwnershipWithPort(StorageService.java:5752) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at sun.reflect.misc.Trampoline.invoke(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at java.base/sun.reflect.misc.MethodUtil.invoke(Unknown Source) at java.management/com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(Unknown Source) at java.management/com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(Unknown Source) at java.management/com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(Unknown Source) at java.management/com.sun.jmx.mbeanserver.PerInterface.getAttribute(Unknown Source) at java.management/com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(Unknown Source) at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(Unknown Source) at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(Unknown Source) at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(Unknown Source) at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(Unknown Source) at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(Unknown Source) at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.getAttribute(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source) at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source)
最新发布
09-03
帮我看看问题是什么? 2025-08-28 11:27:37.819 INFO 14596 --- [ main] c.t.n.d.b.BasicSpringBootApplication : Starting BasicSpringBootApplication on 18088172-BG with PID 14596 (E:\code\java\basic-spring-boot\target\classes started by admin in E:\code\java\basic-spring-boot) 2025-08-28 11:27:37.820 INFO 14596 --- [ main] c.t.n.d.b.BasicSpringBootApplication : The following profiles are active: mysql 2025-08-28 11:27:38.262 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2025-08-28 11:27:38.263 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode. 2025-08-28 11:27:38.286 INFO 14596 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Reactive Cassandra - Could not safely identify store assignment for repository candidate interface com.tplink.nbu.demo.basicspringboot.repository.MysqlUserRepository. If you want this repository to be a Reactive Cassandra repository, consider annotating your entities with one of these annotations: org.springframework.data.cassandra.core.mapping.Table (preferred), or consider extending one of the following types with your repository: org.springframework.data.cassandra.repository.ReactiveCassandraRepository. 2025-08-28 11:27:38.286 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 22ms. Found 0 Reactive Cassandra repository interfaces. 2025-08-28 11:27:38.288 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2025-08-28 11:27:38.288 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode. 2025-08-28 11:27:38.291 INFO 14596 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Cassandra - Could not safely identify store assignment for repository candidate interface com.tplink.nbu.demo.basicspringboot.repository.MysqlUserRepository. If you want this repository to be a Cassandra repository, consider annotating your entities with one of these annotations: org.springframework.data.cassandra.core.mapping.Table (preferred), or consider extending one of the following types with your repository: org.springframework.data.cassandra.repository.CassandraRepository. 2025-08-28 11:27:38.299 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11ms. Found 1 Cassandra repository interfaces. 2025-08-28 11:27:38.302 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2025-08-28 11:27:38.302 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2025-08-28 11:27:38.307 INFO 14596 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data JPA - Could not safely identify store assignment for repository candidate interface com.tplink.nbu.demo.basicspringboot.repository.CassandraUserRepository. If you want this repository to be a JPA repository, consider annotating your entities with one of these annotations: javax.persistence.Entity, javax.persistence.MappedSuperclass (preferred), or consider extending one of the following types with your repository: org.springframework.data.jpa.repository.JpaRepository. 2025-08-28 11:27:38.311 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7ms. Found 1 JPA repository interfaces. 2025-08-28 11:27:38.313 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2025-08-28 11:27:38.313 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode. 2025-08-28 11:27:38.316 INFO 14596 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.tplink.nbu.demo.basicspringboot.repository.CassandraUserRepository. If you want this repository to be a MongoDB repository, consider annotating your entities with one of these annotations: org.springframework.data.mongodb.core.mapping.Document (preferred), or consider extending one of the following types with your repository: org.springframework.data.mongodb.repository.MongoRepository. 2025-08-28 11:27:38.316 INFO 14596 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.tplink.nbu.demo.basicspringboot.repository.MysqlUserRepository. If you want this repository to be a MongoDB repository, consider annotating your entities with one of these annotations: org.springframework.data.mongodb.core.mapping.Document (preferred), or consider extending one of the following types with your repository: org.springframework.data.mongodb.repository.MongoRepository. 2025-08-28 11:27:38.316 INFO 14596 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3ms. Found 0 MongoDB repository interfaces. 2025-08-28 11:27:38.721 INFO 14596 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2025-08-28 11:27:38.731 INFO 14596 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2025-08-28 11:27:38.731 INFO 14596 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34] 2025-08-28 11:27:38.858 INFO 14596 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2025-08-28 11:27:38.859 INFO 14596 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1023 ms 2025-08-28 11:27:39.129 INFO 14596 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2025-08-28 11:27:39.158 INFO 14596 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1}] to localhost:27017 2025-08-28 11:27:39.160 INFO 14596 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[8, 0, 13]}, minWireVersion=0, maxWireVersion=25, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1022300} 2025-08-28 11:27:39.183 WARN 14596 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might want to check your annotation setup at the converter implementation. 2025-08-28 11:27:39.183 WARN 14596 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might want to check your annotation setup at the converter implementation. 2025-08-28 11:27:39.220 WARN 14596 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might want to check your annotation setup at the converter implementation. 2025-08-28 11:27:39.220 WARN 14596 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might want to check your annotation setup at the converter implementation. 2025-08-28 11:27:39.300 INFO 14596 --- [ main] com.datastax.driver.core : DataStax Java driver 3.6.0 for Apache Cassandra 2025-08-28 11:27:39.303 INFO 14596 --- [ main] c.d.driver.core.GuavaCompatibility : Detected Guava >= 19 in the classpath, using modern compatibility layer 2025-08-28 11:27:39.398 INFO 14596 --- [ main] com.datastax.driver.core.Native : Could not load JNR C Library, native system calls through this library will not be available (set this logger level to DEBUG to see the full stack trace). 2025-08-28 11:27:39.398 INFO 14596 --- [ main] com.datastax.driver.core.ClockFactory : Using java.lang.System clock to generate timestamps. 2025-08-28 11:27:39.509 INFO 14596 --- [ main] com.datastax.driver.core.NettyUtil : Did not find Netty's native epoll transport in the classpath, defaulting to NIO. 2025-08-28 11:27:44.003 ERROR 14596 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.cassandra.CassandraHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cassandraTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'cassandraTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]: Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0:0:0:0:0:1:9042] Cannot connect), localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] Cannot connect)) 2025-08-28 11:27:44.019 INFO 14596 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2025-08-28 11:27:44.020 WARN 14596 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [cluster-ClusterId{value='68afccabd741243904de974b', description='null'}-localhost:27017] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
08-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值