创建用户:
useradd es
授权:
chown -R es:es /home/elasticsearch/elasticsearch-7.10.2
切换到es 用户进入bin启动elasticsearch
su es
cd /home/elasticsearch/elasticsearch-7.10.2/bin
./elasticsearch
后台启动es
./elasticsearch -d
使用一个窗口登录root用户,查看是否启动成功
curl -XGET http://localhost:9200
启动问题
问题一
yml配置文件100行存在参数问题
打开配置文件发现100行开头 xpack.security.enrollment.enabled: true 缺乏空格,导致es启动失败
问题二
启动es控制台报错
[2022-05-16T16:18:12,368][WARN ][o.e.t.ThreadPool ] [node-1] execution of [ReschedulingRunnable{runnable=org.elasticsearch.watcher.ResourceWatcherService$ResourceMonitor@23bbb66f, interval=5s}] took [5405ms] which is above the warn threshold of [5000ms]
[2022-05-16T16:18:13,189][INFO ][o.e.x.s.a.s.FileRolesStore] [node-1] parsed [0] roles from file [/datas/elasticsearch-8.2.0/config/roles.yml]
[2022-05-16T16:18:45,374][WARN ][o.e.t.ThreadPool ] [node-1] execution of [ReschedulingRunnable{runnable=org.elasticsearch.watcher.ResourceWatcherService$ResourceMonitor@23bbb66f, interval=5s}] took [14313ms] which is above the warn threshold of [5000ms]
[2022-05-16T16:18:51,806][INFO ][o.e.t.n.NettyAllocator ] [node-1] creating NettyAllocator with the following configs: [name=unpooled, suggested_max_allocation_size=1mb, factors={es.unsafe.use_unpooled_allocator=null, g1gc_enabled=true, g1gc_region_size=4mb, heap_size=920mb}]
[2022-05-16T16:18:52,044][INFO ][o.e.i.r.RecoverySettings ] [node-1] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
[2022-05-16T16:18:52,522][INFO ][o.e.d.DiscoveryModule ] [node-1] using discovery type [multi-node] and seed hosts providers [settings]
[2022-05-16T16:19:03,718][INFO ][o.e.n.Node ] [node-1] initialized
[2022-05-16T16:19:03,788][INFO ][o.e.n.Node ] [node-1] starting ...
[2022-05-16T16:19:04,465][INFO ][o.e.x.s.c.f.PersistentCache] [node-1] persistent cache index loaded
[2022-05-16T16:19:04,472][INFO ][o.e.x.d.l.DeprecationIndexingComponent] [node-1] deprecation component started
[2022-05-16T16:19:07,672][INFO ][o.e.t.TransportService ] [node-1] publish_address {172.30.165.18:9300}, bound_addresses {[::]:9300}
[2022-05-16T16:19:16,622][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /datas/elasticsearch-8.2.0/logs/my-application.log
[2022-05-16T16:19:20,621][INFO ][o.e.n.Node ] [node-1] stopping ...
[2022-05-16T16:19:24,691][INFO ][o.e.n.Node ] [node-1] stopped
[2022-05-16T16:19:24,801][INFO ][o.e.n.Node ] [node-1] closing ...
[2022-05-16T16:19:27,478][INFO ][o.e.n.Node ] [node-1] closed
[2022-05-16T16:19:27,536][INFO ][o.e.x.m.p.NativeController] [node-1] Native controller process has stopped - no new native processes can be started
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 立即生效
问题三
服务器内存不足
修改config文件夹下面的jvm.options文件的相关配置参数
-
虚拟机为4G时 -Xms1960m -Xmx1960m
-
虚拟机 为8G 时 -Xms3976m -Xmx3976m
-
虚拟机 为16G 时 -Xms8008m -Xmx8008m
-
Xms然后Xmx. 最小值和最大值必须相同 -
设置
Xms和Xmx不超过总内存的 50% -
不能超过oops的阈值
Xms和Xmx的大小不能超过32gb,这是压缩普通对象指针【oops】的近似阈值。要验证您是否低于阈值,请检查elasticsearch.logs中是否存在如下日志:
heap size [1.9gb], compressed ordinary object pointers [true] (blog.csdn.net/qq_19897551…)
问题四
elasticsearch用户的最大线程数太低
修改limits.d目录下的配置文件
vim /etc/security/limits.d/90-nproc.conf
注意:完成后退出服务器,重新登陆用户生效!!!
问题五
es6以后的内置# x-pack.security组件,导致启动和访问安全验证受阻,暂时解决方案是将相关配置关闭