centos安装单机elasticseach
预装环境
jdk1.8
1
2
3
4
5
6
|
curl -O http://tar.matosiki.site/tar/elasticsearch-6.4.2.tar.gz
tar -vxzf elasticsearch-6.4.2.tar.gz -C /opt/
cd /opt/elasticsearch-6.4.2/config
|
更改elasticsearch配置
1
2
3
4
5
6
7
|
vim elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
node.max_local_storage_nodes: 256
|
更改用户最大可创建文件数
vi /etc/security/limits.conf
1
2
3
4
|
soft nofile 65536
hard nofile 131072
soft nproc 2048
hard nproc 4096
|
用户最大可创建线程数
vi /etc/security/limits.d/20-nproc.conf
更改最大虚拟内存
vi /etc/sysctl.conf
1
|
vm.max_map_count=655360
|
执行命令
本地测试环境调优
vim /opt/elasticsearch-6.4.2/config/jvm.options
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
groupadd es
useradd es -g es
cd /opt/
chown -R es:es ./elasticsearch-6.4.2
#切换到es用户
su es
cd /opt/elasticsearch-6.4.2/bin
#-d代表后台进程方式启动
./elasticsearch -d
# 关闭elasticsearch
jps | grep Elasticsearch
3673 Elasticsearch
kill -9 3673
|
安装插件
安装分词器
1
2
3
4
5
6
|
curl -O http://tar.matosiki.site/zip/elasticsearch-analysis-ik-6.4.2.zip
unzip elasticsearch-analysis-ik-6.4.2.zip -d /opt/elasticsearch-6.4.2/plugins/ik/
# 重启测试
curl -XGET -H 'Content-Type: application/json' 'http://localhost:9200/_analyze?pretty' -d '{ "analyzer" : "ik_max_word", "text": "中华人民共和国国歌"}'
|
安装Kiban 分析和可视化平台
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
curl -O http://tar.matosiki.site/tar/kibana-6.4.2-linux-x86_64.tar.gz
tar -vxzf kibana-6.4.2-linux-x86_64.tar.gz -C /opt/
vi /opt/kibana-6.4.2-linux-x86_64/config/kibana.yml
server.host: "0.0.0.0"
elasticsearch.url: "http://localhost:9200"
elasticsearch.username: "kibana"
elasticsearch.password: "kibana"
# 更改权限
chown -R es:es /opt/kibana-6.4.2-linux-x86_64
su es
nohup /opt/kibana-6.4.2-linux-x86_64/bin/kibana &
# 测试访问
curl http://localhost:5601/
|
安装 X-Pack(安装x-pack需要先安装kibana)
X-Pack是一个Elastic Stack扩展,它将安全性,警报,监视,报告和图形功能捆绑到一个易于安装的软件包中
这个6.4.2版本默认包含x-pack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# ~~在Elasticsearch中安装x-pack~~
/opt/elasticsearch-6.4.2/bin/elasticsearch-plugin install x-pack
# ~~启动elasticsearch~~
bin/elasticsearch
# 生成默认用户名和密码( elastic and kibana users)
/opt/elasticsearch-6.4.2/bin/x-pack/setup-passwords auto
# Kibana中安装 X-Pack
/opt/kibana-6.4.2-linux-x86_64/bin/kibana-plugin install x-pack
# 在kibana.yml 中添加用户名密码
elasticsearch.username: "kibana"
elasticsearch.password: "<pwd>"
# 启动 Kibana
bin/kibana
# 测试访问 登录elastic
curl http://localhost:5601/
|
安装 logstash
Logstash是一款轻量级的日志搜集处理框架,可以方便的把分散的、多样化的日志搜集起来,并进行自定义的处理,然后传输到指定的位置,比如某个服务器或者文件。能集中处理各种类型的数据,能标准化不同模式和格式的数据,能快速的扩展自定义日志的格式,能非常方便的添加插件来自定义数据源, Logstash采用JRuby开发的,本身也支持插件的功能
ELK:开源分布式日志分析搜索平台
E: elasticsearch, 负责数据的存储和查询
L: logstash, 负责日志数据的过滤和解析
K: Kibana, 负责web方式的前端展现
input: 用于处理输入的
filter: 用于处理过滤的
output: 用于处理输出的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
curl -O http://tar.matosiki.site/tar/logstash-6.4.2.tar.gz
tar -vxzf logstash-6.4.2.tar.gz -C /opt/
# 更改权限
chown -R es:es /opt/logstash-6.4.2/
su es
# 启动
/opt/logstash-6.4.2/bin/logstash -e "input { stdin {} } output { stdout {} }"
# 自定义输出配置启动
vi logstash-simple.conf
input { stdin { } }
output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
}
/opt/logstash-6.4.2/bin/logstash -f logstash-simple.conf &
|