首页 > 数据库 > 数据库开发技术 > elasticsearch安装
elasticsearch-7.10
centos7
依赖jdk11
必须使用非root账户启动
创建用户
# 添加组appusergroupadd appuser# 添加用户appuser,并加入主组appuser,又归属于rootuseradd -s /bin/sh -g appuser -G root appuser# 修改appuser密码passwd appuseryxkong
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-aarch64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-aarch64.tar.gztar -zxvf elasticsearch-7.10.0-linux-aarch64.tar.gz -C /app/es/
#集群名称cluster.name: yxkong#节点名称node.name: node-1#数据和日志的存储目录path.data: /app/data/espath.logs: /app/logs/es#设置绑定的ip,设置为0.0.0.0可以让任何计算机节点访问network.host: 0.0.0.0#默认端口http.port: 9200#设置在集群中的所有节点名称cluster.initial_master_nodes: ["node-1"]# 新增配置xpack.ml.enabled: false 解决启动报Caused by: org.elasticsearch.ElasticsearchException: Failure running machine learning native code. This could be due to running on an unsupported OS or distribution, missing OS libraries, or a problem with the temp directory. To bypass this problem by running Elasticsearch without machine learning functionality set [xpack.ml.enabled: false]xpack.ml.enabled: false
创建目录并授予权限
mkdir -p /app/data/es /app/logs/eschown appuser.appuser -R /app/data/es/ /app/logs/es/
可以根据自己的需求调整 xms 和 xmx
由于我的环境默认是jdk8, 需要在启动文件中指定jdk11目录
export JAVA_HOME=/usr/local/java/jdk-11.0.10切换到root用户 修改sysctl.conf
= 655360【保存完毕后,从指定的文件加载系统参数(不指定即从/etc/sysctl.conf中加载)】sysctl -p
修改limits
vim /etc/security/limits.conf【末尾加上一下内容,首单词是用户名】appuser soft nofile 65536appuser hard nofile 65536appuser soft nproc 4096appuser hard nproc 4096
#启动sh elasticsearch-7.10.0/bin/elasticsearch# 后台启动sh elasticsearch-7.10.0/bin/elasticsearch -d
报错
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_251/jre] does not meet this requirement
elasticsearch-7.10.0/bin/elasticsearch-env: line 126: syntax error near unexpected token `<'
修改elasticsearch-env文件的第126行
done < < (env)改为:done <<< `env`
cd /app/es/elasticsearch-7.10.0/plugins# ik的版本和es一定要匹配https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.10.0/elasticsearch-analysis-ik-7.10.0.zipunzip elasticsearch-analysis-ik-7.10.0.zip -d ./ik# 解压后将zip删除,否则会认为是一个插件,无法加载rm -rf plugins/elasticsearch-analysis-ik-7.10.0.zip
firewall-cmd --zone=public --add-port=9200/tcp --permanentfirewall-cmd --reload
原文作者:5ycode;如有侵权,请联系管理员删除。