Elasticsearch (ES篇): 运行环境安装配置-2

210 阅读2分钟

「这是我参与2022首次更文挑战的第15天,活动详情查看:2022首次更文挑战」。

vim elasticsearch.yml

修改数据和日志目录:

path.data: /home/新用户名称/elasticsearch/data # 数据目录位置

path.logs: /home/新用户名称/elasticsearch/logs # 日志目录位置

修改绑定的ip:

network.host: 0.0.0.0 # 绑定到0.0.0.0,允许任何ip来访问

默认只允许本机访问,修改为0.0.0.0后则可以远程访问

配置信息如下:

属性名说明
cluster.name配置elasticsearch的集群名称,默认是elasticsearch,可以修改成一个有意义的名称;
node.name节点名,es会默认随机指定一个名字,建议指定一个有意义的名称;
path.data设置索引数据的存储路径,默认是es根目录下的data文件夹,可以设置多个存储路径,用逗号隔开
path.logs设置日志文件的存储路径,默认是es根目录下的logs文件夹
bootstrap.memory_lock设置为true可以锁住ES使用的内存,避免内存进行swap
network.host设置bind_host,设置为0.0.0.0允许外网访问
http.port设置对外服务的http端口,默认为9200
discovery.seed_hosts启动此节点时,传递要执行发现的主机的初始列表
cluster.initial_master_nodes使用一组初始的主节点引导集群
  • max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  • [1] : max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

切换到root用户,编辑limits.conf 添加类似如下内容

vim /etc/security/limits.conf

添加如下内容:

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 2048
  • hard nproc 4096

然后重启linux

  • [2] : max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  • elasticsearch用户拥有的内存权限太小,至少需要262144;

解决办法:

  • 在 /etc/sysctl.conf文件最后添加一行
  • vm.max_map_count=262144

即可永久修改  

  • [3]: 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 注释打开,写上当前主节点的IP;

启动与关闭

  • ./elasticsearch 前台运行,Ctrl + C 则程序终止;
  • ./elasticsearch -d 后台运行\
  • 出现started时启动完成

关闭 kill pid

  • Elasticsearch端口9300、9200\
  • 9300是tcp通讯端口,集群ES节点之间通讯使用;
  • 9200是http协议的RESTful接口