[root@localhost /]# docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.1 [root@localhost /]# docker run -d -p 9200:9200 -p 9300:9300 --name es elasticsearch:7.10.1
#启动命令参考 [root@localhost /]# docker run -d -p 9200:9200 -p 9300:9300 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e discovery.type=single-node --name es elasticsearch:7.10.1
问题
1 2 3 4 5 6
问题1:error='Cannot allocate memory' 原因:ES 5.x+堆内存大小默认配置为2G ES 7.x+默认4G 解决: vi config/jvm.options -Xms4g → -Xms512m -Xmx4g → -Xmx512m
1 2 3 4 5
问题2:WARNING: IPv4 forwarding is disabled. Networking will not work. 解决: vi /etc/sysctl.conf net.ipv4.ip_forward=1 restart network && systemctl restart docker sysctl net.ipv4.ip_forward
1 2 3 4 5 6 7 8 9
问题3: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144] 解释: 5.0以后,ES使用mmapfs作为默认的文件系统存储类型。可以通过配置index.store.type来设置ES默认的文件系统存储类型。 Niofs(非阻塞文件系统) mmapfs(内存映射文件系统) 配置:index.store.type: niofs 解决:sysctl -w vm.max_map_count=262144 查看是否生效: 或:vi /etc/sysctl.conf vm.max_map_count=262144 grep vm.max_map_count /etc/sysctl.conf
1 2 3 4
问题4:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] 解决:vi /etc/security/limits.conf,最后添加以下内容。 * soft nofile 65536 * hard nofile 65536
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
问题5: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 4096
当引导检查报未开启内存锁时,需要修改一下配置: vi /etc/security/limits.conf,最后添加以下内容。 * soft nofile 65536 * hard nofile 65536 * soft nproc 4096 * hard nproc 4096 * hard memlock unlimited * soft memlock unlimited vi /etc/systemd/system.conf ,分别修改以下内容。 vi /etc/systemd/system.conf 注意 修改操作系统配置需要重启系统才能生效,如果宿主机内存过小,可能导致容器无法启动。开发模式内存建议4G以上,生产建议32G以上.
# 创建插件文件夹 cd /usr/local/elasticsearch/plugins/ && mkdir ik # 将编译后的zip上传进ik文件夹中解压 unzip elasticsearch-analysis-ik-7.12.1.zip #授权 chown -R elasticsearch ik #重启启动切换其账户启动es
两种分词器analyzer
ik_max_word:细粒度
ik_smart:粗粒度
配置文件说明
1 2 3 4 5 6 7 8 9 10 11 12
1) IKAnalyzer.cfg.xml:IK分词配置文件 2) 主词库:main.dic 3) 英文停用词:stopword.dic,不会建立在倒排索引中 4) 特殊词库: a. quantifier.dic:特殊词库:计量单位等 b. suffix.dic:特殊词库:后缀名 c. surname.dic:特殊词库:百家姓 d. preposition:特殊词库:语气词 5) 自定义词库:比如当下流行词:857、emmm...、渣女、舔屏、996 6) 热更新: a. 修改ik分词器源码 b. 基于ik分词器原生支持的热更新方案,部署一个web服务器,提供一个http接口,通过modified和tag两个http响应头,来提供词语的热更新
esuser@host:/usr/local/elk/elasticsearch/bin$ ./elasticsearch-setup-passwords interactive future versions of Elasticsearch will require Java 11; your Java version from [/usr/jdk1.8.0_241/jre] does not meet this requirement
Your cluster health is currently RED. This means that some cluster data is unavailable and your cluster is not fully functional.
It is recommended that you resolve the issues with your cluster before running elasticsearch-setup-passwords. It is very likely that the password changes will fail when run against an unhealthy cluster.
Do you want to continue with the password setup process [y/N]y
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user. You will be prompted to enter passwords as the process progresses. Please confirm that you would like to continue [y/N]y
Enter password for [elastic]: Reenter password for [elastic]: Passwords do not match. Try again. Enter password for [elastic]: Reenter password for [elastic]: Passwords do not match. Try again. Enter password for [elastic]: Reenter password for [elastic]: Enter password for [apm_system]: Reenter password for [apm_system]: Passwords do not match. Try again. Enter password for [apm_system]: Reenter password for [apm_system]: Enter password for [kibana_system]: Reenter password for [kibana_system]: Enter password for [logstash_system]: Reenter password for [logstash_system]: Enter password for [beats_system]: Reenter password for [beats_system]: Enter password for [remote_monitoring_user]: Reenter password for [remote_monitoring_user]: Changed password for user [apm_system] Changed password for user [kibana_system] Changed password for user [kibana] Changed password for user [logstash_system] Changed password for user [beats_system] Changed password for user [remote_monitoring_user] Changed password for user [elastic]