## 0x01、ElasticSearch安装与配置
##### 1、下载ElasticSearch
```
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.zip
$ unzip elasticsearch-6.3.2.zip
```
##### 2、配置es:修改conf文件夹下的elasticsearch.yml
```
# 配置host使外网可访问,不然ip:port不能访问,只能通过localhost:port
network.host: 0.0.0.0
http.port: 9200
```
##### 3、报错踩坑
- es的安全机制不能使用root用户启动,需要切换到其他用户
- 配置了host后运行es报错
```
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3780] for user [jiang] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
```
解决方案:
```
error [1][2]
$ sudo vi /etc/security/limits.conf
# 添加一下4条配置
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
error:[3]
$ vi /etc/sysctl.conf
# 添加一下配置
vm.max_map_count=262144
$ sysctl -p 生效
```
##### 4、启动es
```
$ ./bin/elasticsearch
$ curl localhost/ip:9200
```
## 0x02、Kibana安装
##### 1、下载kibana,kibana需要和es版本对应
```
$ https://artifacts.elastic.co/downloads/kibana/kibana-6.3.2-linux-x86_64.tar.gz
```
##### 2、解压kibana
```
# sha1sum 查看软件的hash和完整性
$ sha1sum kibana-6.3.2-linux-x86_64.tar.gz
$ tar -zxvf kibana-6.3.2-linux-x86_64.tar.gz
```
##### 3、配置kibana
```
# 连接es
elasticsearch.url: "http://192.168.1.240:9250"
```
##### 4、运行kibana
```
$ ./bin/kibana
# 浏览器访问 localhost:5601
```
##### 5、Kibana用户手册
[Kibana官网用户手册](https://www.elastic.co/guide/cn/kibana/current/index.html)
## 0x03、Elasticsearch head安装
1、下载elasticsearch head
```
去github下载zip
$ wget https://github.com/mobz/elasticsearch-head/archive/master.zip
```
2、安装es head 依赖的nodejs 环境
[node.js教程](http://www.runoob.com/nodejs/nodejs-install-setup.html)
```
$ wget https://npm.taobao.org/mirrors/node/v10.8.0/node-v10.8.0-linux-x64.tar.xz
$ tar xf node-v10.8.0-linux-x64.tar.xz
```
3、配置nodejs环境变量
```
# 在/etc/profile添加以下两行
# config nodejs
NODE_HOME=/home/jiang/app/node-v10.8.0-linux-x64
PATH=$NODE_HOME/bin:$PATH
# 使配置文件生效
$ source /etc/profile
```
4、安装grunt
```
$ cd /elasticsearch-head-master
$ npm install -g grunt-cli
$ grunt -version
$ npm install
```
5、启动head
```
$ cd /elasticsearch-head-master
$ grunt server
浏览器访问: http://localhost:9100/
enjoy it...
```