elasticsearch在linux环境安装使用过程遇到的问题

es在linux环境安装遇到问题

1、启动失败日志

ERROR: [1] bootstrap checks failed
[1]: 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

原因分析:

看提示可知:缺少默认配置,至少需要配置discovery.seed_hosts/discovery.seed_providers/cluster.initial_master_nodes中的一个参数.

discovery.seed_hosts:  集群主机列表
discovery.seed_providers: 基于配置文件配置集群主机列表
cluster.initial_master_nodes: 启动时初始化的参与选主的node,生产环境必填
 处理办法:修改配置文件,添加参数即可

vim config/elasticsearch.yml
 
 
#添加配置
discovery.seed_hosts: ["127.0.0.1"]
 
cluster.initial_master_nodes: ["node-1"]

2、启动失败日志:

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方案:

在/etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

执行/sbin/sysctl -p 立即生效

3、启动报错日志

future versions of Elasticsearch will require Java 11; your Java version from [/opt/softs/jdk1.8.0_124/jre] does not meet this requirement

解决方案:可以安装一个JDK11;也可以直接使用es包里面自己的JDK 

4、权限问题:

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.2.jar:5.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.2.jar:5.6.2]

不能用root用户:

方案一:需要创建新的用户

adduser nandao

passwd nandao
#此目录一定要包含JDK相关的目录,否则启动时找不到JDK
chown -R nandao:nandao /usr/local

chmod 770 /usr/local/

 创建后:

方案二:修改elaticsearch配置,使其可以允许root用户启动:

#在执行elasticSearch时加上参数-Des.insecure.allow.root=true,完整命令如下

./elasticsearch -Des.insecure.allow.root=true

#或者 用vi打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加以下命令

ES_JAVA_OPTS="-Des.insecure.allow.root=true"

 此方案不一定靠谱,有时候执行也报错:

 5、后台运行:

#启动es服务 -d表示后台运行
./elasticsearch -d 

然后测试是否成功:

curl 127.0.0.1:9200

 6、线上下载:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.3-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.3-linux-x86_64.tar.gz.sha512
tar -zxvf elasticsearch-7.9.3-linux-x86_64.tar.gz

7、切换用户报错:

su 命令报错 su: Permission denied

一般是普通用户切换root用户报错,解决方案:

解决方案:查看suPAM认证配置 cd /etc/pam.d   然后 cat su,

 su 的PAM配置文件中有auth required pam_wheel.so use_uid根据上一句的说明可以知道要使用su命令则该用户必须在wheel用户组中,而我的普通用户没有在wheel用户组中。有两种方法可以解决这个问题,一是注释该行,二是将普通用户加入wheel组。上图我是注释掉了此行配置,然后再切换root用户时输入正确密码就可以正常切换了。

8、监控检查:GET _cat/health  状态为 yellow

1672375298 04:41:38 elasticsearch yellow 1 1 12 12 0 0 6 0 - 66.7%

kibana+elasticsearch使用ik分词器发现同一个请求,有时会报错,有时成功

原因是单节点状态下无法分配replicas节点,所以单节点下需要将replicas设置为0.

GET /_cluster/health

查看结果:"unassigned_shards" : 5,

解决过程:

设置现有的index的副本数量为0个

PUT /_settings
{
  "index": {
    "number_of_replicas": 0
  }
}

设置新建的index副本数量为0个,(创建模板匹配所有index,并设置副本数量为0)

PUT /_template/template_log
{
  "index_patterns": [
    "*"
  ],
  "order": 0,
  "settings": {
    "number_of_replicas": 0
  }
}

 9、

10、

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寅灯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值