微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ElasticSearch单机版安装教程

安装ElasticSearch

Docker-compose安装

  • docker-compose.yml
version: '3'
services:
  elasticsearch:
    image: elasticsearch:7.5.1
    container_name: elasticsearch
    networks:
    - net-es
    volumes:
    - /data2/es:/usr/share/elasticsearch/data  
    environment:
    - discovery.type=single-node
    ports:
    - "9200:9200"
 
  elastichd:
    image: containerize/elastichd:latest
    container_name: elasticsearch-hd
    networks:
    - net-es
    ports:
      - "9800:9800"
    depends_on:
      - "elasticsearch"
    links:
      - "elasticsearch:demo"
 
#这里要注意,es和eshd要在相同网络才能被links
networks:
  net-es:
    external: false
  • 启动
docker-compose up -d

Centos7安装

认已经安装过JDK

ElasticSearch官网下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch

选择所需要的版本下载安装,这里使用es:7.5.2

将下载好的文件上传到服务器上,并解压

 tar -zxvf elasticsearch-7.5.2-linux-x86_64.tar.gz

创建es用户

useradd es

passwd es

文件夹赋予权限

chmod -R 777 elasticsearch-7.5.2
su es

cd  elasticsearch-7.5.2
# 启动es
./bin/elasticsearch
# 守护进程启动es
./bin/elasticsearch -d 

测试是否启动成功

curl http://localhost:9200/

启动成功返回如下:

image-20210611160936133

配置ES

vim ./config/elasticsearch.yml
# 配置跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"
#配置es的集群名称认是elasticsearch,
#es会自动发现在同一网段下的es,
# 如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
cluster.name: es
node.name: node1
node.master: true
node.data: true
#path.data: /data/es/data
#path.logs: /data/es/log
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["192.168.1.41:9300"]
cluster.initial_master_nodes: ["192.168.1.41:9300"]

重启es,这样远程就能访问了

插件安装

ik分词器

下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

将解压后文件放入plugins中

/es/elasticsearch-7.5.2/plugins

image-20210611164550925

问题

  • max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

找到文件 /etc/security/limits.conf,编辑,在文件的最后追加如下配置:

es soft nofile 65535

es hard nofile 65537
  • max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

在/etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

执行/sbin/sysctl -p 立即生效

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