ElasticSearch 学习笔记总结(二)

news2024/11/16 11:39:26

文章目录

  • 一、ES JavaAPI 环境准备
  • 二、ES JavaAPI 索引
    • 1. 索引 创建
    • 2. 索引 查找
    • 3. 索引 删除
  • 三、ES JavaAPI 文档
    • 1. 文档 创建
    • 2. 文档 修改
    • 3. 文档 查询
    • 4. 文档 删除
    • 4. 文档 批量新增 和 批量删除
    • 5. 高级查询 索引全量查询
    • 6. 高级查询
  • 四、ES 集群
    • 1. ES集群 概念
    • 2. window 集群搭建
    • 3. linux 单点安装ES

一、ES JavaAPI 环境准备

第一步:创建maven项目,引入相关依赖。

<!-- elasticsearch的核心依赖 -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>7.8.0</version>
</dependency>
<!-- elasticsearch的客户端 high-level另外一种组件。 -->
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>7.8.0</version>
</dependency>
<!-- elasticsearch依赖2.x的log4j -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.8.2</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.8.2</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.9</version>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
</dependency>

第二步:构建相关API客户端。

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Client {

    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200,"http"))
        );
        // 关闭ES客户端
        restHighLevelClient.close();
    }

}

二、ES JavaAPI 索引

1. 索引 创建

http://127.0.0.1:9200/_cat/indices?v 测试使用

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Client {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
        );
        // 创建索引
        CreateIndexRequest request = new CreateIndexRequest("user1");
        CreateIndexResponse createIndexResponse = esClient.indices().create(request, RequestOptions.DEFAULT);
        // 响应状态
        boolean acknowledged = createIndexResponse.isAcknowledged();
        System.out.println("索引操作:" + acknowledged);
        // 关闭ES客户端
        esClient.close();
    }
}

2. 索引 查找

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

public class ESTest_Client_Search {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
        );
        // 查询索引
        GetIndexRequest request = new GetIndexRequest("user1");
        GetIndexResponse getIndexResponse = esClient.indices().get(request, RequestOptions.DEFAULT);
        // 响应状态
        System.out.println(getIndexResponse.getAliases());
        System.out.println(getIndexResponse.getMappings());
        System.out.println(getIndexResponse.getSettings());
        // 关闭ES客户端
        esClient.close();
    }
}

3. 索引 删除

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

public class ESTest_Client_Delete {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
        );
        // 删除索引
        DeleteIndexRequest request = new DeleteIndexRequest("user");
        AcknowledgedResponse delete = esClient.indices().delete(request, RequestOptions.DEFAULT);
        System.out.println("响应是否成功" + delete.isAcknowledged());
        // 关闭ES客户端
        esClient.close();
    }
}

三、ES JavaAPI 文档

1. 文档 创建

http://127.0.0.1:9200/user/_doc/1001 测试使用。

package com.itholmes.es.test;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpHost;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

public class ESTest_Client_Insert {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
        );
        // 插入数据
        IndexRequest request = new IndexRequest();
        request.index("user").id("1001");
        User user = new User();
        user.setName("zhangsan");
        user.setAge(30);
        user.setSex("男");

        // 向ES插入数据,必须讲数据转换为JSON格式
        ObjectMapper mapper = new ObjectMapper();
        String userJson = mapper.writeValueAsString(user);

        // 放入数据,并且告诉请求的类型
        request.source(userJson, XContentType.JSON);
        // 查询
        IndexResponse response = esClient.index(request, RequestOptions.DEFAULT);
        // 查看结果 (Shard分片)
        System.out.println(response.getResult());
        // 关闭ES客户端
        esClient.close();
    }
}

2. 文档 修改

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

public class ESTest_Dos_Update {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        // 修改数据
        UpdateRequest request = new UpdateRequest();
        // 哪个索引,哪个id主键
        request.index("user").id("1001");
        request.doc(XContentType.JSON,"sex","女");
        UpdateResponse response = esClient.update(request, RequestOptions.DEFAULT);
        System.out.println(response.getResult());
        // 关闭ES客户端
        esClient.close();
    }
}

3. 文档 查询

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Dos_Get {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        // 查询文档
        GetRequest request = new GetRequest();
        request.index("user").id("1001");
        GetResponse response = esClient.get(request, RequestOptions.DEFAULT);
        System.out.println(response.getSourceAsString());
        // 关闭ES客户端
        esClient.close();
    }
}

