Elasticsearch安装(Linux版)

一、下载&安装

1、在linux上建立一个目录,用来保存elasticsearch安装包

   mkdir /usr/local/tools/elasticsearch

2、进入/usr/local/tools/elasticsearch目录,下载安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-linux-x86_64.tar.gz

3、tar -zxvf elasticsearch-7.14.1

二、配置文件讲解

   jvm.options         虚拟机参数配置文件

                            配置heap内存一样

    elasticsearch.yml   主配置文件

                      cluster.name  集群名称,同一个网段自动加入

                      node.name        节点名称

                      http.port     http端口

默认情况下,Elastic 只允许本机访问,如果需要远程访问,可以修改 Elastic 安装目录的config/elasticsearch.yml文件,去掉network.host的注释,将它的值改成0.0.0.0,然后重新启动 Elastic。
 

三、启动

    注意:root用户无法启动Elasticsearch

    add一个es用户:

              useradd es

              passwd es

再输入两次密码(自定义)
  为用户赋权限

  chown -R es:es /usr/local/tools/elasticsearch

然后使用es用户启动  :su es

  cd  /usr/local/tools/elasticsearch-7.14.1/bin

启动es命令:./elasticsearch -d

输入:curl http://localhost:9200

如果展示;

{
  "name" : "localhost.localdomain",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "h83jwfs8Rkyn8xYejbeXzQ",
  "version" : {
    "number" : "7.14.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "66b55ebfa59c92c15db3f69a335d500018b3331e",
    "build_date" : "2021-08-26T09:01:05.390870785Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

则证明启动成功。

四、外网访问elasticsearch

上面只能用localhost访问,下面配置elasticsearch,令外网也能访问。

需要修改elasticsearch.yml

network.host: 0.0.0.0

然后再启动,可能会有下面一些报错,根据实际报错情况处理即可

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

#切换到root用户修改
vim /etc/security/limits.conf

# 在最后面追加下面内容
es hard nofile 65536
es soft nofile 65536


# 注意es 是用户

[2]: max number of threads [1024] for user [elk] is too low, increase to at least [4096]

#切换到root用户修改
进入limits.d下的配置文件:vim /etc/security/limits.d/20-nproc.conf ,修改配置如下:


*          soft    nproc      4096
root       soft    nproc     unlimited 


#我这里是20-nproc.conf,不同系统文件名不同,请进入/etc/security/limits.d目录下查看

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

#切换到root用户修改
修改sysctl文件:vim /etc/sysctl.conf ,增加下面配置项


    增加改行配置:vm.max_map_count=655360  
    保存退出后,执行:  
    sysctl -p  

[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

# 在elasticsearch.yml中加入下面命令即可

bootstrap.system_call_filter: false

[5]:

ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

解决方法如下:

# 修改elasticsearch.yml

node.name: node-1
cluster.initial_master_nodes: ["node-1"]

把错误一一改正后,启动es。

外网访问:http://****:9200

展示:

{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "h83jwfs8Rkyn8xYejbeXzQ",
  "version" : {
    "number" : "7.14.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "66b55ebfa59c92c15db3f69a335d500018b3331e",
    "build_date" : "2021-08-26T09:01:05.390870785Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值