1、关闭防火墙和SELINUX
代码语言:javascript
复制systemctl stop firewalld
systemctl disable firewalld
代码语言:javascript
复制setenforce 0
sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
2、JDK安装
代码语言:javascript
复制rpm -qa|grep java|xargs rpm -e --nodeps
代码语言:javascript
复制tar -zxvf jdk*.tar.gz -C /opt
vi /etc/profile.d/custom.sh
代码语言:javascript
复制 source /etc/profile.d/custom.sh
java -version
3、创建用户和组
代码语言:javascript
复制 groupadd elastic
useradd elastic -g elastic
passwd elastic
4、Elasticsearch软件包安装
代码语言:javascript
复制tar -zxvf elastic*.tar.gz -C /opt
代码语言:javascript
复制chown -R elastic:elastic /opt/elasticsearch-6.4.3
代码语言:javascript
复制mkdir -p /var/log/elasticsearch
mkdir -p /data/elasticsearch
chown -R elastic:elastic /var/log/elasticsearch
chown -R elastic:elastic /data/elasticsearch
代码语言:javascript
复制cd /opt/elasticsearch-6.4.3/config/
vi elasticsearch.yml
代码语言:javascript
复制# ---------------------------------- 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.
#
代码语言:javascript
复制sed -i '$avm.max_map_count=262144' /etc/sysctl.conf
sysctl -p
代码语言:javascript
复制vi /etc/security/limits.conf
代码语言:javascript
复制* hard nofile 65536
* soft nofile 65536
* soft nproc 2048
* hard nproc 4096
# End of file
代码语言:javascript
复制su elastic
bin/elasticsearch -d
jps