ES集群部署
环境: MacOS
创建三个副本
修改 elasticsearch.yml文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| // 解决跨域 http.cors.enabled: true http.cors.allow-origin: "*" // 指定当前节点的ip以及端口号 network.host: localhost http.port: 18122 // 集群通信所使用的端口号 transport.tcp.port: 9303 // 指定节点的名称 node.name: node-1001 node.master: true node.data: true // 集群的名称,统一集群下所有节点的配置都相同 cluster.name: my-application
|
对于node-1001配置
1 2 3 4 5 6 7 8 9
| cluster.name: my-application node.name: node-1001 node.master: true node.data: true network.host: localhost http.port: 18120 transport.tcp.port: 9301 http.cors.enabled: true http.cors.allow-origin: "*"
|
对于node-1002配置,需要与node-1001建立,需要增加配置
1 2 3 4 5 6 7 8 9 10 11 12 13
| cluster.name: my-application node.name: node-1002 node.master: true node.data: true network.host: localhost http.port: 18121 transport.tcp.port: 9302 http.cors.enabled: true http.cors.allow-origin: "*" // node-1002需要发现第一个节点,与其建立集群 discovery.seed_hosts: ["localhost:9301"] discovery.zen.fd.ping_timeout: 1m discovery.zen.fd.ping_retries: 5
|
对于node-1003配置,需要与node-1001、node-1002建立
1 2 3 4 5 6 7 8 9 10 11 12 13
| cluster.name: my-application node.name: node-1003 node.master: true node.data: true network.host: localhost http.port: 18122 transport.tcp.port: 9303 http.cors.enabled: true http.cors.allow-origin: "*" // node-1002需要发现第一个节点,与其建立集群 discovery.seed_hosts: ["localhost:9301", "localhost:9302"] discovery.zen.fd.ping_timeout: 1m discovery.zen.fd.ping_retries: 5
|
进入bin目录,依次启动node-1001、node-1002、node-1003
查看集群状态
1
| localhost:18120/_cluster/health
|
显示3个节点
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| { "cluster_name": "my-application", "status": "green", "timed_out": false, "number_of_nodes": 3, "number_of_data_nodes": 3, "active_primary_shards": 0, "active_shards": 0, "relocating_shards": 0, "initializing_shards": 0, "unassigned_shards": 0, "delayed_unassigned_shards": 0, "number_of_pending_tasks": 0, "number_of_in_flight_fetch": 0, "task_max_waiting_in_queue_millis": 0, "active_shards_percent_as_number": 100.0 }
|