config/elasticsearch.yml
# 打开节点名称
node.name: chb2
# 这里的node-1为node-name配置的值
cluster.initial_master_nodes:["chb2"]
# 外部ip访问elasticsearch
network.host: 0.0.0.0
1.2、Ps:常见报错
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] elasticsearch用户拥有的内存权限太小,至少需要262144;
//需要切换到root用户
sysctl -w vm.max_map_count=262144
//查看结果
sysctl -a|grep vm.max_map_count
//显示
vm.max_map_count = 262144
//修改之后,如果重启虚拟机将失效!!!
//解决办法:
//在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured 修改ES配置文件:config/elasticsearch.yml
//解开注释
cluster.initial_master_nodes: ["node-1", "node-2"]
二、kibana安装
vim kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.200.110:9200"]
2.2、问题
2.2.1、Error: Could not close browser client handle!
在kibana的config中的kibana.yml中配置
elasticsearch.hosts: [“http://192.168.147.52:9200”]
xpack.reporting.capture.browser.chromium.disableSandbox: true
xpack.reporting.capture.browser.chromium.proxy.enabled: false
xpack.reporting.enabled: false
详细请参考: https://www.elastic.co/guide/en/kibana/current/settings.html kibana官方配置 https://www.cnblogs.com/sanduzxcvbnm/p/12677691.html https://www.ucloud.cn/yun/34216.html
三、ik分词器 3.1、ik配置1、下载ik分词器 https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v7.9.3 2、解压到es的plugins目录下 3、重启es
3.2、配置自定义词库1、配置自定义词库文件 对于部分专业词语,我们不想进行分词,所以ik分词器提供自定义词库 修改plugins/ik/config/IKAnalyzer.cfg.xml,可以使用本地自定义词库,也可以使用远程分词库(建议使用远程,这样不用每次重启es集群)
IK Analyzer 扩展配置
custom.dic
3、重启es
配置自定义词库前
配置自定义词库后
1、配置同义词词库 2、重启 3、创建索引,设置settings
PUT test1
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"filter": {
"word_sync": {
"type": "synonym",
"synonyms_path": "analysis/synonym.txt"
}
},
"analyzer": {
"ik_sync_smart": {
"filter": [
"word_sync"
],
"type": "custom",
"tokenizer": "ik_smart"
}
}
}
},
"mappings": {
"properties": {
"name": {
"type": "text",
"fields": {
"synoword": {
"type": "text",
"analyzer": "ik_sync_smart"
}
}
}
}
}
}
1、下载plugin https://github.com/medcl/elasticsearch-analysis-pinyin/releases/tag/v7.9.3 2、解压刀plugins目录下的pinyin目录 3、重启es
5.4、测试拼音1、创建index
PUT test1
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"filter": {
"word_sync": {
"type": "synonym",
"synonyms_path": "analysis/synonym.txt"
}
},
"analyzer": {
"ik_sync_smart": {
"filter": [
"word_sync"
],
"type": "custom",
"tokenizer": "ik_smart"
},
"pinyin_analyzer": {
"type": "custom",
"tokenizer": "pinyin_tokenizer"
}
},
"tokenizer": {
"pinyin_tokenizer": {
"type": "pinyin"
}
}
}
},
"mappings": {
"properties": {
"name": {
"type": "text",
"fields": {
"synoword": {
"type": "text",
"analyzer": "ik_sync_smart"
},
"pinyin": {
"type": "text",
"analyzer": "pinyin_analyzer"
}
}
}
}
}
}
2、添加数据
PUT test1/_doc/1
{
"name": "全季"
}
PUT test1/_doc/2
{
"name": "拳击馆"
}
PUT test1/_doc/3
{
"name": "汉庭"
}
3、查询