elasticsearch启动时可能遇到的报错

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

增加用户

group add elk 
useradd -G elk elk
passwd elk 
su - elk 

修改相关参数

/etc/security/limits.conf
增加elk - nofile 655360

/etc/sysctl.conf
增加vm.max_map_count = 262144
执行sysctl -p生效

elasticsearch.yml配置

如下是集群模式下elasticsearch.yml的配置示例:

[root@ZJHZ-CMREAD-ELASTIC10-VBUS-SQ config]# cat elasticsearch.yml |grep -v ^#|grep -v ^$
cluster.name: cmread-search
node.name: node-10
node.master: false
node.max_local_storage_nodes: 1
node.data: true 
path.data: /data
network.host: 0.0.0.0
http.port: 9201
discovery.zen.ping.unicast.hosts: ["10.115.18.140","10.115.18.141"]
discovery.zen.minimum_master_nodes: 2 
discovery.zen.ping_timeout: 60s
cluster.routing.allocation.node_initial_primaries_recoveries: 10
cluster.routing.allocation.node_concurrent_recoveries: 8 
indices.recovery.max_bytes_per_sec: 100mb
indices.requests.cache.size: 60%
gateway.recover_after_nodes: 9

修改默认账户信息

安装x-pack 插件,Elasticsearch 的默认账户为 elastic 默认密码为 changme

curl -XPUT -u elastic 'http://localhost:9200/_xpack/security/user/elastic/_password' -d '{
  "password" : "yourpasswd"
}'s
curl -XPUT -u elastic 'http://localhost:9200/_xpack/security/user/kibana/_password' -d '{
  "password" : "yourpasswd"
}'

图形化管理

elasticsearch head插件具有可视化集群管理、数据可视化、增删改查功能,安装完成后,访问地址是http://{你的ip地址}:9200/_plugin/head/。不过其是把双刃剑,便利的同时会造成不安全的问题,故生产环境尽量不要使用。


donation