1 环境
软件:elasticsearch-5.5.1.tar(安装在服务器),kibana-5.5.0-darwin-x86_64.tar(安装在客户端)
机器:10.10.28.180,10.10.28.181,均开放9200和9300端口
2 准备
tar -xvf elasticsearch-5.5.1.tar
tar -xfv kibana-5.5.0-darwin-x86_64.tar
配置进程最大打开的文件描述符:
sudo vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
vi elasticsearch-5.5.1/bin/elasticsearch.yml
ulimit -n 65536
配置ES启动时所用内存:
vi elasticsearch-5.5.1/conf/jvm.options
-Xms1g
-Xmx1g
配置kibana:
elasticsearch.url: "http://10.10.28.180:9200"
配置ES集群:
10.10.28.180:
cluster.name: my-es
node.name: node-01
network.host: 10.10.28.180
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["10.10.28.180"]
10.10.28.181:
cluster.name: my-es
node.name: node-02
network.host: 10.10.28.181
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.data: true
discovery.zen.ping.unicast.hosts: ["10.10.28.180"]
3 启动
先启动180,再启动181:
./elasticsearch-5.5.1/bin/elasticsearch
启动客户端的kibana:
./kibana-5.5.0-darwin-x86_64/bin/kibana
4 使用
打开http://localhost:5601即可看到ES状态,以及对ES进行操作
插入:
curl -XPOST http://10.10.28.180:9200/mytest/log -d '{
"date" : "1534966686000",
"user" : "wangzi",
"mesg" : "first message into Elasticsearch"
}'
检索:
curl -XGET http://10.10.28.180:9200/mytest/log/${id}