Debian安装和使用Elasticsearch 8.9

news2024/10/6 2:27:19

命令行通过 .deb 包安装 Elasticsearch

elastic

创建一个新用户

adduser elastic --> rust
# 添加sudo权限
# https://phoenixnap.com/kb/how-to-create-sudo-user-on-ubuntu
usermod -aG sudo elastic
groups elastic

下载Elasticsearch v8.9.0 Debian 包

https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#install-deb

Elasticsearch: 初学者指南

https://medium.com/@animeshblog/elasticsearch-the-beginners-cookbook-1cf30f98218

快速开始

主要参考:Verifying HTTPS with a certificate fingerprint

创建 Elasticsearch Java客户端

package org.elastic.service.es;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.TransportUtils;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;

import javax.net.ssl.SSLContext;

/**
 * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html#_verifying_https_with_a_certificate_fingerprint">Verifying HTTPS with a certificate fingerprint</a>
 */
public class MEElastic {
    /**
     * The SHA-256 fingerprint of the certificate used to sign the Elasticsearch server certificate.
     * <p>
     * come from <a href="https://security.stackexchange.com/a/14345">What is the actual value of a certificate fingerprint?</a>
     */
    private static final String fingerprint = "2c895506b07083da7299656fa7fc4b433c3e26c03cf1a99eef23c537711b6e6e";


    private static final String esUsername = "elastic";

    private static final String esPassword = "k_*t_arOy7RF6EQVL-QA";

    private RestClient elasticsearchRestClient() {
        SSLContext sslContext = TransportUtils
                .sslContextFromCaFingerprint(fingerprint);
        BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
        credsProv.setCredentials(
                AuthScope.ANY, new UsernamePasswordCredentials(esUsername, esPassword)
        );
        return RestClient
                .builder(new HttpHost("127.0.0.1", 9200, "https"))
                .setHttpClientConfigCallback(hc -> hc
                        .setSSLContext(sslContext)
                        .setDefaultCredentialsProvider(credsProv)
                        .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                )
                .build();
    }

    public ElasticsearchClient elasticsearchClient() {
        // Create the transport and the API client
        ElasticsearchTransport transport = new RestClientTransport(elasticsearchRestClient(), new JacksonJsonpMapper());
        return new ElasticsearchClient(transport);
    }
}

测试ElasticsearchClient

