安装环境
JDK1.8
Elasticsearch7.16.2
下载es安装包
Elasticsearch7.16.2下载地址
上传到linux并解压
tar -zxvf elasticsearch-7.16.2-linux-x86_64.tar.gz mv ../elasticsearch-7.16.2
删除源码包
rm -f elasticsearch-7.16.2-linux-x86_64.tar.gz
./bin/elasticsearch
启动报错
Exception in thread “main” java.nio.file.AccessDeniedException:
因为es不能使用root用户启动,因此新建用户并赋权,切换到新建用户,然后启动
adduser elastic chown -R elastic /usr/local/opt/elasticsearch-7.16.2/ su elastic ./bin/elasticsearch
原因是因为当前环境使用的是jdk8,es7以上自带jdk,对应的是jdk11,环境变量冲突,所以出现这个警告
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/opt/jdk1.8/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.
需要修改elasticsearch-env配置文件
修改以下代码片段:
# now set the path to java if [ ! -z "$ES_JAVA_HOME" ]; then JAVA="$ES_JAVA_HOME/bin/java" JAVA_TYPE="ES_JAVA_HOME" elif [ ! -z "$JAVA_HOME" ]; then fallback to JAVA_HOME echo "warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME" >&2 JAVA="$JAVA_HOME/bin/java" JAVA_TYPE="JAVA_HOME" else # use the bundled JDK (default) if [ "$(uname -s)" = "Darwin" ]; then # macOS has a different structure JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java" else JAVA="$ES_HOME/jdk/bin/java" fi JAVA_TYPE="bundled JDK" fi
将以上代码修改为
if [ "$(uname -s)" = "Darwin" ]; then # macOS has a different structure JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java" else JAVA="$ES_HOME/jdk/bin/java" fi JAVA_TYPE="bundled jdk"
修改esjvm大小
-Xms256m
-Xmx256m
vim config/jvm.options
启动报错
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 virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
编辑 /etc/sysctl.conf
最后添加vm.max_map_count=655360
vim /etc/sysctl.conf
保存后,执行:
sysctl -p
普通用户下启动
执行命令
curl 127.0.0.1:9200
启动成功
设置外网访问
vim /config/elasticsearch.yml
添加以下内容,并且开放远程防火墙端口,如果是云服务器,需要设置安全组开放9200端口
cluster.name: elasticsearch node.name: node-1 path.data: /usr/local/opt/elasticsearch-7.16.2/data path.logs: /usr/local/opt/elasticsearch-7.16.2/logs network.host: 0.0.0.0 http.port: 9200 cluster.initial_master_nodes: ["node-1"]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)