Elasticsearch 6.x集群搭建

版权声明:本文为博主原创文章,欢迎转载。 https://blog.csdn.net/chengyuqiang/article/details/83996595

以下操作,每个节点相同

1、关闭防火墙和SELINUX

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config

2、JDK安装

rpm -qa|grep java|xargs rpm -e --nodeps
tar -zxvf jdk*.tar.gz -C /opt
vi /etc/profile.d/custom.sh
 source /etc/profile.d/custom.sh
 java -version

3、创建用户和组

 groupadd elastic
 useradd elastic -g elastic
 passwd elastic

4、Elasticsearch软件包安装

tar -zxvf elastic*.tar.gz -C /opt
chown -R elastic:elastic /opt/elasticsearch-6.4.3
chown -R elastic:elastic /var/log/elasticsearch
chown -R elastic:elastic /data/elasticsearch
cd /opt/elasticsearch-6.4.3/config/
vi elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#ES集群名
cluster.name: tpa

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: elastic1
#默认情况下,ElasticSearch将当前节点配置为同时作为候选主结点和数据结点
#候选主结点
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: /path/to/data
#数据目录,多个数据文件使用逗号隔开
path.data: /data/elasticsearch
#
# Path to log files:
#
#path.logs: /path/to/logs
#日志目录
path.logs: /var/log/elasticsearch

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#配置当前结点绑定的IP地址,默认为0.0.0.0
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
#http.port: 9200
#对外服务的HTTP端口
http.port: 9200
#结点间交互的TCP端口
transport.tcp.port: 9300
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
# 集群的发现机制
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#指定接收单播请求的主机,推荐包含组成集群的所有主机,主机之间用逗号隔开
discovery.zen.ping.unicast.hosts: ["elastic1", "elastic2", "elastic3"]


# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#discovery.zen.minimum_master_nodes:
#默认值是1,该属性定义的是为了组成一个集群,相互连接的候选主结点的最小数目
#强烈推荐该属性的设置使用多数原则:(master_eligible_nodes / 2) + 1,既能避免出现脑裂(split-brain)
discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#

sed -i '$a\vm.max_map_count=262144' /etc/sysctl.conf
sysctl -p
vi /etc/security/limits.conf
* hard nofile 65536
* soft nofile 65536
* soft nproc 2048
* hard nproc 4096
# End of file
su elastic
bin/elasticsearch -d
jps

猜你喜欢

转载自blog.csdn.net/chengyuqiang/article/details/83996595
今日推荐