四寇甸、安裝:Elasticsearch:
1. 安裝java(在我的架構(gòu)是安裝過的)
Elasticsearch至少需要Java 8.版本的java,建議使用Oracle JDK 1.8.0_131版(官網(wǎng)建議)胃碾。如果沒符合標準,請自行升級筋搏。本文只描述新安裝java
[root@es-1 ~]# yum install -y java-1.8.0
[root@es-1 ~]# java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
2.導(dǎo)入Elasticsearch PGP密鑰
[root@es-1 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
3.建立rpm包的repo
[root@es-1 ~]# vim /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
4.安裝elasticsearch
[root@es-1 ~]# yum -y install elasticsearch
5.編輯配置文件(省略號代表有其他內(nèi)容仆百,但是不用修改)
[root@es-1 ~]# vim /etc/elasticsearch/elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
…………
#cluster.name: my-application
cluster.name: ELK #起名三個節(jié)點要一致
…………
# ------------------------------------ Node ------------------------------------
…………
#node.name: node-1
node.name: es-1 #節(jié)點名:三個節(jié)點不一致
…………
# ---------------------------------- Network -----------------------------------
……
#network.host: 192.168.0.1
network.host: 192.168.205.155 #當(dāng)前IP地址
#
# Set a custom port for HTTP:
#http.port: 9200 #端口號:默認9200
……
# --------------------------------- Discovery ----------------------------------
…………
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["192.168.205.155","192.168.205.156","192.168.205.157"]
#集群節(jié)點IP地址
…………
6.啟動、添加開機自啟
[root@es-1 ~]# systemctl daemon-reload #重載所有修改過的配置文件(刷新配置)
[root@es-1 ~]# systemctl start elasticsearch #開啟服務(wù)
[root@es-1 ~]# systemctl enable elasticsearch #設(shè)置開機自啟動
[root@es-1 ~]# systemctl status elasticsearch #檢查狀態(tài)
● elasticsearch.service – Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2018-05-24 10:20:04 CST; 3h 12min ago
7.查看端口狀態(tài)
[root@es-1 ~]# netstat -ntlt
tcp6 0 0 192.168.205.155:9200 :::* LISTEN
tcp6 0 0 192.168.205.155:9300 :::* LISTEN
#9200是默認端口
#9300是集群通信端口
8.其他節(jié)點配置
es-2和es-3的安裝和es-1步驟相同奔脐。不同之處為配置文件node.name:俄周、network.host:
9.相關(guān)命令
?檢查Elasticsearch是否運行
[root@es-1 ~]# curl -X GET "192.168.205.155:9200/"
{
"name" : "es-1",
"cluster_name" : "ELK",
"cluster_uuid" : "JBdisD6qT_aEbCbz5eZo8Q",
"version" : {
"number" : "5.6.9",
"build_hash" : "877a590",
"build_date" : "2018-04-12T16:25:14.838Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
?查詢集群狀態(tài)
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cat/nodes' #任選一臺機器執(zhí)行
192.168.205.157 19 45 0 0.00 0.01 0.05 mdi - es-3
192.168.205.156 20 43 0 0.00 0.01 0.05 mdi - es-2
192.168.205.155 26 74 0 0.30 0.18 0.09 mdi * es-1 #帶*號的是自動選舉出來的master
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cat/nodes?v'
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.205.157 20 45 0 0.00 0.01 0.05 mdi - es-3
192.168.205.156 20 43 0 0.00 0.01 0.05 mdi - es-2
192.168.205.155 26 74 0 0.05 0.12 0.08 mdi * es-1
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cluster/state/nodes?pretty'
{
"cluster_name" : "ELK", #名字
"nodes" : {
"fkzXpqmxTkCFdYOUqkWw4g" : { #ID值
"name" : "es-3", #node名字
"ephemeral_id" : "c0tVVqFvRUq9vBY0FAGW2Q", #id
"transport_address" : "192.168.205.157:9300", #集群通訊地址
"attributes" : { }
},
"4ZbLhzt6Q5GK4kyICnYWHg" : { #ID值
"name" : "es-2", #node名字
"ephemeral_id" : "E28qTcY_QxWHuZkENO9-gQ", #id
"transport_address" : "192.168.205.156:9300", #集群通訊地址
"attributes" : { }
},
"SVXe8qm9RACCRl1Zb1qs8w" : { #ID值
"name" : "es-1", #node名字
"ephemeral_id" : "w19b7MK_RO221SrwarV8Cg", #id
"transport_address" : "192.168.205.155:9300", #集群通訊地址
"attributes" : { }
}
}
}
?查詢集群中的master
[root@es-1 ~]# curl -XGET 'http://192.168.205.156:9200/_cluster/state/master_node?pretty'
{
"cluster_name" : "ELK",
"master_node" : "SVXe8qm9RACCRl1Zb1qs8w"
}
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cat/master?v'
id host ip node
SVXe8qm9RACCRl1Zb1qs8w 192.168.205.155 192.168.205.155 es-1
?查詢集群的健康狀態(tài)
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cat/health?v'
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1527142257 14:10:57 ELK green 3 3 0 0 0 0 0 0 - 100.0%
###Status下邊是狀態(tài)顯示
[root@es-1 ~]# curl -XGET 'http://192.168.205.155:9200/_cluster/health?pretty'
{
"cluster_name" : "ELK",
"status" : "green", ##代表正常
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
10.相關(guān)文件路徑
/etc/elasticsearch/elasticsearch.yml ---主配置文件
/etc/elasticsearch/jvm.options ---jvm參數(shù)配置文件
/etc/elasticsearch/log4j2.properties ----日志配置文件
/etc/sysconfig/elasticsearch ---系統(tǒng)配置文件
/usr/share/elasticsearch/bin ---二進制腳本文件
/var/lib/elasticsearch ---在節(jié)點上分配的每個索引/分片的數(shù)據(jù)文件的位置。
/var/log/elasticsearch ---日志文件位置
/usr/share/elasticsearch/plugins ---插件目錄
/etc/elasticsearch/scripts ---腳本文件位置
至此elasticsearch集群布置結(jié)束
上一篇:filebeat+ELK+kafka集群搭建(四:logstash部署)
下一篇:filebeat+ELK+kafka集群搭建(六:kibana部署)