1.关闭seLinux
setenforce 0
修改/etc/selinux/config将SELINUX=enforcing改为SELINUX=disabled
2.关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
3.配置centos7阿里云yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4.安装JDK
5.创建用户
useradd es
6.下载需要的安装包,这里下载的是6.1.1
cd /home/es/
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.1.1.tar.gz
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.1.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.tar.gz
tar -zxvf logstash-6.1.1.tar.gz
tar -zxvf kibana-6.1.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-6.1.1.tar.gz
chown -R es:es logstash-6.1.1
chown -R es:es kibana-6.1.1-linux-x86_64
chown -R es:es elasticsearch-6.1.1
7.安装es
找到config目录下的elasticsearch.yml文件,修改配置:
结尾加上
network.host: 0.0.0.0 #改为0.0.0.0对外开放,如对特定ip开放则改为指定ip
http.port: 9200 #可更改端口不为9200
配置完之后,因为ElasticSearch使用非root用户启动,所以切换上面创建的用户。
su -l es
启动 -d表示后台启动
./bin/elasticsearch -d
访问http://192.168.233.133:9200/可以看到如下信息,表示安装成功。
8.安装Logstash
cd logstash-6.1.1/config/
vim logstash.conf
添加内容
input {
file {
path => "/usr/share/tomcat/logs/*.log"
start_position => beginning
}
}
filter {
}
output {
elasticsearch {
hosts => "localhost:9200"
}
}
切换用户,启动logstash
su -l es
nohup ./bin/logstash -f /home/es/logstash-6.1.1/config/logstash.conf &
启动过后,检测服务有没有正确启动
ps -ef |grep logstash
9.安装kibana
cd /home/es/kibana-6.1.1-linux-x86_64/config
vim kibana.yml
在末尾添加
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://localhost:9200"
kibana.index: ".kibana"
切换用户
su -l es
后台启动
nohup ./bin/kibana &
启动后在浏览器打开http://192.168.233.133:5601,可以看到kibana的web交互界面:
至此三种服务已经搭建完成。