Linux搭建环境之安装elasticsearch篇

1.下载elasticsearch安装包

下载elasticsearch安装包官方文档https://www.elastic.co/downloads/elasticsearch

2.上传elasticsearch安装包

    2.1解压elasticsearch

tar -zxvf elasticsearch-6.4.3.tar.gz

   2.2修改elasticsearch.yml

network.host: 192.168.212.151

http.port: 9200

   2.3启动elasticsearch报错

Cd /usr/local/elasticsearch-6.4.3/bin

./elasticsearch

can not run elasticsearch as root

解决方案:

因为安全问题elasticsearch

 

 不让用root用户直接运行,所以要创建新用户

第一步:liunx创建新用户  adduser XXX    然后给创建的用户加密码 passwd XXX    输入两次密码。

第二步:切换刚才创建的用户 su XXX  然后执行elasticsearch  会显示Permission denied 权限不足。

第三步:给新建的XXX赋权限,chmod 777 *  这个不行,因为这个用户本身就没有权限,肯定自己不能给自己付权限。所以要用root用户登录付权限。

第四步:root给XXX赋权限,chown -R XXX /你的elasticsearch安装目录。

然后执行成功。

 

创建一个分组

 groupadd esmayikt

useradd esyushengjun -g esmayikt -p 123456

chown -R esyushengjun:esmayikt  elasticsearch-6.4.3

su esyushengjun 切换用户 

 

继续报错

bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is

vi /etc/sysctl.conf

vm.max_map_count=655360

sysctl p

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

vi /etc/security/limits.conf

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

重启服务器即可 

3.访问elasticsearch

关闭防火墙

 systemctl stop firewalld.service

http://192.168.212.151:9200

效果如下:

9300与9200区别

9300端口: ES节点之间通讯使用
9200端口: ES节点 和 外部 通讯使用

4.界面工具Kibana安装

下载:https://www.elastic.co/downloads/kibana

tar  -zxvf kibana-6.4.3-linux-x86_64.tar.gz


vim config/kibana.yml
# 将默认配置改成如下:
server.port: 5601
server.host: "192.168.212.151"
elasticsearch.url: "http:// 192.168.212.151:9200"

启动Kibana
./bin/kibana

http://192.168.212.179:5601/app/kibana

5.集群搭建实现

准备三台服务器集群

 

服务器名称

IP地址

node-1

192.168.212.182

node-2

192.168.212.183

node-3

192.168.212.184

vi elasticsearch.yml
cluster.name: myes  ###保证三台服务器节点集群名称相同
node.name: node-1 #### 每个节点名称不一样 其他两台为node-1 ,node-2
network.host: 192.168.212.180 #### 实际服务器ip地址
discovery.zen.ping.unicast.hosts: ["192.168.212.184", "192.168.212.185","192.168.212.186"]##多个服务集群ip
discovery.zen.minimum_master_nodes: 1

关闭防火墙 systemctl stop firewalld.service

默认底层开启9300 集群

验证集群效果

http://192.168.212.185:9200/_cat/nodes?pretty

注意克隆data文件会导致数据不同步

报该错误解决办法

failed to send join request to master

因为克隆导致data文件也克隆呢,直接清除每台服务器data文件。

*号表示为master节点

猜你喜欢

转载自blog.csdn.net/qq_41988225/article/details/84399815