環境:Centos7, jdk1.8html
安裝logstashnode
1.下載logstashlinux
地址:https://artifacts.elastic.co/downloads/logstash/logstash-7.0.0.tar.gzgit
2.解壓logstash壓縮包github
tar zxvf logstash-7.0.0.tar.gznpm
3.config文件夾下建立配置文件json
vim logstash-elasticsearch.confvim
添加如下內容:瀏覽器
input {
# For detail config for log4j as input,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-log4j.html
tcp {
mode => "server"
host => "0.0.0.0"
port => 9000
codec => json_lines
}
}
filter {
#Only matched data are send to output.
}
output {
# For detail config for elasticsearch as output,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
elasticsearch {
action => "index" #The operation on ES
hosts => ["localhost:9200"] #ElasticSearch host, can be array.
index => "demolog" #The index to write data to.
}
}服務器
4.後臺啓動logstash
./bin/logstash -f config/logstash-elasticsearch.conf &
安裝elasticsearch
1.下載elasticsearch
地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
2.解壓elasticsearch壓縮包
tar zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz
3.修改elasticsearch.yml
啓用如下配置
cluster.name: demo-cluster
node.name: node-1
path.data: /tmp/soft/elasticsearch-7.0.0/data
path.logs: /tmp/soft/elasticsearch-7.0.0/logs
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]
gateway.recover_after_nodes: 1
action.destructive_requires_name: true
4.建立組
groupadd elasticsearch
注:elasticsearch爲組名
5.建立用戶
useradd elasticsearch -g elasticsearch -p elasticsearch
注:第一個elasticsearch爲用戶名,第二個elasticsearch爲組名,第三個elasticsearch爲用戶密碼
6.目錄受權
chown -R elasticsearch:elasticsearch /tmp/soft/elasticsearch-7.0.0
7.修改/etc/security/limits.conf
在文件末尾加入如下配置信息
* soft nofile 65536
* hard nofile 131072
* soft nproc 65536
* hard nproc 131072
* soft memlock unlimited
* hard memlock unlimited
8.修改/etc/sysctl.conf
在文件末尾加入如下配置信息
vm.max_map_count=655360
而後執行sysctl -p
9.添加elasticsearch到systemctl
在/etc/systemd/system下建立elasticsearch.sevice, 添加如下內容
[Unit]
Description=elasticsearch.service
After=network.target
[Service]
LimitCORE=infinity
LimitNOFILE=65536
LimitNPROC=65536
Group=elasticsearch
User=elasticsearch
Environment=JAVA_HOME=/tmp/soft/jdk1.8.0_211
ExecStart=/tmp/soft/elasticsearch-7.0.0/bin/elasticsearch
[Install]
WantedBy=multi-user.target
10.啓動elasticsearch
設置開機啓動 systemctl enable elasticsearch
啓動elasticsearch systemctl start elasticsearch
查看elasticsearch狀態 systemctl status elasticsearch
中止elasticsearch systemctl stop elasticsearch
11.防火牆設置
查看防火牆狀態 firewall-cmd --state
關閉防火牆 systemctl stop firewalld.service
禁止防火牆開機啓動 systemctl disable firewalld.service
12.驗證是否啓動成功
執行curl http://127.0.0.1:9200
返回如下信息表示啓動成功
{
"name" : "node-1",
"cluster_name" : "demo-cluster",
"cluster_uuid" : "v9x4jEImQQ6ralBh63jVTg",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
安裝elasticsearch head
1.安裝依賴
yum install epel-release
yum install nodejs npm
yum install -y git
2.下載elasticsearch-head
git clone git://github.com/mobz/elasticsearch-head.git
3.安裝
進入elasticsearch head目錄後執行npm install進行安裝
4.配置elasticsearch.yml
在elasticsearch.yml配置文件末尾加入如下配置
http.cors.enabled: true
http.cors.allow-origin: "*"
5.修改elasticsearch-head/Gruntfile.js
connect: {
server: {
options: {
port: 9100,
base: '.',
keepalive: true
}
}
}
修改成
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
6.修改elasticsearch-head/_site/app.js
this.base_uri = this.config.base_uri;
修改成
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.29.22.151:9200";
注:172.29.22.151:9200爲elasticsearch的訪問地址
7.啓動
後臺啓動 npm run start &
8.鏈接elasticsearch
在瀏覽器輸入elasticsearch head的訪問地址(個人elasticsearch和elasticsearch head安裝在同一臺服務器):http://172.29.22.151:9100
在打開的界面是中輸入elasticsearch的訪問地址:http://172.29.22.151:9200 後點擊鏈接便可鏈接到elasticsearch
安裝kibana
1.下載kibana
地址:https://artifacts.elastic.co/downloads/kibana/kibana-7.0.0-linux-x86_64.tar.gz
2.解壓kibana壓縮包
tar zxvf kibana-7.0.0-linux-x86_64.tar.gz
3.修改config/kibana.yml
啓用如下配置:
# 172.29.22.151爲本機IP地址
server.host: "172.29.22.151"
# http://172.29.22.151:9200爲elasticsearch服務地址
elasticsearch.hosts: ["http://172.29.22.151:9200"]
4.後臺啓動kibana
./bin/kibana &