Elasticsearch 单机多节点部署

Elasticsearch 单机多节点

  • 下载Elasticsearch安装包(本文实验环境版本为5.5.1)
  • 将安装包复制多份,然后修改Elasticsearch目录中config下的elasticsearch.yml文件下列属性值:
cluster.name: pekxxoo
node.name: node-2
node.max_local_storage_nodes: 2
http.port: 9201

cluster.name: 保证集群名称一致,再启动时相同集群名称的节点会自动加入到集群中
node.name: 节点名称,自己定义,只要相互不冲突就可以;
node.max_local_storage_nodes:最大节点个数,按照你准备部署的个数设置;
http.port: 端口号,只要不冲突就行;

  • 进入Elasticsearch安装包\bin目录下,执行下列命令将其安装为本机服务:
    elasticsearch-service.bat install
    这里需要注意,因为我们是进行单机多节点安装,因此需要修改elasticsearch-service.bat文件中的服务名称,避免本机服务名冲突,我的修改如下:
if errorlevel 1 goto x86
set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe
set SERVICE_ID=elasticsearch-service-x64-2
set ARCH=64-bit
goto checkExe

:x86
set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x86.exe
set SERVICE_ID=elasticsearch-service-x86-2
set ARCH=32-bit

只需修改上文中set SERVICE_ID等号后的值即可;

  • 然后在\bin目录下运行elasticsearch-service.bat manager命令,打开服务管理界面,启动服务;

cat命令

当节点都运行起来后,我们可以使用如下命令查询相关信息:
curl host:port/_cat

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   493  100   493    0     0  32866      0 --:--:-- --:--:-- --:--:--  481k=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates

以上列出了_cat命令可以查询的相关信息

headers

headers通过这个参数可以指定输出的字段
curl host:port/_cat/master?h=host,ip,node

Head插件

ES集群管理工具,它是完全油html5编写的独立网页程序,可视化管理集群状态

5.x安装Head插件
Running with built in server

没有安装npm的这里不做详细描述,可以参考这里

5.x版本的elasticsearch可能会出现访问http://localhost:9100/后不能连接集群的状况,需要在配置文件elasticsearch.yml中加入以下内容:

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization

现在就可以成功使用elasticsearch-head方便的管理集群:

2438927-326bc705c7506eef.png

image.png

很抱歉,目前最新版本的 Elasticsearch 是 7.15.1,没有 8.5.3 版本。不过我可以为您介绍一下 Elasticsearch单机安装部署步骤。 1. 下载 Elasticsearch:您可以从 Elasticsearch 官方网站(https://www.elastic.co/downloads/elasticsearch)下载适合您操作系统的安装包。 2. 解压安装包:将下载的安装包解压到您选择的目录中。 3. 配置 Elasticsearch:进入解压后的目录,找到 `config` 文件夹,编辑 `elasticsearch.yml` 文件。您可以根据需要修改以下配置项: - `cluster.name`:集群名称,默认为 "elasticsearch"。 - `node.name`:节点名称,默认为随机生成的唯一标识。 - `path.data`:数据存储路径,默认为 "data" 文件夹。 - `path.logs`:日志存储路径,默认为 "logs" 文件夹。 4. 启动 Elasticsearch:在命令行中进入 Elasticsearch 的 bin 目录,执行以下命令启动 Elasticsearch: - Windows:`.\elasticsearch.bat` - Linux/MacOS:`./elasticsearch` 5. 验证安装:打开浏览器,访问 `http://localhost:9200`,如果看到类似以下信息表示 Elasticsearch 已成功启动: ``` { "name" : "your_node_name", "cluster_name" : "your_cluster_name", "cluster_uuid" : "your_cluster_uuid", "version" : { "number" : "7.15.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "unknown", "build_date" : "2021-10-07T21:56:19.031608185Z", "build_snapshot" : false, "lucene_version" : "8.9.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } ``` 这样就完成了 Elasticsearch单机安装部署
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值