小知识,大挑战!本文正在参与“程序员必备小知识”创作活动。
www.elastic.co/cn/download… 可以下载下面各个软件的历史版本
E:elasticsearch
groupadd elsearch #新建elsearch组
useradd elsearch -g elsearch -p elasticsearch #新建一个elsearch用户
chown -R elsearch:elsearch ./elasticsearch #指定elasticsearch所属elsearch组
tips:默认配置,修改host为本机127.0.0.1,不能是对外ip地址,配置请求项:
http.cors.allow-origin:"*"
切换elsearch用户启动:./elasticsearch -Xmx2g -Xms2g -Des.index.storage.type=memory -d
或者nohup ./elasticsearch -Xmx2g -Xms2g -Des.index.storage.type=memory > /dev/null 2>&1 &
复制代码
报错 max virtual memory areas vm.max\_map\_count \[65530\] is too low, increase to at least \[262144\]是因为操作系统vm.max\_map\_count参数设置太小导致的,至于设置多大的数值,我这里就直接参照报错信息的建议直接设置为262144
解决方案一:
sysctl -w vm.max_map_count=262144
[root@localhost elasticsearch-6.1.2]# sysctl -a | grep "vm.max_map_count" vm.max_map_count = 262144
解决方案二(推荐):永久性修改
- 切换到root用户,备份原有配置
[root@localhost elasticsearch-6.1.2]# cd /etc [root@localhost etc]# cp sysctl.conf sysctl.conf.bak
- 编辑sysctl.conf,增加如下内容
[root@localhost etc]# vim sysctl.conf # elasticsearch config start vm.max_map_count=262144 # elasticsearch config end 复制代码
报错:max file descriptors \[4096\] for elasticsearch process is too low, increase to at least \[65536\]是因为操作系统安全检测配置影响的,我们需要切换到root用户下做如下配置:
先做一个配置备份
[root@localhost elasticsearch-6.1.2]# cd /etc/security/ [root@localhost security]# cp limits.conf limits.conf.bak # elasticsearch config start * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 # elasticsearch config end 执行启动命令 ./bin/elasticsearch ,会发现指定IP已经配置好了,也正常启动。 复制代码
2、L:logstash
- 修改配置文件:logstash/config
type => "log" #自定义
path => "/logs/*.log" #可以是绝对路径
start_position => "beginning"
if [type] == "log"{ # 条件判断等于是否是上面的type
elasticsearch { # 配置elasticsearch服务地址+ip
index => "log-%{+YYYY.MM.dd}"
tips:启动nohup ./logstash -f ../config/logstash.conf > /dev/null 2>&1 &
path => "/var/log/nginx/access.log"
type => "nginx-node3"
start_position => "beginning"
stat_interval => "2"
codec => "json"
path => "/var/log/messages"
type => "nginx-node"
start_position => "beginning"
stat_interval => "2"
if [type] == "nginx-node3" {
elasticsearch {
hosts => ["192.168.0.131:9200"]
index => "logstash-nginx-accesslog-node3-%{+YYYY.MM.dd}"
if [type] == "nginx-node" {
elasticsearch {
hosts => ["192.168.0.131:9200"]
index => "logstash-system-log-node3-%{+YYYY.MM.dd}"
复制代码
3、K:kibana
- 修改config下的配置文件,要读取的elasticSearch地址和可供外网访问的bind地址,如果端口被占用,还需要修改端口号:
server.port: 5601 #默认端口 ,可以改成任何没被使用的端口号
server.host: "127.0.0.1" # 这个配置可以默认关闭,或者打开设置成0.0.0.0
elasticsearch.hosts: ["http://127.0.0.1:9200"] #kibana访问es的地址,
tips:./kibana 提示:Kibana should not be run as root. Use --allow-root to continue. 所以在使用root启动时需要带上:--allow-root 参数
启动:kibana -p 25601 > /dev/null 2>&1 & -p指定服务端口
linux环境配置服务端口,启动时,偶尔有被占用的端口,但是在netstat -ano|grep port看的不是很清除,需要知道是哪个服务占用了端口, lsof -i:8000 (yum install lsof) 然后再ps -ef |grep pid
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.3-x86_64.rpm sudo rpm -vi filebeat-6.4.3-x86_64.rpm
bin/elasticsearch-plugin install ingest-geoip bin/elasticsearch-plugin install ingest-user-agent
[root@iZwz9drblb61bve070evy3Z logs]# whereis filebeat
filebeat: /usr/bin/filebeat /etc/filebeat /usr/share/filebeat
[root@iZwz9drblbx61bve070evy3Z logs]#
#在kibana操作步骤配置filebeat.yml
output.elasticsearch: hosts: ["<es_url>"] username: "elastic" password: ""
setup.kibana: host: "<kibana_url>"Where is the password of the elastic user, <es_url> is the URL of Elasticsearch,
and <kibana_url> is the URL of Kibana.
tips:filebeat.inputs:配置的paths是需要monitor的日志路径,状态要开启enable:true
filebeat.config.modules配置也需要开启,在执行filebeat modules enable nginx之后 ,modules.d目录下的nginx.yml是不带disable的.




近期评论