配置:css
節點數 | 4 |
---|---|
操做系統 | CentOS Linux release 7.4.1708 (Core) |
內存 | 16GB |
軟件 | 版本 | 下載地址 |
---|---|---|
jdk | jdk-8u172-linux-x64 | 點擊下載 |
elasticsearch | elasticsearch-6.3.1 | 點擊下載 |
kibana | kibana-6.3.1-linux-x86_64 | 點擊下載 |
4個節點角色規劃以下:html
主機名 | pycdhnode1 | pycdhnode2 | pycdhnode3 | pycdhnode4 |
---|---|---|---|---|
IP | 192.168.0.158 | 192.168.0.159 | 192.168.0.160 | 192.168.0.161 |
master節點 | yes | yes | yes | yes |
data節點 | yes | yes | yes | yes |
kibana | yes | no | no | no |
注: 在實際生產中,仍是建議master節點和data節點分離java
SELinux
sed -i 's/^SELINUX=.*$/SELINUX=disabled/g' /etc/selinux/config setenforce 0
firewalld
or iptables
systemctl disable firewalld; systemctl stop firewalld; systemctl disable iptables; systemctl stop iptables;
ntpdate
echo "*/5 * * * * /usr/sbin/ntpdate asia.pool.ntp.org | logger -t NTP" >> /var/spool/cron/root
echo 'export TZ=Asia/Shanghai' >> /etc/profile echo 'export LANG=en_US.UTF-8' >> /etc/profile . /etc/profile
useradd -m elasticsearch
echo 'elasticsearch' | passwd --stdin elasticsearch
修改家目錄node
mv /home/elasticsearch /application chown -R elasticsearch. /application/elasticsearch
vi /etc/passwd
,修改elasticsearch用戶家目錄:python
elasticsearch:x:1001:1001::/application/elasticsearch:/bin/bash
設置PS1linux
su - elasticsearch
echo 'export PS1="\u@\h:\$PWD>"' >> ~/.bash_profile echo "alias mv='mv -i' alias rm='rm -i'" >> ~/.bash_profile . ~/.bash_profile
su - elasticsearch ssh-keygen -t rsa # 一直回車便可生成elasticsearch用戶的公鑰和私鑰 cd .ssh vi id_rsa.pub # 去掉私鑰末尾的主機名 elasticsearch@pycdhnode1 cat id_rsa.pub > authorized_keys chmod 600 authorized_keys
壓縮.ssh文件夾nginx
su - elasticsearch zip -r ssh.zip .ssh
隨後分發ssh.zip到pycdhnode2-4主機elasticsearch用戶家目錄解壓即完成免密登陸git
注: 以上操做須要使用 root
用戶,到目前爲止操做系統環境已經準備完成,如下開始正式安裝,後面的操做若是不作特殊說明均使用 elasticsearch
用戶es6
全部節點都須要安裝,安裝方式都同樣 解壓 jdk-8u172-linux-x64.tar.gz
github
tar zxvf jdk-8u172-linux-x64.tar.gz mkdir -p /application/elasticsearch/app mv jdk-8u172-linux-x64 /application/elasticsearch/app/jdk rm -f jdk-8u172-linux-x64.tar.gz
配置環境變量 vi ~/.bash_profile
添加如下內容:
#java export JAVA_HOME=/application/elasticsearch/app/jdk export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
加載環境變量
. ~/.bash_profile
查看是否安裝成功 java -version
java version "1.8.0_172" Java(TM) SE Runtime Environment (build 1.8.0_172-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
若是出現以上結果證實安裝成功。
首先在pycdhnode1上安裝 解壓 elasticsearch-6.3.1.tar.gz
tar zxvf elasticsearch-6.3.1.tar.gz mv elasticsearch-6.3.1 /application/elasticsearch/app/elasticsearch rm -f elasticsearch-6.3.1.tar.gz
設置環境變量 vi ~/.bash_profile
添加如下內容:
#elasticsearch export ELASTICSEARCH_HOME=/application/elasticsearch/app/elasticsearch export PATH=$PATH:$ELASTICSEARCH_HOME/bin
加載環境變量
. ~/.bash_profile
添加配置文件 vi /application/elasticsearch/app/elasticsearch/config/elasticsearch.yml
:
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # #cluster.name: py_es_6.3 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # #node.name: pyesnode-1 # # 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 to log files: # #path.logs: /path/to/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # #network.host: 192.168.0.1 # # Set a custom port for HTTP: # #http.port: 9200 # # 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"] # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # #discovery.zen.minimum_master_nodes: # # For more information, consult the zen discovery module documentation. # # ---------------------------------- Gateway ----------------------------------- #