elasticsearch集群搭建

es集群搭建网上百度一大堆,有很详细的步骤,在这里还是记录一下自己的搭建过程,分享经验(主要是我觉得这个搭建比较简单);

准备材料

集群主机3台:192.168.54.16、192.168.54.17、192.168.54.18

es版本:elasticsearch-2.4.0.tar.gz

步骤:

一、解压elasticsearch-2.4.0.tar.gz到/export/home/tools/elasticsearch-2.4.0

二、修改配置文件vi elasticsearch.yml,以下几个主要关注的配置

#集群名称
# ---------------------------------- Cluster ----------------------------
cluster.name: gate-es

# ------------------------------------ Node ----------------------------
#节点名称(自定义),3台主机分别设置为gate01、gate02、gate03
node.name: gate01
node.master: true
node.data: true

# ----------------------------------- Paths ----------------------------
#数据存放目录
path.data: /export/home/data/es/data
#日志目录
path.logs: /export/home/data/es/log
path.work: /export/home/data/es/work

#------------------------- ------Network -----------------------------
#服务器地址
network.host: 0.0.0.0  --默认
#http访问端口
http.port: 9200    --默认9200
#tcp服务端口
transport.tcp.port: 9300  --默认9300
http.enabled: true

三、另外2台主机执行步骤同上,或者将目录拷贝到2台主机上并修改节点node.name

scp -r elasticsearch-2.4.0_master/ [email protected]192.168.54.17:/export/home/tools/

四、集群配置过程完成,分别启动3个节点

#启动es 
./elasticsearch -d
#查看进程
ps -ef|grep elasticsearch

五、通过curl -XPUT 配置模版,在其中一个节点上设置就可以了

curl -XPUT 192.168.54.16:9200/_template/template_s_command_log -d '{"template":"s_command_log_*","order":0,"settings":{"number_of_shards":"3","number_of_replicas":"1","index.refresh_interval":"30s"},"mappings":{"s_command_log": {"properties": {"sigle_account": {"type": "string"},"result": {"type": "string"},"dev_model": {"type": "string"},"host": {"type": "string"},"dev_account": {"type": "string"},"vendor_id": {"type": "string"},"date": {"type": "string"},"login_ip": {"type": "string"},"@version": {"type": "string"},"ip": {"type": "string"},"id": {"type": "string"},"@timestamp": {"format": "strict_date_optional_time||epoch_millis","type": "date"},"command": {"type": "string"},"path": {"type": "string"},"sendtime": {"type": "long"},"dev_type": {"type": "string"}}}}}'

六、查看模版

curl -XGET 192.168.54.18:9200/_template/template_s_command_log

 

至此、es集群就搭建完成了,下面通过页面访问一下http://127.0.0.1:9200/_plugin/head

elasticsearch集群搭建

通过sql引擎执行查询:http://127.0.0.1:9200/_plugin/sql

elasticsearch集群搭建