Elasticsearch 6.x叢集搭建
阿新 • • 發佈:2018-12-21
以下操作,每個節點相同
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