CentOS7安装ElasticSearch6.3.2

1、配置ES需要的组和用户

#新建组elastic
groupadd elastic
#新建用户elasticsearch
useradd -d /usr/elasticsearch -g elastic -m elasticsearch

1.使用useradd时,如果后面不添加任何参数选项,例如:

#sudo useradd test创建出来的用户将是默认“三无”用户:一无Home Directory,二无密码,三无系统Shell。 
2.使用adduser时,创建用户的过程更像是一种人机对话,系统会提示你输入各种信息,然后会根据这些信息帮你创建新用户。

  • adduser会提示设置密码,而useradd不会。
  • adduser会创建用户目录,比如/home/freebird freebird是用户,useradd不会
  • dduser会创建用户目录,比如/home/freebird freebird是用户,useradd不会
  • adduser会询问全名,房间号码,电话号码等用户信息,useradd不会 

2、切换elasticsearch用户

su elasticsearch

3、下载 elasticsearch-6.3.2.tar.gz

#下载安装文件 
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz
#解压安装文件
tar xzvf elasticsearch-6.3.2.tar.gz

4、编辑配置文件config/elasticsearch.yml

#去除注释符号
#定义elasticsearch集群名称,访问时使用。
cluster.name: es
#定义不限制IP访问
network.host: 0.0.0.0

5、启动bin/elasticsearch

./elasticsearch

6、启动时报错

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用户

编辑vim /etc/security/limits.conf文件,追加:

#在末尾追加以下内容(elasticsearch为启动用户,当然也可以指定为*)
elasticsearch soft nofile 65536   
elasticsearch hard nofile 65536
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096

编辑/etc/sysctl.conf文件,追加:

vm.max_map_count=262144

配置生效,执行:

#执行命令:
sysctl -w vm.max_map_count=262144
#查看结果:
sysctl -a|grep vm.max_map_count
#显示:
vm.max_map_count = 262144

重新使用elasticsarch用户,执行elasticsarch命令,启动成功。

7、启动成功

#http://192.168.1.210:9200/
{
  "name" : "vGAO73O",
  "cluster_name" : "es",
  "cluster_uuid" : "alOOymDtTSC6WN_M4FhTSg",
  "version" : {
    "number" : "6.3.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "053779d",
    "build_date" : "2018-07-20T05:20:23.451332Z",
    "build_snapshot" : false,
    "lucene_version" : "7.3.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

8、如果想后台执行

nohup ./elasticseach &

猜你喜欢

转载自blog.csdn.net/fishinhouse/article/details/81258647