192.168.30.121,192.168.30.122,192.168.30.123上配置elasticsearch集群:
在所有主机上添加elk用户
在所有主机上解压elasticsearch,并更改属主,组:
修改192.168.30.121配置文件:
#cat>elasticsearch/config/elasticsearch.yml<<EOF
cluster.name: my-es
node.name: node-1
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 192.168.30.121
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.30.121", "192.168.30.122","192.168.30.123"]
discovery.zen.minimum_master_nodes: 2
node.master: true
node.data: true
EOF修改192.168.30.122配置:
#cat>elasticsearch/config/elasticsearch.yml<<EOF
cluster.name: my-es
node.name: node-2
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 192.168.30.122
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.30.121", "192.168.30.122","192.168.30.123"]
discovery.zen.minimum_master_nodes: 2
node.master: true
node.data: true
EOF
修改192.168.30.123配置:
#cat>elasticsearch/config/elasticsearch.yml<<EOF
cluster.name: my-es
node.name: node-3
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 192.168.30.123
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.30.121", "192.168.30.122","192.168.30.123"]
discovery.zen.minimum_master_nodes: 2
node.master: true
node.data: true
EOF启动:
cd /usr/local/elk/elasticsearch/logs && nohup sudo -u elk /usr/local/elk/elasticsearch/bin/elasticsearch &
检查:
安装head:
检查依赖包:
安装:
#git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm config set registry https://registry.npm.taobao.org
npm install #安装较慢,失败可多次执行
修改vim Gruntfile.js
connect: {
server: {
options: {
hostname: "192.168.30.121",
port: 9100,
base: '.',
keepalive: true
}
}
}
});修改app.js:
[root@k8s-etcd1elasticsearch-head]# vim _site/app.js
this.base_uri =this.config.base_uri || this.prefs.get("app-base_uri") ||"http://192.168.30.121:9200";
在所有elasticsearch的配置文件追添以下两行,然后重启elasticsearch:
http.cors.enabled: true
http.cors.allow-origin: "*"启动head:
[root@k8s-etcd1 elk]# cdelasticsearch-head/ && nohup grunt server -d &
检测: