我是在linux服务器上装的es本地浏览器能够访问linux的es因为我改了es的配置文件network.host已经修改为四个0了,依然报错

来源:7-5 -Elasticsearch 实-文档、资源库、测试用例

慕仙4974986

2018-01-01

//img.mukewang.com/szimg/5a49b8a30001d4cf09520746.jpg


-----------控制台报错是这个-----------------------

org.elasticsearch.transport.ReceiveTimeoutTransportException: [][192.168.0.103:9200][cluster:monitor/nodes/liveness] request_id [0] timed out after [5005ms]

at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:698) ~[elasticsearch-2.4.6.jar:2.4.6]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_65]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_65]

at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_65]


2018-01-01 11:58:15.944 ERROR 8793 --- [           main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{192.168.0.103}{192.168.0.103:9200}]


---------------------junit报的错是这个------------------------------

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.168.0.103}{192.168.0.103:9200}]]

at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:326)

at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223)

at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)

at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:295)

at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)

at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)

at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)

at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.doScan(ElasticsearchTemplate.java:795)

at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.scan(ElasticsearchTemplate.java:736)

at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.delete(ElasticsearchTemplate.java:670)

at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.deleteAll(AbstractElasticsearchRepository.java:248)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:520)

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:505)

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:477)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)

at com.sun.proxy.$Proxy101.deleteAll(Unknown Source)

at com.andy.spring.boot.blog.repository.es.EsBlogRepositoryTest.initRepositoryData(EsBlogRepositoryTest.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

-----------------------------
application.properties

# Elasticsearch 服务地址
spring.data.elasticsearch.cluster-nodes=192.168.0.103:9200
#设置链接超时时间
spring.data.elasticsearch.properties.transport.tcp.connect_timeout=120s


-----------------------------

-------------------------------------------------------

@RunWith(SpringRunner.class)

@SpringBootTest

public class EsBlogRepositoryTest {


@Autowired

private EsBlogRepository esBlogRepository;

@Before

public void initRepositoryData(){

//清除所有数据

esBlogRepository.deleteAll();

esBlogRepository.save(new EsBlog("登鹳雀楼", "王之涣的登鹳雀楼",  "白日依山尽,黄河入海流。欲穷千里目,更上一层楼。"));

esBlogRepository.save(new EsBlog("相思", "王维的相思",  "红豆生南国,春来发几枝。愿君多采撷,此物最相思。"));

esBlogRepository.save(new EsBlog("静夜思", "李白的静夜思",  "床前明月光,疑是地上霜,举头望明月,低头思故乡。"));

}



@Test

public void testFindDistinctEsBlogByTitleContainingOrSummaryContainingOrContentContaining() {


Pageable pageable = new PageRequest(0, 20);

String title = "思";

String summary = "相思";

String content = "相思";

Page<EsBlog> page = esBlogRepository.findDistinctEsBlogByTitleContainingOrSummaryContainingOrContentContaining(title, summary, content, pageable);

assertThat(page.getTotalElements()).isEqualTo(2);

System.out.println("...............start");

for (EsBlog esBlog : page.getContent()) {

System.out.println(esBlog.toString());

}

System.out.println("...............end");

}

}


写回答

1回答

老卫

2018-01-01

请根据课程的配置来对应用进行设置。
spring.data.elasticsearch.cluster-nodes=localhost:9300

1
1
慕仙4974986
非常感谢!已经解决
2018-01-01
共1条回复

基于Spring Boot技术栈博客系统企业级前后端实战

毕设 Elasticsearch搜索+Thymeleaf模板+JPA+Security+BootStrap

1296 学习 · 738 问题

查看课程