@Test
void elasticsearchClient() throws IOException {
    MEElastic meElastic = new MEElastic();
    ElasticsearchClient esClient = meElastic.elasticsearchClient();
    GetIndexResponse rsp = esClient.indices().get(request -> request.index("test"));
    System.out.println(rsp);
    esClient._transport().close();
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/845797.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

GATK BaseRecalibratorSpark 过程中因Too many open files终止

Error&#xff1a; GATK BaseRecalibratorSpark 过程中因Too many open files终止 执行命令&#xff1a; nohup time ./gatk --java-options "-Xmx16G" BaseRecalibratorSpark -R ../../alignment/hg38/hg38.fa -I ../../alignment/bam/P368T.sorted.markdup.bam …

【C++】C++文件操作-文本文件/二进制文件

0.前言 一、文本文件 1.写文件 代码 #include <iostream> using namespace std; #include <fstream> //头文件包含//************************************** //文本文件 写文件 void test01() {//1.包含文件 fstream//2.创建流对象ofstream ofs;//3.指导打开方式…

芒格之道——查理·芒格股东会讲话1987-2022

你越是认真生活&#xff0c;你的生活就会越美好&#xff01; 这里将读书过程划线的内容摘抄在这里&#xff0c;方便自己回顾。 书分为两部分&#xff0c;我先读了后半部分&#xff0c;而且是从后往前读&#xff0c;到了前半部分&#xff0c;我是从前往后读。书还挺贵&#xff…

使用反汇编工具IDA查看发生异常的汇编代码的上下文去辅助分析C++软件异常

目录 1、概述 2、如何使用IDA打开并查看二进制文件的汇编代码 3、在IDA中找到发生崩溃的那条汇编指令的位置 3.1、如何在IDA中找到发生异常的那条汇编指令 3.2、示例 4、阅读汇编代码上下文需要掌握一定的基础汇编知识 5、最后 VC常用功能开发汇总&#xff08;专栏文章列…

备战秋招011(20230807)

文章目录 前言一、今天学习了什么&#xff1f;二、算法----》单调栈1、介绍2、题目 总结 前言 提示&#xff1a;这里为每天自己的学习内容心情总结&#xff1b; Learn By Doing&#xff0c;Now or Never&#xff0c;Writing is organized thinking. 今天拿到了上周面试的结果…

选读SQL经典实例笔记19_Any和All

1. Any 1.1. 任意一个 1.2. 选修了任意一门课程的学生 1.2.1. 找出选修了至少一门课程的学生 1.3. 比任何火车都快的飞机 1.3.1. 找出比所有火车都快的飞机 2. All 2.1. 全部 2.2. 吃所有蔬菜的人 2.2.1. 没有任何一种蔬菜他们不吃 3. 问题12 3.1. 选修了全部课程的…

scikit-plot 使用笔记

scikit-plot是基于sklearn和Matplotlib的库&#xff0c;主要的功能是对训练好的模型进行可视化。 安装&#xff1a; pip install scikit-plot 功能1&#xff1a;评估指标可视化 scikitplot.metrics.plot_confusion_matrix快速展示模型预测结果和标签计算得到的混淆矩阵。 im…

ForkJoinPool详解

一、归并排序 1、简介 先把一个庞大的数组进行递归分解&#xff0c;把拆分的数组排好序&#xff0c;之后把拆分排好序的数组进行有序的合并&#xff0c;必须住的问题就是&#xff0c;递归拆分的阈值&#xff0c;比如当数组长度拆分到10000时候就不拆了&#xff0c;不能无限制…

TPU编程竞赛系列 | 创客北京2023·算能AI+边缘计算专项赛开始啦!

为助力北京市高精尖产业发展&#xff0c;构建大中小企业相互依存、相互促进的企业发展生态&#xff0c;打造北京市有影响力的双创服务品牌赛事&#xff0c;“创客北京”大赛组委会联合算能举办AI边缘计算方向专项赛。 1.赛题任务 本赛题基于“AI边缘计算”方向&#xff0c;针对…

21、springboot的宽松绑定及属性处理类的构造注入

springboot的宽松绑定及属性处理类的构造注入 ★ 如何使用属性处理类所读取的属性 属性处理类最终变成了Spring容器中的一个Bean组件&#xff0c;因此接下来Spring即可将该Bean组件注入任意其他组件。 这种做法的好处是&#xff1a;可以将大量的配置信息封装一个对象——所以…

利用openTCS实现车辆调度系统(三)车辆适配器解读,封装自己的适配器

适配器的官方解释&#xff1a;openTCS 支持自定义车辆驱动程序的集成&#xff0c;这些驱动程序实现特定于车辆的通信协议&#xff0c;从而在内核和车辆之间进行调解。 由于其功能&#xff0c;车辆驾驶员也称为通信适配器。 openTCS适配器。欢迎随时沟通 1、源码下载 github下…

arcgis宗地或者地块四至权利人信息提取教程

ARCGIS怎样将图斑四邻的名称及方位加入其属性表 以前曾发表过一篇《 如何把相邻图斑的属性添加在某个字段中》的个人心得,有些会员提出了进一步的要求,不但要相邻图斑的名称,还要求有方位,下面讲一下自己的做法。 基本思路是:连接相邻图斑质心,根据连线的角度确定相邻图斑…

动态规划(二)

一、线性DP 1.1数字三角形 #include<iostream> #include<algorithm>using namespace std;const int N 510,INF 1e9;int n; int a[N][N]; int f[N][N];int main() {scanf("%d",&n);for(int i 1;i < n;i ){for(int j 1;j < i; j )scanf(&qu…

【2.3】Java微服务:sentinel服务哨兵

✅作者简介&#xff1a;大家好&#xff0c;我是 Meteors., 向往着更加简洁高效的代码写法与编程方式&#xff0c;持续分享Java技术内容。 &#x1f34e;个人主页&#xff1a;Meteors.的博客 &#x1f49e;当前专栏&#xff1a; Java微服务 ✨特色专栏&#xff1a; 知识分享 &am…

Spring 事务失效的八种场景

1. 抛出检查异常导致事务不能正确回滚 Service public class Service1 {Autowiredprivate AccountMapper accountMapper;Transactionalpublic void transfer(int from, int to, int amount) throws FileNotFoundException {int fromBalance accountMapper.findBalanceBy(from…

Butterfly 安装文档(一) 快速开始

安装 在你的Hexo根目录里面 git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly 应用主题 修改 Hexo 根目录下的 _config.yml&#xff0c;把主题改为 butterfly theme: butterfly 安装插件 如果你没有 pug 以及 stylus 的渲染…

字符串查找匹配算法

概述 字符串匹配&#xff08;查找&#xff09;是字符串的一种基本操作&#xff1a;给定带匹配查询的文本串S和目标子串T&#xff0c;T也叫做模式串。在文本S中找到一个和模式T相符的子字符串&#xff0c;并返回该子字符串在文本中的位置。 暴力匹配 Brute Force Algorithm&a…

20天突破英语四级高频词汇——第②天

2&#xfeff;0天突破英语四级高频词汇~第2天加油(ง •_•)ง&#x1f4aa; &#x1f433;博主&#xff1a;命运之光 &#x1f308;专栏&#xff1a;英语四级高频词汇速记 &#x1f30c;博主的其他文章&#xff1a;点击进入博主的主页 目录 2&#xfeff;0天突破英语四级高…

LouvainMethod分布式运行的升级之路

1、背景介绍 Louvain是大规模图谱的谱聚类算法&#xff0c;引入模块度的概念分二阶段进行聚类&#xff0c;直到收敛为止。分布式的代码可以在如下网址进行下载。 GitHub - Sotera/spark-distributed-louvain-modularity: Spark / graphX implementation of the distri…

SQL server 与 MySQL count函数、以及sum、avg 是否包含 为null的值

sql server 与 mysql count 作用一样。 count 计算指定字段出现的个数&#xff0c; 不是计算 null的值 获取表的条数 count(n) n:常数 count(1),count&#xff08;0&#xff09;等 count(*) count(字段) 其中字段为null 不会统计在内。 avg(字段)、sum(字段) 跟count(字段)…