K8S 日志收集(三):ES 集群安装
集群设备
ip | role |
---|---|
192.168.19.93 | master、data |
192.168.19.94 | data |
安装java
elasticsearch 需要java环境
elasticsearch-6.x 要求java版本1.8.0_131 or later
rpm -ivh http://192.168.19.111:8080/panjunbai/jdk-8u141-linux-x64.rpm
安装elasticsearch
可以使用yum源安装,也可以下载rpm包直接安装
cat /etc/yum.repos.d/elastic.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
yum install -y elasticsearch
rpm -ivh http://192.168.19.111:8080/panjunbai/elasticsearch-6.2.4.rpm
配置elasticsearch通用配置
配置java运行内存大小,修改/etc/elasticsearch/jvm.options文件中-Xms -Xmx的值,为java虚拟机运行的内存最小和最大值,必须相同。其他使用默认值即可。
[root@es-2 elasticsearch]# cat /etc/elasticsearch/jvm.options |grep "^-Xm"
-Xms6g
-Xmx6g
创建elasticsearch运行的日志路径和数据路径
[root@es-2 elasticsearch]# mkdir /data/es-data
[root@es-2 elasticsearch]# mkdir /data/es-log
[root@es-2 elasticsearch]# chown -R elasticsearch.elasticsearch /data
192.168.19.93 elasticsearch 配置
[root@es-2 elasticsearch]# cat elasticsearch.yml |grep -v "^#"
cluster.name: test-panjunbai
node.name: node-94
path.data: /data/es-data
path.logs: /data/es-log
network.host: 192.168.19.94
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.19.93", "192.168.19.94"]
discovery.zen.minimum_master_nodes: 1
node.master: true
node.data: true
192.168.19.94 elasticsearch 配置
[root@es-1 elasticsearch]# cat elasticsearch.yml
cluster.name: test-panjunbai
node.name: node-93
path.data: /data/es-data
path.logs: /data/es-log
network.host: 192.168.19.93
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.19.93", "192.168.19.94"]
discovery.zen.minimum_master_nodes: 1
node.master: false
node.data: true
在192.168.19.93、192.168.19.94 启动elasticsearch
systemctl start elasticsearch
启动成功后访问结果
[root@es-2 es-log]# curl 192.168.19.93:9200
{
"name" : "node-93",
"cluster_name" : "test-panjunbai",
"cluster_uuid" : "joXSilqGTiyvah-VcIqlYQ",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
[root@es-2 es-log]# curl 192.168.19.94:9200
{
"name" : "node-94",
"cluster_name" : "test-panjunbai",
"cluster_uuid" : "joXSilqGTiyvah-VcIqlYQ",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}