环境配置
- ES版本:5.4.3
- 系统:CentOS release 6.x
- spring-data-elasticsearch:3.0.0.RELEASE
- spring:5.0.1.RELEASE
问题
1.本地访问es的restful接口不通
需要更改下面配置(elasticsearch.yml):
network.bind_host:0.0.0.0
network.host: <服务器ip>
如果系统是CentOS release 6.x的,需要在(elasticsearch.yml)增加下面语句
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
2.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
需要修改linux的内核设置,在/etc/sysctl.conf文件加入
vm.max_map_count=262144
然后系统执行:
sysctl -p
3.availableProcessors is already set to
Caused by: java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
at io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51)
at io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87)
at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:82)
at org.elasticsearch.transport.netty4.Netty4Transport.<init>(Netty4Transport.java:138)
at org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:93)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:174)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:265)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:130)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:116)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:106)
at org.springframework.data.elasticsearch.client.TransportClientFactoryBean.buildClient(TransportClientFactoryBean.java:91)
at org.springframework.data.elasticsearch.client.TransportClientFactoryBean.afterPropertiesSet(TransportClientFactoryBean.java:86)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1763)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)
... 82 more
解决办法:
@Slf4j
@Component
public class ElasticSearchConfiguration implements InitializingBean {
static {
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
@Override
public void afterPropertiesSet() throws Exception {
log.info("*****************es_config*************************");
log.info("es.set.netty.runtime.available.processors:{}", System.getProperty("es.set.netty.runtime.available.processors"));
log.info("***************************************************");
}
}