赞
踩
主机名 :node1
IP地址 | 192.168.121.147 |
---|---|
角色 | es01,redis01 |
主机名 :node2
IP地址 | 192.168.121.148 |
---|---|
角色 | es02,redis02 |
主机名 :node3
IP地址 | 118.190.146.109 |
---|---|
角色 | es03,tomcat,nginx |
三台机器都是CentOS 7.6,内存>=3G
1、设置主机名和hosts解析
cat >> /etc/hosts << EOF
192.168.121.147 node1
192.168.121.148 node2
118.190.146.109 node3
EOF
2、时间同步
3、部署jdk
三台机器都部署jdk,建议内存3G以上
rpm -ivh jdk-8u144-linux-x64.rpm
java -version
# vim /etc/yum.repos.d/elk.repo
[elk] name=elk 7.x
baseurl=https://mirrors.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-7.x/
gpgcheck=0
这里我是用的都是离线rpm包
安装:# yum install -y elasticsearch-7.2.0
如果缺少epel源
yum -y install epel-release
node1节点的配置
# 备份 cp /etc/elasticsearch/elasticsearch.yml{,.bak} grep '^[a-Z]' /etc/elasticsearch/elasticsearch.yml #修改主节点相关配置 vim /etc/elasticsearch/elasticsearch.yml cluster.name: my-elk node.name: node1 path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: 192.168.121.147 http.port: 9200 discovery.seed_hosts: ["node1", "node2", "node3"] cluster.initial_master_nodes: ["node1"] #行末添加 node.master: true node.data: false node.ingest: false node.ml: false cluster.remote.connect: false
(1)安装head插件
yum install -y nodejs npm
(2)下载head插件
cd /var/lib/elasticsearch/
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
#解压
yum install unzip
unzip master.zip
(3)安装依赖包
yum install openssl bzip2 unzip -y
下载运行head必要的文件(放置在文件夹/tmp下)
cd /tmp
wget https://npm.taobao.org/mirrors/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
用以下命令把下载到的包添加到npm cache目录中
npm cache add phantomjs
开始安装依赖:
cd -
cd elasticsearch-head-master/
# 直接使用npm安装时间久,依赖网络,替换我淘宝的cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 安装依赖
cnpm install
(4)修改配置文件
vim Gruntfile.js
#找到并修改
options: {
port: 9100,
base: '.',
keepalive: true,
hostname: '*'
}
## 注意:true后面有逗号
修改elasticsearch-head默认连接地址,将localhost改为本机IP
vim _site/app.js
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http:192.168.121.148:9200";
(5)修改elasticSearch配置文件并启动ElasticSearch
修改elasticsearch的配置文件elasticsearch.yml,以允许跨域访问,在文末追加如下代码即可
http.cors.enabled: true
http.cors.allow-origin: "*"
重启:
systemctl restart elasticsearch
启动插件:
# cd /var/lib/elasticsearch/elasticsearch-head-master/
# nohup ./node_modules/grunt/bin/grunt server &
访问IP:9100就能看到我们集群信息
1、kibana安装配置
yum install -y https://mirrors.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-7.x/7.2.0/kibana-7.2.0-x86_64.rpm
可以配置多个端口的kibana,每个系统单独开一个kibana端口号,比如财务系统kibana使用5601端
口、租赁系统kibana使用5602,然后nginx做代理访问配置。
[root@elk-node03 ~]# cp -r /etc/kibana/ /etc/cw-5601-kibana
[root@elk-node03 ~]# cp -r /etc/kibana/ /etc/zl-5602-kibana
vim /etc/cw-5601-kibana/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
kibana.index: ".cw-kibana"
elasticsearch.hosts: ["http://192.168.121.147:9200"]
vim /etc/zl-5602-kibana/kibana.yml
server.port: 5602
server.host: "0.0.0.0"
kibana.index: ".zl-kibana"
elasticsearch.hosts: ["http://192.168.121.147:9200"]
提供服务脚本:
cp -a /etc/systemd/system/kibana.service /etc/systemd/system/kibana_cw.service
修改:
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/cw-5601-kibana/kibana.yml"
cp -a /etc/systemd/system/kibana.service /etc/systemd/system/kibana_zl.service
修改:
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/zl-5602-kibana/kibana.yml"
启动服务:
systemctl daemon-reload
systemctl start kibana_cw.service kibana_zl.service
systemctl enable kibana_cw.service kibana_zl.service
查看:
lsof -i:5601
lsof -i:5601
访问IP:5601
配置访问验证
# cat /etc/nginx/conf.d/cw_kibana.conf server { listen 15601; server_name localhost; location / { proxy_pass http://192.168.150.13:5601/; auth_basic "Access Authorized"; auth_basic_user_file /etc/nginx/conf.d/cw_auth_password; } } # cat /etc/nginx/conf.d/zl_kibana.conf server { listen 15602; server_name localhost; location / { proxy_pass http://192.168.150.13:5602/; auth_basic "Access Authorized"; auth_basic_user_file /etc/nginx/conf.d/zl_auth_password; } }
#下载工具
yum install httpd-tools
htpasswd -c /etc/nginx/conf.d/cw_auth_password cwlog
htpasswd -c /etc/nginx/conf.d/zl_auth_password zllog
# nginx -t
# systemctl restart nginx
# systemctl enable nginx
访问IP:15601
LogStash由JRuby语言编写,基于消息(message-based)的简单架构,并运行在Java虚拟机
(JVM)上。不同于分离的代理端(agent)或主机端(server),LogStash可配置单一的代理端
(agent)与其它开源软件结合,以实现不同的功能。
logStash的四大组件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。