elsticsearch官方下载: https://www.elastic.co/cn/downloads/elasticsearch
一安装:根据需要选择自己的版本:
我用的linux,我的服务2核4g,环境是centos7.9
文件放到/usr/doumingquan/elk/下
tar -zxvf elasticserarch7.13.2
mv elasticsearch7.13.2 elasticsearch
cd elasticsearch
修改配置文件
vi elasticsearch/config/elasticsearch.yml(有些配置文件夹没有的需要自己新建,data,logs目录这些自己定义)
vi /etc/security/limits.conf
根据需要在后面添加:
* soft nofile 65535
* hard nofile 65535
* soft nproc 32000
* hard nproc 32000
* hard memlock unlimited
* soft memlock unlimited
遇到的问题:
1.elasticsearch不能使用root账号执行:
useradd es
passwd es
修改文件夹的所属组,所有者和权限
chown es:es elasticsearch -R
chmod -R 770 elasticsearch
切换es用户 su es(elastic是不能用root执行的)
elasticsearch/bin/elasticsearch(启动elasticsearch)
2.下面这3个问题,
a.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf(在最后添加一行)
vm.max_map_count=262144
执行:sysctl -p(立即生效)
bc配置文件的问题
不报错的话就启动成功了
netstat -antp|grep 9200能查询到端口就成功了
生产环境下对配置要求高,有时候java提示没有内存则修改
vim elasticsearch/config/jvm.options(根据自身的服务器配置,外网(生产环境)最低好像是1g,之前用512m还是报错的)
附:黑马的配置说明
二、索引
1.索引创建:使用postman创建索引
json数据格式如下:
{
"settings":{
"number_of_shards":3,
"number_of_replicas":1
},
"mappings":{
"properties":{
"name":{
"type":"text"
},
"age":{
"type":"integer"
},
"country":{
"type":"keyword"
},
"birthday":{
"type":"date",
"format":"yyyy-MM-dd HHmmss||yyyyMMdd||epoch_millis"
}
}
}
}
2.修改索引
3.删除索引
4.索引搜索(文档:https://www.elastic.co/guide/cn/elasticsearch/guide/current/pagination.html)
5.将logstash数据导入到elasticsearch
新建test/logstash_pannel_accesslog.conf(用logstash将宝塔的access.log导入到elasticsearch)
input {
file {
path => "/www/wwwlogs/access.log"
start_position => "beginning"
}
}
filter {
if [path] =~ "access" {
mutate { replace => { "type" => "apache_access" } }
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
}
stdout { codec => rubydebug }
}
bin/logstash -f test/logstash_pannel_accesslog.conf(执行)
版权声明:本文为weixin_36521716原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。