centos7安装elasticsearch伪集群
####### 主从节点
首先需要安装java环境
1.下载elasticsearch-7.0.1安装包
# 进入到/opt目录下
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.1-linux-x86_64.tar.gz
# 解压
tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz
# 复制另外一个节点的elasticsearch文件
cp -R elasticsearch-7.0.1 elasticsearch-7.0.1-node-2
2.添加普通用户
# 在linux环境中,elasticsearch不允许以root权限运行,这里创建一个elk用户
groupadd elk # 创建用户组elk
useradd elk -g elk -s /bin/bash # 创建新用户elk,-g elk 设置其用户组为 elk,-p elk 设置其密码为elk
chown -R elk.elk /opt # 更改 /opt 文件夹及内部文件的所属用户及组为 elk:elk
3.elasticsearch : which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
which java
# /usr/local/java/bin/java
ln -s /usr/local/java/bin/java /usr/bin/java
4.修改配置(两个节点分别配置)
# 进入到主节点的文件目录下
# cd elasticsearch-7.0.1
# vim config/elasticsearch.yml
cluster.name: es
node.name: node-1
node.master: true
node.data: true
path.data: /opt/elasticsearch-7.0.1/data
path.logs: /opt/elasticsearch-7.0.1/logs
#允许远程访问
network.host: 0.0.0.0
transport.tcp.port: 9300
http.port: 9200
# 单节点一项配置
# discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301"]
action.destructive_requires_name: true
# 防止脑裂
discovery.zen.minimum_master_nodes: 2
# 允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
# 进入到从节点文件目录下
# cd elasticsearch-7.0.1-node-2
# vim config/elasticsearch.yml
cluster.name: es
node.name: node-2
node.master: true
# node.master: false
node.data: true
path.data: /opt/elasticsearch-7.0.1-node-2/data
path.logs: /opt/elasticsearch-7.0.1-node-2/logs
#允许远程访问
network.host: 0.0.0.0
transport.tcp.port: 9301
http.port: 9201
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301"]
action.destructive_requires_name: true
# 防止脑裂
discovery.zen.minimum_master_nodes: 2
# 允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
# 新建两个文件
mkdir -p /opt/elasticsearch-7.0.1-node-2/data
mkdir -p /opt/elasticsearch-7.0.1/data
5.修改分配的jvm空间大小
# vim config/jvm.options
-Xms4g → -Xms512m
-Xmx4g → -Xmx512m
6.修改系统配置
# max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p
# vim /etc/security/limits.conf
# 以下配置解决如下错误
# max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
# memory locking requested for elasticsearch process but memory is not locked
elk hard nofile 65536
elk soft nofile 65536
elk soft memlock unlimited
elk hard memlock unlimited
7.分别启动elasticsearch,使用浏览器访问ES
[root@VM_0_9_centos elasticsearch-7.0.1]# su elk
[elk@VM_0_9_centos elasticsearch-7.0.1]$ sh ./bin/elasticsearch
#[root@VM_0_9_centos elasticsearch-7.0.1-node-2]# su elk
#[elk@VM_0_9_centos elasticsearch-7.0.1-node-2]$ sh ./bin/elasticsearch
This account is currently not available。
vim /etc/passwd
参考链接:https://blog.csdn.net/moxiaomomo/article/details/82778922
参考链接:https://blog.csdn.net/qq_22638399/article/details/80839694
参考链接:https://blog.csdn.net/a19860903/article/details/72467996