Ealsticsearch 5.x 遇到的坑

1、Es client的java api中使用了netty,自身服务也需要使用netty接收http请求,则不能再进入netty的jar包了,而es中有限制,不能再使用netty?

需要设置全局的环境变量,可以在jvm中进行设置,也可在服务启动时进行设置,如(spring boot服务):

@SpringBootApplication

public class Application implements CommandLineRunner {

@Autowired

private DataLogServerdataLogServer;

public static void main(String[]args) {

// 设置环境变量,解决Es的netty与Netty服务本身不兼容问题

System.setProperty("es.set.netty.runtime.available.processors","false");

SpringApplication.run(VrworldApploguploadApplication.class,args);

}

}

2、jvm内存分配不够的问题

Starting elasticsearch: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

#

# There is insufficient memory for the Java Runtime Environment to continue.

# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.

# An error report file with more information is saved as:

# /tmp/hs_err_pid16341.log

                                                           [FAILED]

修改/etc/elasticsearch下的jvm.options,jvm配置信息,修改

-Xms2g

-Xmx2g

将参数调小一点,我修改为1g就可以了

3、elasticsearch dead but pid file exists

  删除原有日志/var/log/elasticsearch 并且重新创建service elasticsearch

      rm -f /var/run/:删除下面的elasticsearch文件

4、elasticsearch dead but subsys locked

 需要删除/var/lock/subsys 目录下的elasticsearch文件:

it means that there is a lock file exist in subsys folder

GO to :


    cd /var/lock/subsys or where you kept subsys folder

    delete elasticsearch file

    rm elasticsearch

    stop the elasticsearch

    and start the elasticsearch

5、[2017-10-31T10:04:07,697][WARN ][o.e.b.JNANatives] unable to install syscall filter

 详细信息如下:

 

 这只是一个warm,不会影响服务的运行,需要关注,可能会出第六个问题。

6、 bootstrap checks failed

1、 max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

是由于系统的文件限制过小,修改如下:切换到root用户,编辑limits.conf添加类似如下内容

vi /etc/security/limits.conf 

添加如下内容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

2、max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]

vi /etc/security/limits.d/90-nproc.conf 

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 2048

3、max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

解决:切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p

4、system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
 bootstrap.memory_lock: false
 bootstrap.system_call_filter: false

7、Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [type] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

解决:问题说的很明白,Es5.x string类型的字段分为text和keyworld,text用户数据检索,而keyword用于数据的聚合,当然只有string类型才会有keword,所以在聚合的时候,直接使用keyword进行聚合,如:

AggregationBuilders.terms("agg").field("content" + ".keyword"); // content为字段名

 当然还可以启用fielddata,默认是关闭的,启用后会加载到内存中,有一定的消耗,开启方式如下:

PUT my_index/_mapping/my_type
{
  "properties": {
    "my_field": {
      "type":     "text",
      "fielddata": true
    }
  }
}
 或者(注意其中对应的index、type和field的名称,替换一下):



8、Expected numeric type on field [my_field.keyword], but got [keyword]

解决:这是在进行avg和sum等Metrics Aggregations(度量聚合)的时候报错的,进行数学维度的计算,期望得到一个数字字段,但是得到的是一个String的keyword类型,若把my_field.keyword换成my_field,则又会包上一个错误。则需要在index数据之前进行mapping配置,将该字段的值定义为numeric,或者开启mapping的Numeric detection(数字探测)。默认是关闭的,但是这样的话就会将所有的数据类型都映射为数字了。开启方式如下:

PUT my_index
{
  "mappings": {
    "my_type": {
      "numeric_detection": true
    }
  }
}
 
PUT my_index/my_type/1
{
  "my_float":   "1.0",
  "my_integer": "1"
}


如下所示:

 

9、Es集群索引过数据后,又想修改数据和日志的路径

    报错如下:


 则需要修改启动的默认配置路径:删除-Edefault.path.data=${DATA_DIR},如下是我的服务器上的数据,位于/etc/init.d目录下的elasticsearch文件:

-Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR

  还需要删除/usr/lib/systemd/system/elasticsearch.service中的配置部分:

ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec

ExecStart=/usr/share/elasticsearch/bin/elasticsearch \

                                                -p ${PID_DIR}/elasticsearch.pid \

                                                --quiet \

                                                -Edefault.path.logs=${LOG_DIR} \

                                                -Edefault.path.data=${DATA_DIR} \

                                                -Edefault.path.conf=${CONF_DIR}

    当然修改完当你运行时也会提示你:

Warning: elasticsearch.service changed on disk. Run 'systemctl daemon-reload' to reload units.

    执行以下刷新:

systemctl daemon-reload

10、Validation Failed: 1: reindex from remote sources doesn't support workers > 1 but was [5]

  该错是由于我想使用5个线程并行化的执行remote reindex操作报错的,remote reindex操作不允许指定slices,去掉即可,还是比较好用的。

11、doesn't match any of the locations specified by path.repo because this setting is empty

  在为es集群环境做灾备和恢复时候,首先需要创建创建一个仓库,并往仓库中存放快照(每个快照中会区分不同的索引)。但是在创建仓库的时候,要求仓库的地址必须在每个集群环境中的elasticsearch.yml中进行配置(相当于一个白名单列表):

    单个:path.repo: /mnt

    多个:path.repo: [“/data” , “/mnt”]

12、在使用sshfs创建共享文件系统的时候,报错read: Connection reset by peer

        Es在灾备的时候可以将数据存放到共享文件系统(一般选择sshfs),或hdfs等。但是在执行如sudo sshfs -o allow_other [email protected]:/data/elasticsearch-repository /mnt的时候,报错read:Connect reset by peer,刚开始以为是es的问题,最后发现就是ssh的问题。由于我使用的是阿里云服务器,并且使用秘钥进行连接,我还以为是它的问题。最后

        ssh 192.168.10.11

        ssh: connect to host 192.168.10.11 port 22: Connection refused

  想起来我修改过ssh的端口,则需要将命令添加端口就好了,如下:

        sudo sshfs -o allow_other [email protected]:/data/elasticsearch-repository /mnt -p 61822



猜你喜欢

转载自blog.csdn.net/it_lihongmin/article/details/78436883
今日推荐