.Net使用Elastic.Clients.Elasticsearch连接Elasticsearch8

文章目录


1、elasticsearch.yml配置

单一节点配置

yaml 复制代码
node.name: node-1

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

network.host: localhost
http.port: 9200

xpack.security.enabled: true
xpack.security.enrollment.enabled: true

xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12

http.host: 0.0.0.0

2、生成证书指纹

bash 复制代码
cd /etc/elasticsearch/certs
openssl x509 -in http_ca.crt -sha256 -fingerprint | grep SHA256 | sed 's/://g'
复制代码
SHA256 Fingerprint=ABE1B0CEBA7D45461430B48A7804DFDC6ECB136CDF4523F01106D863F4826BD1

3、使用Elastic.Clients.Elasticsearch连接

csharp 复制代码
var settings1 = new ElasticsearchClientSettings(new Uri($"https://{_elasticModel.IP}:{_elasticModel.Port}"))
	.CertificateFingerprint("ABE1B0CEBA7D45461430B48A7804DFDC6ECB136CDF4523F01106D863F4826BD1")
	.Authentication(new BasicAuthentication(_elasticModel.UserName, _elasticModel.Password));

4、参考

https://www.elastic.co/guide/en/elasticsearch/client/net-api/8.13/connecting.html


相关推荐
feilieren3 小时前
Docker 安装 Elasticsearch 9
运维·elasticsearch·docker·es
Java烘焙师7 小时前
架构师必备:业务扩展模式选型
mysql·elasticsearch·架构·hbase·多维度查询
G皮T20 小时前
【Elasticsearch】深度分页及其替代方案
大数据·elasticsearch·搜索引擎·scroll·检索·深度分页·search_after
G皮T1 天前
【Elasticsearch】检索排序 & 分页
大数据·elasticsearch·搜索引擎·排序·分页·检索·深度分页
飞询1 天前
Docker 安装 Elasticsearch 9
elasticsearch·docker
G皮T1 天前
【Elasticsearch】检索高亮
大数据·elasticsearch·搜索引擎·全文检索·kibana·检索·高亮
大只鹅2 天前
解决 Spring Boot 对 Elasticsearch 字段没有小驼峰映射的问题
spring boot·后端·elasticsearch
HGW6892 天前
基于 Elasticsearch 实现地图点聚合
java·elasticsearch·高德地图
小袁拒绝摆烂2 天前
ElasticSearch快速入门-1
大数据·elasticsearch·搜索引擎
GISer_Jing3 天前
Git协作开发:feature分支、拉取最新并合并
大数据·git·elasticsearch