ELK的安装配置

ElasticSearch

单机搭建

操作说明

  1. 所有命令都在root用户操作

安装JDK环境

下载ElasticSearch

解压并改名

tar -zxvf elasticsearch-6.7.0.tar.gz
mv elasticsearch-6.7.0 elasticSearch
cd elasticSearch

添加用户组/用户

  • 因不能用root用户启动elasticSearch,会提示:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    1. 增加用户组:groupadd elastic
    2. 增加用户并归到用户组:useradd elsearch -g elastic
    3. 修改密码:passwd elastic

修改目录所属用户和用户组

chown -R elastic:elastic elasticSearch

修改系统相关配置

修改文件数上限
  1. 如果没有增加,启动会报错:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
  2. vim /etc/security/limits.conf
* soft     nofile     65536
* hard     nofile     131072
* soft     nproc      2048
* hard     nproc      4096
  1. 检查是否修改成功
ulimit -n
修改内存权限
  1. 如果没有增加,启动会报错:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  2. 不能通过sysctl -w vm.max_map_count=262144这种方式(重启会失效),必须采用下面文件方式
  3. vim /etc/sysctl.conf
vm.max_map_count=655360
fs.file-max=655360

4.检查是否修改成功

sysctl -p

修改elasticsearch.yml

  1. vim config/elasticsearch.yml
  2. 通过/network查找,修改为虚拟机的IP
  3. 通过/http.port查找,修改为9200

启动

  1. 编写启动脚本
su -l elastic -c "/home/software/elasticsearch/bin/elasticsearch -d &"
  1. 启动脚本
./start.sh

访问

  1. 浏览器访问http://xxx.xxx.xxx.xxx:9200
  2. 看到如下表示成功
    [外链图片转存中…(img-onFpT0qC-1606272749158)]

关闭

  1. 编写关闭脚本
pid=`ps -ef|grep elastic | grep -v grep |awk '{print $2}'`
kill -9 $pid
  1. 启动脚本
./shutdown.sh

问题解决过程

  • 进入创建的elastic用户,执行sysctl -w vm.max_map_count=262144报错:permission denied on key 'vm.max_map_count
  1. 尝试解决
    https://stackoverflow.com/questions/40451288/elasticsearch-failed-to-start-in-centos,
    依然报错:xxx is not in the sudoers file.This incident will be reported-7
  2. 最后exit elastic,用root用户执行该命令,https://www.cnblogs.com/zox2011/archive/2013/05/28/3103824.html
  • Java HotSpot™ 64-Bit Server VM warning: Cannot open file logs/gc.log due to Permission denied
  1. 第一次启动es使用了root用户,在config目录下创建了文件elasticsearch.keystore,只需要进入之后把文件删除,然后用es的用户启动就可以了,链接

Kibana

单机搭建

操作说明

  1. 所有命令都在root用户操作

下载Kibana

解压并改名

tar -zxvf kibana-6.7.0-linux-x86_64.tar
mv kibana-6.7.0-linux-x86_64 kibana
cd kibana

修改kibana.yml

  1. vim config/kibana.yml
server.port: 5601
elasticsearch.url: elasticSearch的访问地址
server.host: "192.168.52.167"
kibana.index: ".kibana"

启动

  1. 编写启动脚本
nohup ./kibana > ../logs/nohup.out 2> ../logs/error.out &
  1. 启动脚本
./start.sh

访问

  1. 浏览器访问http://xxx.xxx.xxx.xxx:5601
  2. 看到如下表示成功
    [外链图片转存中…(img-pfhQNWbw-1606272749162)]

关闭

  1. 编写关闭脚本
pid=`ps -ef | netstat -tunlp | grep 5601 | awk '{print $7}' | cut -d/ -f 1`
kill $pid
  1. 启动脚本
./shutdown.sh

问题解决过程

  • 如何关闭kibana
  1. 通过ps -ef|grep kibana找不到进程,因为 kibana 是node 写的。所以kibana 运行的时候是运行在node 里面
  2. ps -ef | netstat  -tunlp | grep 5601 | awk ‘{print $7}’| cut -d / -f -1
  3. awk使用
  4. cut使用
  5. kibana进程找不到的原因
  6. 关闭kibana

Logstash

单机搭建

操作说明

  1. 所有命令都在root用户操作

下载Logstash

解压并改名

tar -zxvf logstash-6.7.0.tar.gz
mkdir logstash
mkdir jar
mv logstash-6.7.0 logstash/
cd logstash

修改gem源

vim Gemfile
修改source为https://gems.ruby-china.com/

下载插件

有网环境
  1. 去https://rubygems.org/搜索想要的插件gem
  2. 以logstash output jdbc为例
cd bin/
logstash-plugin install logstash-output-jdbc
无网环境
  1. 在能上网的机器,按有网环境步骤下载
  2. 以logstash output jdbc为例
cd logstash-6.7.0/vendor/bundle/jruby/2.5.0
cd gems,复制logstash-output-jdbc-5.4.0到无网机器的logstash安装目录同个位置
cd ..
cd specifications,复制logstash-output-jdbc-5.4.0.gemspec到无网机器的logstash安装目录同个位置
cd logstash-6.7.0/
vim Gemfile,找到gem "logstash-output-jdbc"并添加到到无网机器的logstash安装目录的Gemfile

启动

nohup ./logstash-6.7.0/bin/logstash -f ./logstash-6.7.0/config/dataQuality/dataQuality.conf  > ./logstash-6.7.0/log-243/nohup.out &

查看日志

tail -f -n300 ./logstash-6.7.0/log-243/nohup.out 

关闭

pid=`jps | grep Logstash | awk '{print $1}'`
kill $pid

问题解决过程

  • Validating logstash-output-jdbc
    Unable to download data from https://gems.ruby-china.com/ - SocketError: Failed to open TCP connection to gems.ruby-china.com:443 (initialize: name or service not known) (https://gems.ruby-china.com/latest_specs.4.8.gz)
    ERROR: Installation aborted, verification failed for logstash-output-jdbc
  1. 因为ping外网都ping不通
  2. vim /etc/sysconfig/network-scripts/ifcfg-ens33,BOOTPROTO改为dhcp
  3. systemctl  restart  network
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值