Elasticsearch 集群安裝
| ip地址 | 主機名 | 服務名 | 安裝軟件 |
| 192.168.0.7 | es-server-1 | Es01 | ES JDK es-head |
| 192.168.0.8 | es-server-2 | Es02 | ES JDK |
| 192.168.0.12 | es-server-3 | Es03 | ES JDK |
系統(tǒng)環(huán)境
[root@es-server-1 config]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
每臺服務器配置/etc/sysctl.conf,添加內(nèi)容
vm.max_map_count = 655360 #修改文件句柄數(shù)
添加之后 sysctl -p 讓其生效
2.每臺服務器配置/etc/security/limits.conf ,添加內(nèi)容
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
es - nproc 65536
es - nofile 65536
3, 每臺服務器配置主機名
vim /etc/hosts
192.168.0.7 es-server-1
192.168.0.8 es-server-2
192.168.0.12 es-server-3
每臺服務器安裝 JDK(jdk 版本必須在 1.8 版本之上)
mkdir –p /usr/java
cd /usr/java
下載jdk1.8.0_181.tar.gz
tar –zxvf jdk1.8.0_181.tar.gz
vim /etc/profile 最后添加
export JAVA_HOME=/usr/java/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
使其生效: source /etc/profile
查看安裝版本:
[root@es-server- 1config]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
每臺服務器安裝 elasticsearch
1,安裝之前環(huán)境準備
創(chuàng)建存儲目錄
mkdir /data/
創(chuàng)建 Elasticisearch 用戶 es 并授予權限
useradd -d /data/es -m es
cd /data/es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.0.tar.gz
tar -xvf elasticsearch-6.8.0.tar.gz
mv elasticsearch-6.8.0.tar.gz elasticsearch
創(chuàng)建存放數(shù)據(jù)、日志目錄
mkdir -p /data/es/elasticsearch/es_data
mkdir -p /data/es/elasticsearch/es_log
chown -R es:es /data/es
2,修改配置文件
先備份
[root@es-server-1 ~]# cd /data/es/elasticsearch/config/
[root@es-server-1 config]#
[root@es-server-1 config]# cp elasticsearch.yml elasticsearch.yml_0528bak
對配置文件添加參數(shù)
[root@es-server- 1config]#cat elasticsearch.yml
cluster.name: yuxi_es
node.name: es01
node.master: true
node.data: false
network.host: 0.0.0.0
http.port: 8900 #默認是9200可以不修改
discovery.zen.ping.unicast.hosts: ["192.168.0.7", "192.168.0.8", "192.168.0.12"]
http.cors.enabled: true #為es設置跨域訪問
http.cors.allow-origin: "*" #為es設置跨域訪問
path.data: /data/es/elasticsearch_data
path.logs: /data/es/elasticsearch_log
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 30s
另外兩臺服務器,同樣操作僅僅配置文件 node.name 分別為 es02 es03
啟動每臺 ES
授權后,并切換用戶
[root@es-server- 1 usr]# chown -R es.es /usr/java/
[root@es-server- 1 usr]# su - es
Last login: Thu May 28 14:48:54 CST 2020 on pts/7
啟動 ES
/data/es/elasticsearch/bin/elasticsearch -d
啟動后觀察集群狀態(tài):
[es@es-server-1 ~]$ curl http://192.168.0.7:8900
{
"name" : "Es01",
"cluster_name" : "yuxi_es",
"cluster_uuid" : "kEEpj9SYReKvMxELkyLspQ",
"version" : {
"number" : "6.8.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "65b6179",
"build_date" : "2019-05-15T20:06:13.172855Z",
"build_snapshot" : false,
"lucene_version" : "7.7.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
另外兩臺服務器同樣操作
安裝 es head 插件
1,在第一臺服務器創(chuàng)建目錄,并下載插件
mkdir -p /data/software
cd /data/software
yum install git
git clone https://github.com/mobz/elasticsearch-head.git
yum install -y nodejs nodejs-npm
注:如yum安裝nodejs沒有包
通過官方查詢需要安裝的版本
https://github.com/nodesource/distributions
在CentOS下獲取相應版本的nodejs資源(以NodeJS 8.x為例)
鍵入 curl -sL https://rpm.nodesource.com/setup_8.x | bash -
在執(zhí)行yum安裝
2,安裝 head 插件
[root@es-server- 1 ~]$ npm -v 3.10.10
[root@es-server- 1 elasticsearch-head]# cd /data/software/elasticsearch-head
[root@es-server-1 elasticsearch-head]# npm install -g configurable-http-proxy
3,啟動插件
[root@es-server-1 elasticsearch-head]# nohup npm run start & 或是運行grunt server 啟動
[1] 54923
[root@es-server-1 elasticsearch-head]# nohup: ignoring input and appending output to ‘nohup.out’
如啟動報錯可以根據(jù)報錯安裝需要的包
npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org
npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org
npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org
npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org
npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org
npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org
查看啟動
[root@es-server-1 elasticsearch-head]# cat nohup.out
> elasticsearch-head@0.0.0 start /data/software/elasticsearch-head
> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
進入圖形界面展示


浙公網(wǎng)安備 33010602011771號