概述
目录
- 一、下载
- 二、解压
- 三、将解压目录移至 /usr/local
- 四、启动
- 五、测试
- 六、设置外网访问
一、下载
下载链接:https://www.elastic.co/cn/downloads/elasticsearch
二、解压
tar xzvf elasticsearch-7.15.2-linux-x86_64.tar.gz
三、将解压目录移至 /usr/local
mv elasticsearch-7.15.2 /usr/local/
四、启动
./bin/elasticsearch -d
报错:
1、warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_311/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
2、Java HotSpot™ 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
3、can not run elasticsearch as root
解决方法:
1、安装jdk11(下载 jdk-11.0.13_linux-x64_bin.tar.gz,解压 tar xzvf jdk-11.0.13_linux-x64_bin.tar.gz,mv jdk-11.0.13 /usr/local/),并修改文件/usr/local/elasticsearch-7.15.2/bin/elasticsearch,在文件的开头增加以下内容:
# 指定jdk11
export ES_JAVA_HOME=/usr/local/jdk-11.0.13
export PATH=$ES_JAVA_HOME/bin:$PATH
# 添加jdk判断
if [ -x "$ES_JAVA_HOME/bin/java" ]; then
JAVA="/usr/local/jdk-11.0.13/bin/java"
else
JAVA=`which java`
fi
2、CMS 垃圾收集器在JDK9开始被标注为@Deprecated,JDK11支持的垃圾回收器为G1和ZGC,而ZGC在JDK11还处于实验阶段。修改config目录下的jvm.options,将:-XX:+UseConcMarkSweepGC 改为:-XX:+UseG1GC
3、es5之后必须通过创建用户启动
(1)创建用户
adduser es
(2)设置密码
passwd es
(3)授权
chown -R es:es elasticsearch-7.15.2/
(4)切换es用户启动
su es
./bin/elasticsearch -d
五、测试
启动后输入curl 127.0.0.1:9200,如果返回json数据说明启动成功。
六、设置外网访问
修改./config/elasticsearch.yml文件,设置:
network.host: 0.0.0.0
报错:
1、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2、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
解决方法:
1、执行命令,临时生效:
sysctl -w vm.max_map_count=262144
编辑配置文件/etc/sysctl.conf,永久生效:
vm.max_map_count=262144
2、修改./config/elasticsearch.yml文件,在discovery.seed_hosts,discovery.seed_providers, cluster.initial_master_nodes中至少设置一项,将discovery.seed_hosts设置为默认值即可:
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
最后
以上就是妩媚仙人掌为你收集整理的CentOS7和8下安装Elasticsearch一、下载二、解压三、将解压目录移至 /usr/local四、启动五、测试六、设置外网访问的全部内容,希望文章能够帮你解决CentOS7和8下安装Elasticsearch一、下载二、解压三、将解压目录移至 /usr/local四、启动五、测试六、设置外网访问所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复