es搭建

下载

https://www.elastic.co/products/elasticsearch

https://github.com/elastic/elasticsearch

运行

执行bin文件夹中的elasticsearch.bat ,查看 http://localhost:9200

安装ik中文分词器

https://github.com/medcl/elasticsearch-analysis-ik/releases

  • 选择和已经下载的elasticsearch版本兼容的ik。
  • 解压后复制elasticsearch/plugins/ik(ik文件夹新创建)目录下
  • 重新运行elasticsearch.bat
  • ik:http://localhost:9200/_cat/plugins

单节点部署,外网访问

修改elasticsearch.yml文件,设置network.host: 0.0.0.0,并添加discovery.type: single-node。

集群elasticsearch.yml相关配置如下

1
2
3
4
5
6
7
8
9
10
11
---------------------------------- Cluster -----------------------------------
cluster.name: mqiy-es
#
# ------------------------------------ Node ------------------------------------
node.name: node-1
# ---------------------------------- Network -----------------------------------
network.host: 192.168.85.141
http.port: 9200
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["192.168.85.142", "192.168.85.143"]
cluster.initial_master_nodes: ["node-1", "node-2","node-3"]

查看集群状态

http://192.168.85.141:9200/_cat/health?v 查看集群的健康状态
http://192.168.85.141:9200/_cat/indices?v 查看集群的索引数
http://192.168.85.141:9200/_cat/allocation?v 查看集群所在磁盘的分配状况
http://192.168.85.141:9200/_cat/nodes?v 查看集群的节点
http://192.168.85.141:9200/_cat 查看集群信息目录(包含上面的)

v 表示带title

启动过程报错

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

添加配置 /etc/sysctl.conf (永久性修改)

1
2
3
# elasticsearch config start
vm.max_map_count=262144
# elasticsearch config end

sysctl -p

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

添加配置 /etc/security/limits.conf (永久性修改) 

1
2
3
4
5
6
# elasticsearch config start
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
# elasticsearch config end

其中* 号不能省略,不需要重启

elasticsearch-env: line 122: syntax error near unexpected token `<’

解决方法是修改elasticsearch-env文件的第122行:
done < <(env)
【<改成三连,括号改成单引号】
done <<<’env’