安装JDK
下载:https://www.elastic.co/cn/downloads/elasticsearch
解压:tar -zxvf elasticsearch-7.12.0-linux-aarch64.tar.gz
修改文件名:mv elasticsearch-7.12.0 es
配置elasticsearch集群:
cd config
vi elasticsearch.yml
集群名称: cluster.name: es
节点名称: node.name: es-node-1
数据路径: path.data: /home/es/data
日志路径: path.logs: /home/es/logs
本机IP: network.host: 192.168.3.205
端口号: http.port: 9200
跨域: http.cors.enabled: true http.cors.allow-origin: "*"
集群节点列表: discovery.seed_hosts: ["192.168.3.205", "192.168.3.190"]
设置有资格选举为master的节点列表自举master: cluster.initial_master_nodes: ["192.168.3.205", "192.168.3.190"]
创建数据路径:
cd /home/es
mkdir data
vi jvm.options
-Xms512m
-Xmx512m
启动:
cd /elasticsearch7.12.0/bin ./elasticsearch
报错:
①./elasticsearch-env:行83: /home/es/jdk/bin/java: 无法执行二进制文件
配件Java环境变量:
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_221-amd64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
②java.lang.RuntimeException: can not run elasticsearch as root
添加用户:adduser es
chown -R es /home/es
切换用户:su es
cd /home/es/bin ./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].]
vi elasticsearch.yml 添加xpack.ml.enabled: false
④max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
su root vi /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535
max number of threads [3870] for user [es] is too low, increase to at least [4096]
su root vi/etc/security/limits.conf es soft nproc 4096 es hard nproc 4096
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
su root vi /etc/sysctl.conf vm.max_map_count = 262144
立即生效:/sbin/sysctl -p
开放9200和9300端口:
firewall-cmd --add-port=9200/tcp --permanent
firewall-cmd --add-port=9300/tcp --permanent
firewall-cmd --reload
su es
cd /home/es/bin ./elasticsearch
访问:http://192.168.3.205:9200
网友评论