一、准備工作
1、安裝 JDK
2、服務器 2 台如下:
IP地址 | 端口 |
192.168.1.1 | 9201 |
192.168.1.2 | 9201 |
二、安裝前配置
1、使用 root 用戶先進行以下內容的配置
vi /etc/security/limits.conf #添加如下內容: * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 vi /etc/security/limits.d/90-nproc.conf #修改文件內容為 soft nproc 2048 vi /etc/sysctl.conf #添加下面配置: vm.max_map_count=655360 sysctl -p ulimit -n 65536 #保存后執行 sysctl -p
2、elasticsearch 限制 root 用戶啟動,所以需要先創建用戶
#添加用戶組添加用戶
groupadd es
useradd es -g es
3、創建 es 目錄並賦權
#創建 es 安裝目錄 mkdir /usr/local/es #創建 es 數據目錄 mkdir /data/es #更改目錄 Owner chown -R es:es /usr/local/es chown -R es:es /data/es
三、安裝步驟
1、下載 es 安裝包並解壓
tar -zxvf elasticsearch-6.4.2.tar.gz
2、移動 elasticsaerch 到/usr/local/es 目錄下
mv elasticsearch-6.4.2 /usr/local/es/ chown -R es:es /usr/local/es/elasticsearch-6.4.2/
3、切換至用戶 es
su es
4、創建 es 數據和日志存儲目錄
mkdir /data/es/data
mkdir /data/es/logs
5、修改 config 包下配置文件 elasticsearch.yml 如下:
cluster.name: elasticsearch-prod node.name: node-1 path.data: /data/es/data path.logs: /data/es/logs network.host: 0.0.0.0 http.port: 9201 http.enabled: true #服務發現端口 transport.tcp.port: 9301 #集群發現 IP 集合,有幾個節點就寫幾個 IP discovery.zen.ping.unicast.hosts: ["192.168.1.1:9301", "192.168.1.2:9301"] http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type #以下配置用於開啟密碼驗證,不設密碼請忽略 #xpack.security.enabled: true #xpack.security.transport.ssl.enabled: true
6、啟動 elasticsearch
注:elasticsearch 限制 root 用戶不能啟動,請使用用戶 es 啟動
su es cd /usr/local/es/elasticsearch-6.4.2/bin #前台啟動方式 ./elasticsearch #后台啟動方式 ./elasticsearch -d
四、集群部署
參照以上步驟再操作一遍即可,請注意所有節點的集群名稱(cluster.name)保持一致。