4. 文档 删除

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Dos_Delete {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        DeleteRequest request = new DeleteRequest();
        request.index("user").id("1001");
        // 删除文档
        DeleteResponse delete = esClient.delete(request, RequestOptions.DEFAULT);
        System.out.println(delete.toString());
        // 关闭ES客户端
        esClient.close();
    }
}

4. 文档 批量新增 和 批量删除

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

public class ESTest_Client_Insert_Batch {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
        );
        // 文档 批量新增
        BulkRequest request = new BulkRequest();
        request.add(new IndexRequest().index("user").id("1001").source(XContentType.JSON,"name","zhangsan"));
        request.add(new IndexRequest().index("user").id("1002").source(XContentType.JSON,"name","lisi"));
        request.add(new IndexRequest().index("user").id("1003").source(XContentType.JSON,"name","wangwu"));
        BulkResponse response = esClient.bulk(request, RequestOptions.DEFAULT);
        System.out.println(response.getTook()); // 执行时长
        System.out.println(response.getItems());
        // 关闭ES客户端
        esClient.close();
    }
}
package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class ESTest_Dos_Delete_Batch {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        // 文档 批量删除
        BulkRequest request = new BulkRequest();
        request.add(new DeleteRequest().index("user").id("1001"));
        request.add(new DeleteRequest().index("user").id("1002"));
        request.add(new DeleteRequest().index("user").id("1003"));
        BulkResponse bulk = esClient.bulk(request, RequestOptions.DEFAULT);
        System.out.println(bulk.getTook());
        System.out.println(bulk.getItems());
        // 关闭ES客户端
        esClient.close();
    }
}

5. 高级查询 索引全量查询

查询某索引下的全部内容:

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;

public class ESTest_Dos_Query {
    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        // 高级查询 全量查询
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // 查询索引中全部的数据
        SearchSourceBuilder query = new SearchSourceBuilder().query(QueryBuilders.matchAllQuery());
        request.source(query);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        // 最终的结果
        SearchHits hits = response.getHits();
        System.out.println(hits.getTotalHits());
        System.out.println(response.getTook());
        for (SearchHit hit : hits) {
            System.out.println(hit.getSourceAsString());
        }
        // 关闭ES客户端
        esClient.close();
    }
}

6. 高级查询

总共有:分页查询、条件查询、字段查询、组合查询、范围查询、 聚合查询、分组查询。

package com.itholmes.es.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.metrics.MaxAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortOrder;

public class ESTest_Dos_Query {

