Centos7安装ELK6.5.4
2019-01-11 本文已影响0人
日常琐事一如年少模样
Centos7安装ELK6.5.4
1、预安装JDK8
2、禁用SELinux
原因:kibana始终都是报Nginx502Bad
3、安装ES
# 导入秘钥
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
# 下载rpm源
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.rpm
# 安装
rpm -ivh elasticsearch-6.5.4.rpm
# 配置elasticsearch.yml
vim /etc/elasticsearch/elasticsearch.yml
# 取消下面两行的注释
bootstrap.memory_lock: true # 设置堆大小为可用内存的一半左右
http.port: 9200
# 重新加载配置文件
systemctl daemon-reload
# 设置自启
systemctl enable elasticsearch
# 启动
systemctl start elasticsearch
# 查看是否启动成功: 9200端口
netstat -plntu
4、安装Nginx
# 安装软件仓库EPEL,用于yum install xxx提供软件包
yum install -y epel-release
# 安装Nginx及依赖模块
yum install nginx httpd-tools -y
# 删除配置
vim /etc/nginx/nginx.conf
# 删除80端口的server{}配置
image.png
# 创建kibana代理
vim /etc/nginx/conf.d/kibana.conf
# 添加nginx配置
server {
listen 80;
server_name elk-stack.co;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.kibana-user;
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
} }
# 创建elasticsearch代理
vim /etc/nginx/conf.d/elasticsearch.conf
# 添加nginx配置
server {
listen 81;
server_name elk-stack.co;
location / {
proxy_pass http://localhost:9200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
} }
# 添加basic认证
htpasswd -c /etc/nginx/.kibana-user admin
# 检测nginx配置文件
nginx -t
# 设置开机自启
systemctl enable nginx
# 启动Nginx
systemctl start nginx
5、安装Kibana
# 下载rpm源
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.5.4-x86_64.rpm
# 安装kibana
rpm -ivh kibana-6.5.4-x86_64.rpm
# 修改配置
vim /etc/kibana/kibana.yml
# 取消以下三行的注释
server.port: 5601
server.host: "localhost"
elasticsearch.url: "http://localhost:9200"
# 设置开机自启
systemctl enable kibana
# 启动Kibana
systemctl start kibana
# 查看是否启动成功:5601端口
netstat -plntu
6、安装Logstash
# 下载rpm源
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.5.4.rpm
# 安装
rpm -ivh logstash-6.5.4.rpm
# 设置开机自启
systemctl enable logstash
# 启动
systemctl start logstash
# 开放防火墙
firewall-cmd --zone=public --add-port=80/tcp --add-port=81/tcp --permanent
firewall-cmd --reload