詹学伟

詹学伟

一个爱好编程的90后站长。

关注我詹学伟个人微信号:tobecomputer

您现在的位置是:网站首页>博客详情

Centos7 elasticsearch集群安装

2020-10-07 詹学伟 专业交流 82 0

1.说明
服务器配置,三台centos虚拟机,ip列表如下:

192.168.183.101
192.168.183.102
192.168.183.103


安装es之前先安装jdk,jdk的安装略去。
es的版本:elasticsearch-6.5.4

2.配置

vim config/elasticsearch.yml



#配置es的集群名称,默认是elasticsearch,
#es会自动发现在同一网段下的es,
# 如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。

cluster.name: blog
#
# ------------------------------------ Node ------------------------------------
node.name: node_01
node.master: true
node.data: true
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/data/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300

discovery.zen.ping.unicast.hosts: ["192.168.183.101:9300","192.168.183.102:9300", "192.168.183.103:9300"]

discovery.zen.minimum_master_nodes: 2


3.分发

scp -r root@node2:`pwd`


4.修改
node2节点

node.name: node_02


node3节点

node.name: node_03


5.创建es用户

useradd es
passwd es
xxxxx


6.切换es用户

su es


7.启动es

./elesticsearch


遇到的问题:

1.配置文件设置的路径,es用户没有权限创建
解决:切回root用户,创建相应目录并赋权限

mkdir -p xxxx

sudo chmod -R a+rw xxxxxx



2.包一下错误
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [3795] for user [es] is too low, increase to at least [4096]
解决:

vim /etc/security/limits.conf
* soft nproc 4096
* hard nproc 4096
* soft nofile 65536
* hard nofile 65536


vim/etc/sysctl.conf
vm.max_map_count=262144


8.再次启动

9.访问浏览器

http://192.168.183.101:9200/_cat/nodes?v


10.elesticsearch head插件安装
1.安装git

yum install -y git


2.下载

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install


3.配置

cd elasticsearch-6.5.1/config/
vi elasticearch.yml


4.启动

cd elasticsearch-head/
npm run start


问题:
在进入head项目install的时候可能会报错:phantomjs-prebuilt@2.1.16 install: `node install.js`
解决:npm -g install phantomjs-prebuilt@2.1.16 --ignore-script


文章评论