ElasticSearch

ElasticSearch第2节 CentOS7安装Elasti

2019-06-13  本文已影响0人  小超_8b2f

小伦超正经_ElasticSearch 7.0.0博客

1. 下载Java并安装Java

2. 下载Elasticsearch

https://www.elastic.co/cn/downloads/elasticsearch/

3.启动ElasticSearch

#前台运行
$ .elasticsearch
#后台运行
$ ./elasticsearch -d
3.1启动报错1

Caused By java.lang.RuntimeException: can not run ElasticSearch as root

解决办法:

#1. 方式一:启动参数:
bin/elasticsearch -Des.insecure.allow.root=true
#2.方式二:修改bin/elasticsearch
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
3.2.启动报错2

D is not a recognized option

这是出于系统安全考虑设置的条件。由于elasticsearch可以接收用户输入的脚本并执行,为了系统安全考虑,建议创建一个单独的用户来运行Elasticsearch

解决办法:

tar -zxvf elasticsearch-7.1.1-darwin-x86_64.tar.gz

#不要用root用户,要创建一个单独的用户来启动elasticsearch
$ groupadd esgroup
$ useradd -g esuser -p 123456
$ chown -R esuser:esgroup elasticsearch-7.1.1
$ su esuser
$ cd elasticsearch-7.1.1/bin
3.3. 启动报错3 :内存空间不够了

[INFO][Ko.e.c.r.a.DiskThresholdMonitor] [ZAds5FP] low disk watermark [85%] exceeded on [ZAds5FPeTY-ZUKjXd7HJKA][ZAds5FP] [/opt/elasticsearch-6.2.4/data/nodes/0] free: 1.2gb[14.2%], replicas will not be assigned to this node

解决办法:

#调整jvm内存大小
vi bin/elasticsearch
ES_JAVA_OPTS="-Xms512m -Xmx512m"
3.4 启动运行
#前台运行
$ ./elasticsearch
#后台运行
$ ./elasticsearch -d

# 检验启动成功与否
$ curl 127.0.0.1:9200
{
  "name" : "guchunchaodeMacBook-Air.local",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_4Iuk4DmS1-OQTAdcpdM9Q",
  "version" : {
    "number" : "7.1.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "7a013de",
    "build_date" : "2019-05-23T14:04:00.380842Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
3.5实现远程访问

config/elasticsearch.yml

newnetwork.host: 192.168.1.111
3.5.1 错误1

[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
修正方法:

vim elasticsearch.yml
# cluster.initial_master_nodes: ["node-1", "node-2"]  修改为:
cluster.initial_master_nodes: ["node-1"]
3.5.2 错误2
[1] : max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2] : max number of threads [3790] for user [ esuser] is too low, increase to at least [4096]
[3] : max virtual memory areas 鐘.maxjnap_count [65530] is too low, increase to at least [262144]

#处理第一个❌
vim /etc/security/limits.conf

esuser soft nofile 65536
esuser hard nofile 65536
esuser soft nproc 4096
esuser hard nproc 4096

#处理第二个❌
vim /etc/security/limits.d/20-nproc.conf
* soft nproc 4096 #改为:
esuser soft nproc 4096

#处理第三个❌
vim /etc/sysctl.conf
vim max_map_count=655360

#执行以下命令生效
sysctl -p
#关闭防火墙
systemctl stop firewalld.service

然后 浏览器访问:http://192.168.249.104:9200/

$ curl localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused
$ curl 127.0.0.1:9200
curl: (7) Failed to connect to 127.0.0.1 port 9200: Connection refused
$ curl 192.168.249.104:9200
{
  "name" : "guchunchaodeMacBook-Air.local",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_4Iuk4DmS1-OQTAdcpdM9Q",
  "version" : {
    "number" : "7.1.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "7a013de",
    "build_date" : "2019-05-23T14:04:00.380842Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
上一篇下一篇

猜你喜欢

热点阅读