12.ubuntu 16.04.6 安裝 Elasticsearch
阿新 • • 發佈:2020-08-06
需要提前安裝和配置java
具體參見教程:https://www.cnblogs.com/ff111/p/11868976.html
1.下載Elasticsearch 5.6.16
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-5-6-16
elasticsearch-5.6.16.tar.gz
2.上傳到ubuntu目錄
/apps/es/
3.解壓
tar zxvf elasticsearch-5.6.16.tar.gz
4.建立ES使用者和組(建立elsearch使用者組及elsearch使用者),因為使用root使用者執行ES程式,將會出現錯誤;所以這裡需要建立單獨的使用者去執行ES 檔案。
groupadd esgroup ##新增使用者組 useradd -m esuser -g esgroup ##新增使用者到使用者組 chown -R esuser:esgroup /apps/es/elasticsearch-5.6.16 ##更改該資料夾下所屬的使用者組的許可權
5.建立ES資料檔案和日誌檔案
#建立data目錄 mkdir /data #更改許可權 chown -R esuser:esgroup /data/ #切換使用者
- esuser
#建立 es的data和logs目錄
cd /data
mkdir -p es/data
mkdir -p es/data
#切回root使用者su - root
#進入es配置檔案
vi /apps/es/elasticsearch-5.6.16/config/elasticsearch.yml
#叢集名稱 cluster.name: my-application #節點名稱 node.name: node-1 #資料儲存目錄(多個路徑用逗號分隔) path.data: /data/es/data #日誌目錄 path.logs: /data/es/logs # 修改一下ES的監聽地址,這樣別的機器才可以訪問 根據實際本機地址修改 network.host: 192.168.215.10 # 監聽埠(預設的就好) http.port: 9200
注意,設定引數的時候“:冒號”後面要有空格
儲存退出配置檔案
6.啟動
切換到elsearch使用者,進入到bin 目錄下執行 ./elasticsearch 命令就可以了,執行 ./elasticsearch -d 是後臺執行
cd /apps/es/elasticsearch-5.6.16/bin/
./elasticsearch
7.請求
附:
發現錯誤1:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
意思是說你的程序不夠用了。
解決方案: 切到root 使用者:進入到security目錄下的limits.conf;執行命令 vi /etc/security/limits.conf :
[root@localhost bin]# vi /etc/security/limits.conf
在檔案的末尾新增下面的引數值:
* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
發現錯誤2:
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
作業系統的vm.max_map_count引數設定太小導致的,請使用root使用者登入系統,執行以下命令:
[root@localhost bin]# sysctl -w vm.max_map_count=655360 vm.max_map_count = 655360 [root@localhost bin]# sysctl -a | grep "vm.max_map_count" #檢視是否修改成功 vm.max_map_count = 655360
再次切換到elsearch使用者,進入到bin 目錄下執行 ./elasticsearch 命令,啟動正常。