linux安装ES

1.需要先安装JDK(必须是1.8以上)    

参考链接:https://blog.csdn.net/qq_40806970/article/details/104553635

2.下载ES包    参考链接:https://blog.csdn.net/he19970408/article/details/107359861/

wget http://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz    #后面是es的版本

3.解压压缩包

tar -zxvf elasticsearch-6.4.1.tar.gz

4.运行ES服务   (注意用root用户启动会报错)

在bin目录中执行   ./elasticsearch
    
注意:root用户启动[2018-09-19T14:50:04,029][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

5.不能以root用户身份来启动

创建新用户:adduser es
修改用户密码:passwd es
配置文件权限:chown -R es /home/elasticsearch-6.4.1 #在root用户下根目录,赋予用户文件权限
切换用户: su es

6.启动ES

进入ES文件目录:/home/elasticsearch-6.4.1/bin
启动: ./elasticsearch       或者./elasticsearch -d  (-d代表在后台执行)

7.测试是否安装成功

另起一个终端执行: curl http://localhost:9200   出现以下内容说明成功
{
  "name" : "r7rn72t",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "x5gy7QF6T6mDkxMlw5aDjQ",
  "version" : {
    "number" : "6.4.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "e36acdb",
    "build_date" : "2018-09-13T22:18:07.696808Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

8.开启ES远程访问

在es根目录下的config文件夹下elasticsearch.yml 
vim elasticsearch.yml   将原来的network修改为以下配置:
network.host:0.0.0.0

 

 9.重启ES

重新启动出现如下错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法:
切换到root用户修改: su root
vim /etc/security/limits.conf
在最后面加上以下内容
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096

修改 vim /etc/sysctl.conf
在最后面加上  vm.max_map_count=655360

修改完之后  sysctl -p
再次切换到es用户启动ES

10.外部浏览器访问   (阿里云服务器需要开启9200端口,才能访问)

http://es的主机名:9200  出现以下信息说明安装成功:
{
  "name" : "r7rn72t",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "x5gy7QF6T6mDkxMlw5aDjQ",
  "version" : {
    "number" : "6.4.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "e36acdb",
    "build_date" : "2018-09-13T22:18:07.696808Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

 

posted @ 2020-10-23 15:21  只会玩辅助  阅读(1686)  评论(0编辑  收藏  举报