Elasticsearch安装

官方文档

下载Elasticsearch 5

在Elasticsearch文件夹下配置节点信息(10.35.16.67做master节点和10.35.16.143作分节点):

master结点配置文件添加

1
2
3
4
5
6
7
8
9
10
11
#  /Elasticsearch5.x/config/elasticsearch.yml
cluster.name: es
node.name: es0
network.host: 0.0.0.0
http.port: 9200
node.master: true
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
discovery.zen.ping.unicast.hosts: ["10.35.16.67:9300","10.35.16.143:9300","10.35.16.67:9301"]
http.cors.enabled: true
http.cors.allow-origin: "*"

分节点配置文件添加

1
2
3
4
5
6
7
8
9
10
11
12
13
#  /Elasticsearch5.x/config/elasticsearch.yml
cluster.name: es
node.name: es1
network.host: 10.35.16.243
http.port: 9200
node.data: true
node.master: false
discovery.zen.ping.unicast.hosts: ["10.35.16.67:9300","10.35.16.143:9300","10.35.16.67:9301"]
discovery.zen.minimum_master_nodes: 1
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
http.cors.enabled: true
http.cors.allow-origin: "*"#action.destructive_requires_name: true

运行Elasticsearch(在Elasticsearch文件夹下)

1
./bin/elasticsearch -d

运行Elasticsearch常见问题解决方案


ik分词器安装

项目地址

1
elasticsearch-plugin  install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.16/elasticsearch-analysis-ik-5.6.16.zip

测试

1
2
3
4
5
POST http://localhost:9200/_analyze
{
"analyzer": "ik_smart",
"text": "世界如此之大"
}

创建索引

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"test": {
"properties": {
"area": {
"type": "string",
"analyzer": "ik_smart",
"search_analyzer": "ik_smart",
"fielddata": true // 聚合需填true
}
}
}
}
}


Elasticsearch-head插件安装

项目地址

需先安装node-js

安装elasticsearch-head

1
2
3
4
5
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
open [http://localhost:9100/](http://localhost:9100/)


Kibana安装

官方文档

下载kibana 5,必须与Elasticsearch版本号一致

Kibana配置文件目录在kibana-5.x/config/kibana.yml,配置详解见官网教程

运行Kibana

1
./bin/kibana


Search-Guard 安装

官方文档项目地址

1
./bin/elasticsearch-plugin install -b com.floragunn:search-guard-5:5.6.16-19.3

进入 elasticsearch/plugins/search-guard-5/tools 文件夹下

1
2
3
chmod +x install_demo_configuration.sh
./install_demo_configuration.sh
./sgadmin_demo.sh