栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

安装ElasticSearch8.0和Kibana8.0 Window版

安装ElasticSearch8.0和Kibana8.0 Window版

官网下载ElasticSearch8和Kibana8

进入https://www.elastic.co/cn/下载Es8和Kibana8

注意选择windows版本

安装ElasticSearch8

解压缩Es8到任务目录

到/bin 目录执行 ./elasticsearch.bat

在命令行控制台中找到密码和token 保存起来

->  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  VWFjE60dbpKIjbajGJQ4

->  HTTP CA certificate SHA-256 fingerprint:
  b6a69429e178231857760658deedfcfe6e858d8fcfcc3d230099dcc04acf429d

->  Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxNzIuMTkuNTEuNjU6OTIwMCIsIjE5Mi4xNjguMzEuMTE6OTIwMCIsIjE5Mi4xNjguMTA2LjE6OTIwMCIsIjE5Mi4xNjguMjMuMTo5MjAwIl0sImZnciI6ImI2YTY5NDI5ZTE3ODIzMTg1Nzc2MDY1OGRlZWRmY2ZlNmU4NThkOGZjZmNjM2QyMzAwOTlkY2MwNGFjZjQyOWQiLCJrZXkiOiJ5RU1DX0g0QjhLSUNnMWNqdlRwZjpqS2ZENmdIRVFGR0gxbkFWbVplS1NRIn0=

其中kibana使用的token有效期为30分钟,如果过期,需要使用如下命令行重新生成token

bin/elasticsearch-create-enrollment-token -s node

访问如下网址,测试安装是否成功

https://localhost:9200/

出现如下图片则代表安装完毕

这时候你可以使用账号elastic和之前保存的密码登录了
登录后可以看到一些json数据

安装kibana8

然后解压缩kibana8到任意目录

执行 /bin 中的./kibana.bat

复制控制台出现的连接 拷贝到浏览器中打开

将刚才的token复制到文本框中 并确认,
 

用户名elastic
密码就是上一步保存的密码登录即可
至此 Kibana8安装完毕

访问URL

​ http://localhost:5601/
使用SpringBoot访问带有CA证书的SE数据库

添加依赖包


            org.elasticsearch.client
            elasticsearch-rest-client
            8.0.0
        

配置Bean 其中需要访问用到的密码 以及上文提到的CA证书

@Bean(destroyMethod = "close")
    public RestClient restClient() throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException, KeyManagementException {

        final CredentialsProvider credentialsProvider =
                new BasicCredentialsProvider();
        credentialsProvider.setCredentials(AuthScope.ANY,
                new UsernamePasswordCredentials("elastic", "VWFjE60dbpKIjbajGJQ4"));

        Path caCertificatePath = Paths.get("E:\es\elasticsearch-8.0.0-windows-x86_64\elasticsearch-8.0.0\config\certs\http_ca.crt");
        CertificateFactory factory =
                CertificateFactory.getInstance("X.509");
        Certificate trustedCa;
        try (InputStream is = Files.newInputStream(caCertificatePath)) {
            trustedCa = factory.generateCertificate(is);
        }
        KeyStore trustStore = KeyStore.getInstance("pkcs12");
        trustStore.load(null, null);
        trustStore.setCertificateEntry("ca", trustedCa);
        SSLContextBuilder sslContextBuilder = SSLContexts.custom()
                .loadTrustMaterial(trustStore, null);
        final SSLContext sslContext = sslContextBuilder.build();
        RestClientBuilder builder = RestClient.builder(
                new HttpHost("localhost", 9200, "https"))
                .setHttpClientConfigCallback(httpClientBuilder -> {
                    httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                    return httpClientBuilder.setSSLContext(sslContext);
                });
        return builder.build();
    }

访问指定索引(表)

//注入client
    @Autowired
    RestClient restClient;

..... 逻辑代码中 ......

        Request request = new Request("GET","/ess_book/_doc/1");
        Response response = restClient.performRequest(request);
        return EntityUtils.toString(response.getEntity());

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/742736.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号