es部署

2021/12/22 6:20:16

本文主要是介绍es部署,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

部署单机版es
tar xf elasticsearch-7.16.0-linux-x86_64.tar.gz
./bin/elasticsearch -d
can not run elasticsearch as root

su - machangwei
./bin/elasticsearch -d #切换用户后没有权限访问jdk目录
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
could not find java in JAVA_HOME at /opt/jdk/bin/java

ls: cannot open directory /opt/jdk/: Permission denied

退回到root
vim bin/elasticsearch-env
JAVA_HOME=/application/elasticsearch-7.16.0/jdk
chown -R machangwei.machangwei elasticsearch-7.16.0
su - machangwei

[machangwei@mcw1 ~]$ cd /application/elasticsearch-7.16.0/bin/
[machangwei@mcw1 /application/elasticsearch-7.16.0/bin]$ ./elasticsearch -d
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME


只能本机访问:
[root@mcw1 /application]$ curl http://127.0.0.1:9200/
{
"name" : "mcw1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "00voBHA3RUKvKy_Wl-VyEQ",
"version" : {
"number" : "7.16.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "6fc81662312141fe7691d7c1c91b8658ac17aa0d",
"build_date" : "2021-12-02T15:46:35.697268109Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[root@mcw1 /application]$


[root@mcw1 /application]$ curl http://10.0.0.131:9200/
curl: (7) Failed connect to 10.0.0.131:9200; Connection refused

添加配置,重启es报错,
[machangwei@mcw1 /application/elasticsearch-7.16.0/config]$ grep network.host elasticsearch.yml
network.host: 10.0.0.131
====错误信息:
ERROR: [3] bootstrap checks failed. You must address the points described in the following [3] lines before starting Elasticsearch.
bootstrap check failure [1] of [3]: max number of threads [3827] for user [machangwei] is too low, increase to at least [4096]
bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [3] of [3]: 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
ERROR: Elasticsearch did not exit normally - check the logs at /application/elasticsearch-7.16.0/logs/elasticsearch.log


添加配置启动
[machangwei@mcw1 /application/elasticsearch-7.16.0]$ vim config/elasticsearch.yml
[machangwei@mcw1 /application/elasticsearch-7.16.0]$ tail config/elasticsearch.yml
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
discovery.seed_hosts: ["10.0.0.131"]
cluster.initial_master_nodes: ["esmcw1"]
cluster.name: escluster
node.name: esmcw1
network.host: 0.0.0.0
http.port: 9200


启动后还是报错:最大线程数太少,最大虚拟内存太少
ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max number of threads [3827] for user [machangwei] is too low, increase to at least [4096]
bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /application/elasticsearch-7.16.0/logs/escluster.log ls^C
[root@mcw1 /application]$ tail /application/elasticsearch-7.16.0/logs/escluster.log
[2021-12-22T09:26:13,015][ERROR][o.e.b.Bootstrap ] [esmcw1] node validation exception
[2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max number of threads [3827] for user [machangwei] is too low, increase to at least [4096]
bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

 

[root@mcw1 /application]$ tail -1 /etc/sysctl.conf #添加系统配置vm.max_map_count,解决了虚拟内存问题,但是还有报错
vm.max_map_count=655360
==还报错:
[2021-12-22T09:41:48,876][ERROR][o.e.b.Bootstrap ] [esmcw1] node validation exception
[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max number of threads [3827] for user [machangwei] is too low, increase to at least [4096]

 

设置/etc/security/limits.conf

* soft nproc 5000
* hard nproc 5000
root soft nproc 5000
root hard nproc 5000
重启服务器生效.应该有不需要重启服务器的方法,回头研究

这次再启动就不报错退出进程了。并且可以使用这个ip进行访问了
[root@mcw1 ~]$ curl http://10.0.0.131:9200/
{
"name" : "esmcw1",
"cluster_name" : "escluster",
"cluster_uuid" : "00voBHA3RUKvKy_Wl-VyEQ",
"version" : {
"number" : "7.16.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "6fc81662312141fe7691d7c1c91b8658ac17aa0d",
"build_date" : "2021-12-02T15:46:35.697268109Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

 

浏览器也可以访问了

 



这篇关于es部署的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程