Elasticsearch安裝
1、下載ES
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz
- 或者在windows下載好,放到服務器上
- tar -xvf elasticsearch-5.5.2.tar.gz
- 注意版本:5.5.2
- 注意:需要jdk1.8+
2、修改配置
修改conifig/elasticsearch.yml(主節點)
cluster.name: website-application
node.name: node-1-master-175-9200
node.master: true
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.175
http.port: 9200
transport.tcp.port: 9300
#設定集群中master節點的初始串列,可以通過這些節點來自動發現新加入集群的節點。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 為了避免腦裂,集群節點數最少為 (有master資格節點數/2) + 1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的引數,這樣head插件可以訪問es,解決跨域訪問問題
http.cors.enabled: true
http.cors.allow-origin: "*"
從節點
cluster.name: website-application
node.name: node-2-176-9200
node.master: false
#node.attr.rack: r1
node.data: true
path.data: /usr/local/elasticsearch/elasticsearch-5.5.2/data
path.logs: /usr/local/elasticsearch/elasticsearch-5.5.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
#設定集群中master節點的初始串列,可以通過這些節點來自動發現新加入集群的節點。
discovery.zen.ping.unicast.hosts: ["192.168.1.175:9300"]
# 為了避免腦裂,集群節點數最少為 半數+1
discovery.zen.minimum_master_nodes: 1
#discovery.zen.ping_timeout: 120s
#gateway.recover_after_nodes: 2
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 1
#script.engine.groovy.inline.search: on
#script.engine.groovy.inline.aggs: on
#indices.recovery.max_bytes_per_sec: 20mb
node.max_local_storage_nodes: 3
action.destructive_requires_name: false
# 增加新的引數,這樣head插件可以訪問es,解決跨域訪問問題
http.cors.enabled: true
http.cors.allow-origin: "*"
3、新建用戶es,分配檔案權限
es啟動需要在非root賬號下,所以需要新建一個用戶,新建用戶后,需要分配檔案權限,否則會報錯:
groupadd es
useradd es -g es -p es
chown -R es:es /usr/local/elasticsearch
chmod 775 /usr/local/elasticsearch
可能的報錯:
java.nio.file.AccessDeniedException: 或
bash: ./elasticsearch: Permission denied
4、 啟動,報錯處理
啟動命令 ./bin/elasticsearch
查看日志和報錯:
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
原因
每個行程最大打開檔案數大小太小,用戶擁有的記憶體權限太小,查看命令如下:
ulimit -Hn
ulimit -Sn
解決
切換到root賬戶下:
vi /etc/security/limits.conf添加或修改以下配置(用戶退出后重新登錄生效):
* hard nofile 65536
* soft nofile 65536
注意:65535不行,必須是65536
然后修改記憶體分配:
sudo sysctl -w vm.max_map_count=262144
5、重啟腳本
#!/bin/sh
NAME=elasticsearch
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
/usr/local/elasticsearch/elasticsearch-5.5.2/bin/elasticsearch -d
tail -300f /usr/local/elasticsearch/elasticsearch-5.5.2/logs/website-application.log
echo "---------------"
head安裝
1、下載解壓
- wget https://github.com/mobz/elasticsearch-head/archive/master.zip
- 或者windows下載好放到服務器上
- 需要nodejs環境
2、安裝nodejs
下載解壓:
wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz
xz -d node-v6.9.2-linux-x64.tar.xz
tar -xvf node-v6.9.2-linux-x64.tar
修改:
vi /etc/profile
增加配置:
export NODE_HOME=/usr/local/elasticsearch/node-v6.9.2-linux-x64
export PATH=$NODE_HOME/bin:$PATH
使之生效:
source /etc/profile
查看版本:
node -v
npm -v
3、繼續安裝
cd /usr/local/elasticsearch/elasticsearch-head-maste
npm install phantomjs-prebuilt@2.1.14 --ignore-scripts
可以在elasticsearch-head下使用npm run start啟動,可能會報警告:
[root@redis1 elasticsearch-head-master]# npm run start
> elasticsearch-head@0.0.0 start /usr/local/elasticsearch/elasticsearch-head-master
> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
使用命令安裝缺失的插件:
npm install grunt-contrib-clean grunt-contrib-concat grunt-contrib-watch grunt-contrib-connect grunt-contrib-copy grunt-contrib-jasmine
使用grunt server命令啟動報錯處理:
[root@redis1 elasticsearch-head-master]# grunt server
-bash: grunt: 未找到命令
安裝grunt快捷命令:
npm install -g grunt-cli
此后可以在elasticsearch-head下使用grunt server 命令啟動
4、修改配置
- 修改Gruntfile.js hostname屬性,添加主機ip
- 如果elasticsearch未針對head修改配置,需修改elasticsearch組態檔
conifig/elasticsearch.yml:
# 增加新的引數,這樣head插件可以訪問es,解決跨域訪問問題
http.cors.enabled: true
http.cors.allow-origin: "*"
# http.cors.allow-headers: "Authorization"
- 重啟es后生效
中文分詞安裝
- 去elasticsearch路徑下使用命令安裝
- ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.2/elasticsearch-analysis-ik-5.5.2.zip
- 注意版本一致
- 重啟es后生效
拼音分詞安裝
- wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.5.2/elasticsearch-analysis-pinyin-5.5.2.zip
- 或者本地下載好放到服務器
- 在elasticsearch下plugins檔案夾建立pinyin檔案夾,unzip解壓,放入此檔案夾
- 注意版本一致
wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.5.2/elasticsearch-analysis-pinyin-5.5.2.zip
unzip elasticsearch-analysis-pinyin-5.5.2.zip
mv elasticsearch ./elasticsearch-5.5.2/plugins/pinyin
- 重啟es后生效
kibana安裝
- wget https://artifacts.elastic.co/downloads/kibana/kibana-5.5.2-linux-x86_64.tar.gz
- 或者本地下載好放到服務器上
- tar -xvf kibana-5.5.2-linux-x86_64.tar.gz
- 注意版本與elasticsearch一致;
- 修改組態檔config/kibana.yml;
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://192.168.2.41:9200"
kibana.index: ".kibana"
啟動:./bin/kibana
后臺啟動:nohup ./bin/kibana &
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/266789.html
標籤:其他
下一篇:編程和做科研的一些認知和理解
