ES学习笔记(二):集群配置与启动 --mac环境

1 环境准备:

  1. 复制原有es文件,分别为三个文件夹:Node-8001,Node-8002,Node-8003
  2. 删除三个文件夹中的data文件,清除log文件
  3. 修改配置文件

1.1修改配置文件

配置文件路径es/config/elasticsearch.yml

Node-8001文件详情:

# 集群名称

cluster.name: my-application

# 节点名称

node.name: node-8001

# master节点

node.master: true

# 是否是数据节点

node.data: true

# 主机名称

network.host: localhost

# http端口

http.port: 8001

# tcp监听端口

transport.tcp.port: 9301

# 跨域配置

http.cors.enabled: true

http.cors.allow-origin: “*”

Node-8002文件详情:

# 集群名称

cluster.name: my-application

# 节点名称

node.name: node-8002

# master节点

node.master: true

# 是否是数据节点

node.data: true

# 主机名称

network.host: localhost

# http端口

http.port: 8002

# tcp监听端口

transport.tcp.port: 9302

#寻找master节点(不同于8001的地方)

discovery.seed_hosts: [“localhost:9301”]

discovery.zen.fd.ping_timeout: 1m

discovery.zen.fd.ping_retries: 5

# 跨域配置

http.cors.enabled: true

http.cors.allow-origin: “*”

Node-8003文件详情:

# 集群名称

cluster.name: my-application

# 节点名称

node.name: node-8003

# master节点

node.master: true

# 是否是数据节点

node.data: true

# 主机名称

network.host: localhost

# http端口

http.port: 8003

# tcp监听端口

transport.tcp.port: 9303

#寻找master节点(不同于8002的地方)

discovery.seed_hosts: [“localhost:9301”,“localhost:9302”]

discovery.zen.fd.ping_timeout: 1m

discovery.zen.fd.ping_retries: 5

# 跨域配置

http.cors.enabled: true

http.cors.allow-origin: “*”

2 启动

文件配置好后,分别在bin目录下启动:./elasticsearch

查看节点启动情况:

方式路径
GEThttp://localhost:8001/_cluster/health

result:

{
"cluster_name":“my-application”,
"status":“green”,
"timed_out":false,
"number_of_nodes":3,
"number_of_data_nodes":2,
"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
}

3 常见启动报错

  • 现象

BindHttpException[Failed to bind to 127.0.0.1:1001]; nested: SocketException[Permission denied];

原因:

Linux不允许普通用户绑定到<= 1024 的端口,因为设置的端口号是1001,因此它失败了“权限被拒绝”。

mac的内核使用的是Linux,windows电脑不会有这个问题

解决:

最快和最安全的解决方案是使用大于1024的值配置端口,所以我改成了8001.

  • 现象

java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/opt/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])

原因

后台已经存在相同的elasticsearch的进程端口号。

解决

找到该进程 ps -ef | grep elasticsearch

杀掉该进程即可 kill -9 NNN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值