软件下载地址: https://www.elastic.co/cn/start
根据自己的电脑系统选择对应版本下载安装/解压
开始配置config文件
实例中以一台主节点和一台边缘节点展开
主节点:config/elasticsearch.yml(仅启用的代码)
cluster.name: es-cluster #开始集群名称
node.name: node-1 #设置当前节点名称
node.master: true #设置为主节点
network.host: 192.168.106.128 #固定ip地址
#http.port: 9200 #端口可使用默认9200
discovery.seed_hosts: ["192.168.106.128", "192.168.106.129"] #设置主节点和子节点的ip地址
cluster.initial_master_nodes: ["node-1"] #设置为主节点的名称即可
子节点:config/elasticsearch.yml(仅启用代码)
cluster.name: es-cluster #开始集群名称
node.name: node-2 #设置当前节点名称
node.master: false #设置为子节点
network.host: 192.168.106.129 #固定ip地址
#http.port: 9200 #端口可使用默认9200
discovery.seed_hosts: ["192.168.106.128", "192.168.106.129"] #设置主节点和子节点的ip地址
cluster.initial_master_nodes: ["node-1"] #设置为主节点的名称即可
使用命令:bin/elasticsearch 启动主/子程序
查看是否配置成功:
http://192.168.106.128:9200/
{
"name": "node-1",
"cluster_name": "es-cluster",
"cluster_uuid": "i1I7P9zdQ_Sy9y2yjSbBzw",
"version": {
"number": "7.5.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "e9ccaed468e2fac2275a3761849cbee64b39519f",
"build_date": "2019-11-26T01:06:52.518245Z",
"build_snapshot": false,
"lucene_version": "8.3.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
http://192.168.106.128:9200/
{
"name": "node-2",
"cluster_name": "es-cluster",
"cluster_uuid": "i1I7P9zdQ_Sy9y2yjSbBzw",
"version": {
"number": "7.5.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "e9ccaed468e2fac2275a3761849cbee64b39519f",
"build_date": "2019-11-26T01:06:52.518245Z",
"build_snapshot": false,
"lucene_version": "8.3.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
检查集群是否成功: http://192.168.106.128:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.106.128 24 91 0 0.25 0.08 0.02 dilm * node-1
192.168.106.129 15 48 0 0.31 0.21 0.12 dil - node-2
状态查看: http://192.168.106.129:9200/_cluster/state
至此,如上方状态返回结果。那么恭喜你配置成功!
静默运行:
要将Elasticsearch作为守护程序运行,请在命令行上指定-d,然后使用-p选项将进程ID记录在文件中:
bin/elasticsearch -d -p pid
日志消息可以在$ ES_HOME / logs /目录中找到。
关闭Elasticsearch,停止pid文件中记录的进程ID
pkill -F pid