Elasticsearch项目实战
前言
- 之前项目中有使用到ES技术栈,一直没有来的急分享,今天就好好做一个技术沉淀
Elasticsearch安装
- 下载地址:
https://www.elastic.co/cn/downloads/elasticsearch
- 安装:
-
es版本:8.0.0
-
解压启动
tar -xvf elasticsearch-8.0.0-linux-x86_64.tar.gz -C /opt/module/ # 解压到/opt/module/ ln -s /opt/module/elasticsearch-8.0.0 /opt/elasticsearch # 建立软连接 mkdir -p /data/elasticsearch/{data,logs} # 规范es的数据和日志目录 cd /opt/elasticsearch vim /opt/elasticsearch/config/elasticsearch.yml # 修改配置文件 ## 配置信息如下 cluster.name: es.xx.com node.name: xx-node1 path.data: /data/elasticsearch/data path.logs: /data/elasticsearch/logs bootstrap.memory_lock: true network.host: 0.0.0.0 http.port: 9200 xpack.security.enabled: false # 不开访问不了 vim /opt/elasticsearch/config/jvm.options # 修改配置文件 ## 配置信息如下 -Xms2g -Xmx2g useradd -s /bin/bash -M es # 创建普通用户 chown -R es.es /opt/module/elasticsearch-8.0.0 # 修改文件夹权限 chown -R es.es /data/elasticsearch # 修改文件夹权限 vim /etc/security/limits.d/es.conf 修改文件描述符 ## 修改内容如下 es hard nofile 65536 es soft fsize unlimited es hard memlock unlimited es soft memlock unlimited sysctl -w vm.max_map_count=262144 # 调整内核参数 echo "vm.max_map_count=262144" >> /etc/sysctl.conf sysctl -p # 配置生效 su -c "/opt/elasticsearch/bin/elasticsearch -d" es # 启动
-
验证一下:http://ip:9200
-
Elasticsearch使用后续更新
- 文档地址:
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
- API地址:
https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html