场景
ubuntu环境下使用apt-get install elasticsearch安装es,一路掉坑,做个简单记录,避免再次踩坑。systemctl start elasticsearch 方式启动,通过 journalctl -xe 和 查看 elasticsearch日志进行排错。当前的elasticserch版本是8.6,日志默认位置在/var/log/elasticsearch/elasticsearch.log.优先使用es官网搜索答案,其次参考网络其他答案。
1. node.master 和 node.data 无法识别
elasticsearch unknown setting [node.master] please check that any required plugins are installed
...
elasticsearch unknown setting [node.data] please check that any required plugins are installed
解决方案
#/etc/elasticsearch/elasticsearch.yml#删除node.master和node.data,改为 node.roles#node.master:true#node.data:true
node.roles: [ master,data]
2. tmp目录没有权限
JNA temporary directory ‘/tmp’ is not writable
解决方案
# /usr/share/elasticsearch下创建目录tmp /etc/profile追加exportES_TMPDIR=/usr/share/elasticsearch/tmp
exportES_JAVA_OPTS="-Djna.tmpdir=/usr/share/elasticsearch/tmp"
3. --enable-preview错误
To make full use of MMapDirectory, please pass '--enable-preview' to the Java command line
解决方案
#/etc/elasticsearch/jvm.options.d 目录下创建 jvm.options-Djava.io.tmpdir=/usr/share/elasticsearch/tmp
-Djna.tmpdir=/usr/share/elasticsearch/tmp
--enable-preview
-Xms256m-Xmx256m-Des.enforce.bootstrap.checks=true
4. jvm.options中的Xms和Xmx保持一致,不然会报下面的错误
initial heap size [268435456] not equal to maximum heap size [1933574144]; this can cause resize pauses
5. timeout错误
elasticsearch.service: Failed with result 'timeout'.
解决方案
#/usr/lib/systemd/system/elasticsearch.service##原始值75,调大一点TimeoutStartSec=500
6. cluster.initial_master_nodes 错误
this node is locked into cluster UUID [LkG38jKHQu2JwB2wE-Wnbw] but [cluster.initial_master_nodes] is set to [lawrence-Lenovo-B4450s]; remove this setting to avoid possible data loss caused by subsequent cluster bootstrap attempts
解决方案
#/etc/elasticsearch/elasticsearch.yml 约115行注释掉 cluster.initial_master_nodes#cluster.initial_master_nodes: ["lawrence-Lenovo-B4450s"]
版权归原作者 107.2M 所有, 如有侵权,请联系我们删除。