es集群搭建
?
?
1、復制5份es,版本要相同,且各個節點上jdk版本也要相同,否則會報數據同步格式不一致? invalid internal transport message format。
2、配置elasticsearch.yml,主要修改以下方面:
cluster.name: my-application? ? #集群名,各個節點要一致
node.name: node-01? ? ? ? ?#節點名
path.data: /data1/elk/elasticsearch/data? ?#數據存儲位置
path.logs: /data1/elk/elasticsearch/logs? #日志
bootstrap.system_call_filter: false? ?#關閉鎖內存
network.host: 192.168.0.1? ? ?#各個節點IP,每個節點寫自己的ip
http.port: 9200? ? ? ? ? ? ? ? ? ? ? ?#端口
discovery.zen.ping.unicast.hosts: ["192.168.0.1", "192.168.0.2","192.168.0.3","192.168.0.4","192.168.0.5"]? ? ? ? ?#集群ip列表
discovery.zen.minimum_master_nodes: 3? ? #集群master節點數,建議為(集群節點總數/2)+1
3、配置好直接啟動即可,隨意先啟動哪一臺,先啟動即為master。9300是tcp通訊端口,集群間和TCPClient都走的它,所以各個主機間9300一定要能互通。
4、驗證集群? ??,es 9200是http協議的RESTful接口,可用此端口查看集群狀態
curl -XGET 'http://192.168.0.1:9200/_cat/nodes?pretty'?
其中
- _cat代表查看信息
- nodes為查看節點信息,默認會顯示為一行,所以就用刀了?preety讓信息更有好的顯示
- ?preety讓輸出信息更友好的顯示
結果如下表示集群已搭建成功:
?
5、es啟動腳本
vim?/etc/init.d/es
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
export JAVA_HOME=/usr/local/jdk1.8.0_92
export JAVA_BIN=/usr/local/jdk1.8.0_92/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case "$1" in
start)
su dev<<!
cd /data1/elk/elasticsearch
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su dev<<!
cd /data1/elk/elasticsearch
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
?
?
?
?
6、集群管理-cerebro
? 下載cerebro? ? ?
wget?https://github.com/lmenezes/cerebro/releases/download/v0.7.2/cerebro-0.7.2.zip解壓并配置application.conf?
?
?
啟動后,訪問http://127.0.0.1:9000 即可
?
因為cerebo目前沒有什么登錄驗證(最起碼寫這篇博客時,我還不知道,如果你們知道更方便的登錄驗證,請留言告訴我,謝謝~),用戶直接訪問域名即可,不是很安全,所以用nginx配置下登錄驗證。
1、在location /下添加auth_basic_user_file /usr/local/.passwd;
2、登陸http://tool.oschina.net/htpasswd 輸入用戶名和密碼,在線生成加密密碼
3、將生成的密碼寫入/usr/local/.passwd文件中
echo "wuyun:$apr1$TrU5vUSC$RBuz3xG67Mr2pnAV596N5." >/usr/local/.passwd
?
nginx配置如下:
?
?
此時重啟nginx,再登錄訪問域名時就需要輸入賬號密碼了。不輸入密碼會報401 Authorization Required錯誤
另如果logstash啟動多個配置需先建立單獨存在配置文件目錄, 然后啟動 nohup? ./logstash -f ../conf &
?
轉載于:https://www.cnblogs.com/abkn/p/9591198.html
總結
- 上一篇: mysql复制模式第四部分-----环形
- 下一篇: lnmp环境切换php版本,并安装相应r