    public static void main(String[] args) throws Exception {
        // 创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"))
        );
        // 1. 条件查询
        // SearchResponse response = condition(esClient);
        // 2. 分页查询
        // SearchResponse response = page(esClient);
        // 3. 排序查询
        // SearchResponse response = sort(esClient);
        // 4. 过滤查询
        // SearchResponse response = filter(esClient);
        // 5. 组合查询
        // SearchResponse response = associate(esClient);
        // 6. 范围查询
        // SearchResponse response = range(esClient);
        // 7. 模糊查询
        // SearchResponse response = like(esClient);
        // 8. 高亮查询
        // SearchResponse response = highlight(esClient);
        // 9. 聚合查询
        // SearchResponse response = aggregate(esClient);
        // 10. 分组查询
        SearchResponse response = group(esClient);
        // 最终的结果
        SearchHits hits = response.getHits();
        System.out.println(hits.getTotalHits());
        System.out.println(response.getTook());
        for (SearchHit hit : hits) {
            System.out.println(hit.getSourceAsString());
        }
        // 关闭ES客户端
        esClient.close();
    }

    // 条件查询
    public static SearchResponse condition(RestHighLevelClient esClient) throws Exception {
        // 高级查询
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // termQuery 进行条件查询
        SearchSourceBuilder query = new SearchSourceBuilder().query(QueryBuilders.termQuery("age", 30));
        request.source(query);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 分页查询
    public static SearchResponse page(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // builder设置分页
        SearchSourceBuilder builder = new SearchSourceBuilder().query(QueryBuilders.termQuery("age", 30));
        // 分页算法: 起始位置 = (当前页码 - 1) * 每页显示数据条数
        builder.from(2); // 起始位置
        builder.size(2); // 每页多少条
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 查询排序
    public static SearchResponse sort(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // builder设置分页
        SearchSourceBuilder builder = new SearchSourceBuilder().query(QueryBuilders.matchAllQuery());
        builder.sort("age", SortOrder.DESC);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 查询过滤
    public static SearchResponse filter(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // builder设置分页
        SearchSourceBuilder builder = new SearchSourceBuilder().query(QueryBuilders.matchAllQuery());
        // 包含,不包含
        String[] excludes = {};
        String[] includes = {"name"};
        builder.fetchSource(excludes, includes);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 组合查询
    public static SearchResponse associate(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        // builder 组合查询
        SearchSourceBuilder builder = new SearchSourceBuilder();
        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
        // 满足的条件 must就是必须
        // boolQueryBuilder.must(QueryBuilders.matchQuery("age",30));
        // boolQueryBuilder.mustNot(QueryBuilders.matchQuery("sex","男"));
        // should 可以理解为or的效果
        boolQueryBuilder.should(QueryBuilders.matchQuery("age", 30));
        boolQueryBuilder.should(QueryBuilders.matchQuery("age", 100));
        builder.query(boolQueryBuilder);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 范围查询
    public static SearchResponse range(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        SearchSourceBuilder builder = new SearchSourceBuilder();
        RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("age");
        rangeQuery.gte(30); // gte 大于等于
        rangeQuery.lte(90); // lte 小于等于
        builder.query(rangeQuery);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 模糊查询
    public static SearchResponse like(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        SearchSourceBuilder builder = new SearchSourceBuilder();
        // 模糊查询 fuzziness 英文直译:模糊度,Fuzziness.ONE代表差异1个字符也可以查询出来。
        FuzzyQueryBuilder fuzziness = QueryBuilders.fuzzyQuery("name", "wangwu").fuzziness(Fuzziness.ONE);
        builder.query(fuzziness);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        return response;
    }

    // 高亮查询
    public static SearchResponse highlight(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        SearchSourceBuilder builder = new SearchSourceBuilder();
        TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("name", "zhangsan");
        HighlightBuilder highlightBuilder = new HighlightBuilder();
        // 添加标签
        highlightBuilder.preTags("<font color='red'>");
        highlightBuilder.postTags("</font>");
        // 指定name属性高亮效果。
        highlightBuilder.field("name");
        builder.highlighter(highlightBuilder);
        builder.query(termQueryBuilder);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        // 高亮显示是对应的highlight的属性。
        return response;
    }

    // 聚合查询
    public static SearchResponse aggregate(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        SearchSourceBuilder builder = new SearchSourceBuilder();
        // 聚合查询 取age的最大值
        MaxAggregationBuilder field = AggregationBuilders.max("maxAge").field("age");
        builder.aggregation(field);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        // 同样聚合查询也要特定的属性才获取到。
        return response;
    }

    // 分组查询
    public static SearchResponse group(RestHighLevelClient esClient) throws Exception {
        SearchRequest request = new SearchRequest();
        request.indices("user");
        SearchSourceBuilder builder = new SearchSourceBuilder();
        // 分组查询 根据age年龄进行分组
        AggregationBuilder field = AggregationBuilders.terms("ageGroup").field("age");
        builder.aggregation(field);
        request.source(builder);
        SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
        // 同样分组查询也要特定的属性才获取到。
        return response;
    }

}

四、ES 集群

1. ES集群 概念

概念:
在这里插入图片描述

ES目录介绍:

  • data目录:存放相关的数据,如果删除了数据就没了。
  • logs目录:存放日志,如果删除了日志就没了。

2. window 集群搭建

第一步:配置第一个节点。

配置elasticsearch.yml文件:

  • 集群的名称一定保持一致。
  • 节点名字在集群当中,必须保持唯一。
# 集群名称 保持一致。
cluster.name: my-application
# 节点名字
node.name: node-1002
node.master: true
node.data: true
# 网络外网配置
network.host: localhost
# http协议端口
http.port: 1002
# 传输协议
transport.tcp.port: 9301

# 配置开宇
http.cors.enabled: true
http.cors.allow-origin: "*"

在这里插入图片描述
在这里插入图片描述

集群状态查询:

# get方法
http://localhost:1001/_cluster/health 

第二步:配置第二个节点。

  • 需要在elasticsearch.yml文件中,添加配置,配置到第一个节点上。(其实是发现服务的效果)。
# 其他配置node.name http.port transport.tcp.port 端口 都不能相同!
# 配置注册发现效果
discovery.seed_hosts: ["localhost:9301"] # 相当于取找9301这个节点。
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5

第三步:配置第三个节点。

discovery.seed_hosts: ["localhost:9301","localhost:9302"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5

3. linux 单点安装ES

官方下载,linux包解压。

因为安全问题,ES不允许root用户直接运行,所以要创建新用户。

useradd es
passwd es
chown -R es:es /opt/elasticsearch/elasticsearch-7.8.0

添加配置如下:

cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
# 配置node-1为主节点
cluster.initial_master_nodes: ["node-1"]

因为linux系统有文件限制之类的,所以为了防止这种类似错误的发生配置如下操作:

配置limits.conf:

# 配置limits.conf
vi /etc/security/limits.conf

配置如下:

# 在limits.conf文件末尾添加
# 针对es用户 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536

配置20-nproc.conf:

# 配置20-nproc.conf
vi /etc/security/limits.d/20-nproc.conf
# 针对es用户 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
* hard nproc 4096

修改sysctl.conf 文件:

# 修改sysctl.conf 文件
vi /etc/sysctl.conf 
vm.max_map_count=655360

最后,切换到创建的用户es,并且在bin目录下启动即可。

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

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

相关文章

阿里P8:做测试10年我的一些经验分享,希望你们少走弯路

我是在2015年毕业的&#xff0c;当时是读的普通本科&#xff0c;不上不下的专业水平&#xff0c;毕业的时候&#xff0c;恰好遇到了金融危机。校园招聘里阴差阳错的巧合&#xff0c;让我走上了软件测试工程师的道路。 入职第一天&#xff0c;来了个高大上的讲师&#xff0c;记…

如何使用码匠连接 PostgreSQL

目录 在码匠中集成 PostgreSQL 在码匠中使用 PostgreSQL 关于码匠 PostgreSQL 是一种特性非常齐全的自由软件的对象-关系型数据库管理系统&#xff08;ORDBMS&#xff09;&#xff0c;它具有许多强大的功能&#xff0c;PostgreSQL 支持大部分的 SQL 标准并且提供了很多其他现…

一些无线通信系统模型的概念

一些无线通信系统模型的概念 扩频通信,指的是系统的带宽WWW远大于其信息传输速率R(bits/s)R(bits/s)R(bits/s), 定义展频带因子BeWRB_e \frac{W}{R}Be​RW​, 易知在扩频通信系统中,BeB_eBe​远大于1. 在频率上产生如此大的冗余度,主要是为了减轻无线通信或卫星通信中经常产生…

关于算法学习和刷题的建议

大家好&#xff0c;我是方圆。最近花时间学了学算法&#xff0c;应该算是我接触Java以来第一次真正的学习它&#xff0c;这篇帖子我会说一些我对算法学习的理解&#xff0c;当然这仅仅是浅浅的入算法的门&#xff0c;如果想深挖或者是有基础的人想提升自己&#xff0c;我觉得这…

【Linux】内核同步机制之等待队列和完成量

文章目录完成量和等待队列1. 等待队列1.1 基本元素1.2 等待队列的创建和初始化1.3 等待队列元素的创建和初始化1.4 添加和移除等待队列元素到等待队列2. 等待事件机制3. 等待队列唤醒4. 总结4.1 等待事件方式4.2 手动休眠方式4.3 借助内核封装函数&#xff0c;进行手动休眠5. 完…

前端开发_快应用开发

目录快应用官网真机调试组件组件嵌套问题tab组件list组件web组件css 样式问题[1]选择器[2]盒模型[3]样式布局-弹性布局[4-1]样式切换 - 类名的动态切换[4-2] 样式切换 - 行内样式动态切换[5]background[6]overflow[7]border-radius[8]盒子阴影[9] 单位系统接口[1] 检查某app是否…

机房运维6大隐患,你中了几个?

随着医院的看诊预约、缴费、打印报告等众多业务转至线上进行&#xff0c;对医院的网络及数据处理能力提出越来越高的要求&#xff0c;那么&#xff0c;机房的稳定、安全运行是医院网络信息系统的关键因素。 机房运维6大隐患 01.电源电力系统不稳定&#xff0c;网络设备运转遭到…

华为面试题就这?00后卷王直接拿下30k华为offer......

先说一下我的情况&#xff0c;某211本计算机&#xff0c;之前在深圳那边做了大约半年多少儿编程老师&#xff0c;之后内部平调回长沙这边&#xff0c;回来之后发现有点难&#xff0c;这边可能是业绩难做&#xff0c;虚假承诺很厉害&#xff0c;要给那些家长虚假承诺去骗人家&am…

红日(vulnstack)1 内网渗透ATTCK实战

环境准备 靶机链接&#xff1a;百度网盘 请输入提取码 提取码&#xff1a;sx22 攻击机系统&#xff1a;kali linux 2022.03 网络配置&#xff1a; win7配置&#xff1a; kali配置&#xff1a; kali 192.168.1.108 192.168.111.129 桥接一块&#xff0c;自定义网卡4 win7 1…

一文读懂云渲染“串流”全链路时延及优化策略

​这是一个让云游戏完美起步的时代。 云游戏作为产业内近年来炙手可热的话题&#xff0c;具有“云端运行、超高清、零延时、即点即玩”等众多特性。 随着 5G 时代的到来&#xff0c;以及中心云能力下沉至边缘云&#xff0c;高带宽、低延迟、高性能这些特性与云游戏紧密结合&a…

FastDDS-2.库概览

2. 库概览 Fast DDS&#xff08;前身为Fast RTPS&#xff09;是DDS规范的高效高性能实现&#xff0c;DDS规范是一种用于分布式应用软件的以数据为中心的通信中间件&#xff08;DCPS&#xff09;。本节回顾Fast DDS的体系结构、操作和关键特性。 2.1 架构 Fast DDS的架构如下图…

07_MySQL的单行函数

1. 函数的理解1.1 什么是函数函数在计算机语言的使用中贯穿始终&#xff0c;函数的作用是什么呢&#xff1f;它可以把我们经常使用的代码封装起来&#xff0c;需要的时候直接调用即可。这样既提高了代码效率 &#xff0c;又提高了可维护性 。在 SQL 中我们也可以使用函数对检索…

python之wheel 包命名规则、abi 兼容和安装

一、windows安装python包&#xff0c;遇见的问题 1、python3以后的版本&#xff0c;安装python包&#xff0c;可以直接使用pip安装&#xff0c;但是安装时偶尔报错 2、安装python源码包&#xff0c;如何确定自己该安装哪个版本&#xff0c;一看就晕倒~~~&#xff08;没人扶&…

PMP新考纲考试难不难,通过率怎样?

PMP考试难不难&#xff0c;还是因人而异的&#xff0c;对小白而言&#xff0c;肯定是难的&#xff0c;对项目管理老人而言&#xff0c;难度肯定是没那么高。 据考过的朋友讲&#xff0c;新考纲是有点难度的&#xff0c;尤其是最开始6月25日的考试&#xff0c;2023年就简单些了…

职场性别报告,男女薪酬仍有差距,男性平均薪酬比女性高29.7%

性别是否影响职业&#xff1f;女性求职比男性更加困难&#xff1f;男性薪酬比女性更有优势&#xff1f;人们一说到警察、建筑师通常会想到高大魁梧的男性形象&#xff0c;一说到幼师、护士往往想到的都是温柔的女性形象&#xff0c;职业好似与性别挂钩&#xff1b;女性求职通常…

OnlyOffice验证(二)在Centos7上部署OnlyOffice编译结果

在Centos7上部署OnlyOffice编译结果 此处将尝试将OnlyOffice验证&#xff08;一&#xff09;DocumentServer编译验证的结果部署到Centos7上。并且使用其它服务器现有的RabbitMq和Mysql。 安装Nginx 先安装Nginx需要的依赖环境&#xff1a; yum install openssl* -y yum insta…

java本地搭建宝塔部署实战likeadmin后台管理系统源码 - server端(一)

大家好啊&#xff0c;我是测评君&#xff0c;欢迎来到web测评。 上次分享了那几期likeadmin的搭建视频教程&#xff0c;由于是php开发的&#xff0c;这对有些习惯用java开发的同学不太友好&#xff0c;好在这套系统也有java版本的&#xff0c;也有朋友让我录制java版的搭建教程…

1. 驱动开发--基础知识

文章目录1 驱动的概念2 linux体系架构3 模块化设计3.1 微内核和宏内核4 linux设备驱动分类4.1 驱动分类4.2 三类驱动程序详细对比分析4.3 为什么字符设备驱动最重要5 驱动程序的安全性要求5.1 驱动是内核的一部分5.2 驱动对内核的影响5.3 常见驱动安全性问题6 驱动应该这么学6.…

「TCG 规范解读」词汇表

可信计算组织&#xff08;Ttrusted Computing Group,TCG&#xff09;是一个非盈利的工业标准组织&#xff0c;它的宗旨是加强在相异计算机平台上的计算环境的安全性。TCG于2003年春成立&#xff0c;并采纳了由可信计算平台联盟&#xff08;the Trusted Computing Platform Alli…

66岁“硅仙人与23岁“硅神童”创业晶圆厂,年薪17万美元

美国小伙打造出家庭芯片工厂&#xff01; 溅射、氧化、光刻、蚀刻、绑定、封装全包括&#xff01; 主人公Sam Zeloof&#xff0c;当时是一名大四学生。Sam Zeloof 是 YouTube和 Twitter 上的网络红人。多年来&#xff0c;他一直在记录自己在车库中制造硅芯片的令人印象深刻的…