Elasticsearch日誌分析系統html
做者:尹正傑前端
版權聲明:原創做品,謝絕轉載!不然將追究法律責任。html5
1 Node(節點): 2 單個的裝有Elasticsearch服務而且提供故障轉移和擴展的服務器。 3 Cluster(集羣): 4 一個集羣就是由一個或多個node組織在一塊兒,共同工做,共同分享整個數據具備負載均衡功能的集羣。 5 Document(文檔): 6 一個文檔是能夠被索引的基礎信息單元。 7 Index(索引): 8 索引就是一個擁有幾分類似特徵的文檔的集合。 9 Type(類型): 10 一個索引中,你能夠定義一種或多種類型。 11 Field(列): 12 Field是Elasticsearchd的最小單位,至關於數據的某一列。 13 Shards(分片): 14 Elasticsearch將索引分紅若干份,每一個部門就是一個shard。 15 Replicas(複製): 16 Replicas是索引一份或多份拷貝。
三.Elasticsearch對應數據庫的關係java
1 [root@yinzhengjie ~]# cat /etc/redhat-release 2 CentOS release 6.6 (Final) 3 [root@yinzhengjie ~]# 4 [root@yinzhengjie ~]# uname -r 5 2.6.32-504.el6.x86_64 6 [root@yinzhengjie ~]# 7 [root@yinzhengjie ~]# uname -m 8 x86_64 9 [root@yinzhengjie ~]#
b>.卸載舊版本的JAVAnode
1 [root@yinzhengjie jdk]# java -version ----->檢查當前版本 2 java version "1.7.0_65" ------>當前版本是1.7 3 OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17) 4 OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode) 5 [root@yinzhengjie jdk]# 6 [root@yinzhengjie jdk]# yum -y groupremove java* ------>卸載相關Java組件 7 [root@yinzhengjie jdk]# java -version ------>再次查看當前Java版本 8 java version "1.5.0" ------->當前版本是1.5 9 gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-18) 10 11 Copyright (C) 2007 Free Software Foundation, Inc. 12 This is free software; see the source for copying conditions. There is NO 13 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 [root@yinzhengjie jdk]# 15 [root@yinzhengjie jdk]# yum -y remove java* 16 [root@yinzhengjie jdk]# java -version ------->再次查看Java版本應該報錯說明卸載成功。 17 -bash: /usr/bin/java: 沒有那個文件或目錄 18 [root@yinzhengjie jdk]#
c>.安裝Javapython
1 [root@yinzhengjie ~]# mkdir -pv /yinzhengjie/application/jdk && cd /yinzhengjie/application/jdk 2 [root@yinzhengjie jdk]# yum -y install lrzsz 3 [root@yinzhengjie jdk]# rz ------>上傳咱們已經下載的文件 4 rz waiting to receive. 5 zmodem trl+C ȡ 6 7 100% 185289 KB 960 KB/s 00:03:13 0 Errorsr.gz... 8 9 [root@yinzhengjie jdk]# ll 10 總用量 185300 11 -rw-r--r--+ 1 root root 189736377 10月 29 21:45 jdk-8u151-linux-x64.tar.gz 12 [root@yinzhengjie jdk]# 13 [root@yinzhengjie jdk]# tar xf jdk-8u151-linux-x64.tar.gz 14 [root@yinzhengjie jdk1.8.0_151]# tail -6 /etc/profile 15 #ADD BY YINZHENGJIE 16 export JAVA_HOME=/yinzhengjie/application/jdk/jdk1.8.0_151 17 export JAVA_BIN=/yinzhengjie/application/jdk/jdk1.8.0_151/bin 18 export PATH=$PATH:$JAVA_HOME/bin 19 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 20 export JAVA_HOME JAVA_BIN PATH CLASSPATH 21 [root@yinzhengjie jdk1.8.0_151]# 22 [root@yinzhengjie jdk1.8.0_151]# source /etc/profile ------->從新讀取該配置文件 23 [root@yinzhengjie jdk1.8.0_151]# java -version -------->再一次的檢查當前JAVA版本 24 java version "1.8.0_151" ------->當前版本爲1.8版本,表示安裝成功。 25 Java(TM) SE Runtime Environment (build 1.8.0_151-b12) 26 Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode) 27 [root@yinzhengjie jdk1.8.0_151]#
b>.源碼安裝並運行Elasticsearchlinux
1 [root@yinzhengjie ~]# mkdir -pv /yinzhengjie/application/elasticsearch && cd /yinzhengjie/application/elasticsearch 2 [root@yinzhengjie elasticsearch]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz 3 [root@yinzhengjie elasticsearch]# rz 4 rz waiting to receive. 5 zmodem trl+C ȡ 6 7 100% 32982 KB 1221 KB/s 00:00:27 0 Errorsr.gz... 8 9 [root@yinzhengjie elasticsearch]# tar xf elasticsearch-5.6.3.tar.gz 10 [root@yinzhengjie elasticsearch]# useradd yinzhengjie 11 [root@yinzhengjie elasticsearch]# chown yinzhengjie:yinzhengjie elasticsearch-5.6.3 -R 12 [root@yinzhengjie elasticsearch]# cd elasticsearch-5.6.3/bin/ 13 [root@yinzhengjie bin]# su yinzhengjie 14 [yinzhengjie@yinzhengjie bin]$ ./elasticsearch -d ------>用非root用戶在後臺運行 15 [root@yinzhengjie ~]# lsof -i:9200 ------>查看服務是否正常啓動 16 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 17 java 5543 yinzhengjie 137u IPv6 35018 0t0 TCP localhost:wap-wsp (LISTEN) 18 java 5543 yinzhengjie 138u IPv6 35019 0t0 TCP localhost:wap-wsp (LISTEN) 19 [root@yinzhengjie ~]# 20 [yinzhengjie@yinzhengjie bin]$ exit 21 exit 22 [root@yinzhengjie bin]# 23 [root@yinzhengjie bin]# 24 [root@yinzhengjie bin]# ps -ef | grep elasticsearch | grep -v grep 25 501 5786 1 4 21:29 pts/0 00:00:17 /yinzhengjie/application/jdk/jdk1.8.0_151/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/yinzhengjie/application/elasticsearch/elasticsearch-5.6.3 -cp /yinzhengjie/application/elasticsearch/elasticsearch-5.6.3/lib/* org.elasticsearch.bootstrap.Elasticsearch -d 26 [root@yinzhengjie bin]# 27 [root@yinzhengjie bin]# curl 127.0.0.1:9200 ------->用curl命令驗證安裝的es是否可用。 28 { 29 "name" : "uJy1--c", 30 "cluster_name" : "elasticsearch", 31 "cluster_uuid" : "mQ8mfu3bQQGdo-jSECJQhQ", 32 "version" : { 33 "number" : "5.6.3", 34 "build_hash" : "1a2f265", 35 "build_date" : "2017-10-06T20:33:39.012Z", 36 "build_snapshot" : false, 37 "lucene_version" : "6.6.1" 38 }, 39 "tagline" : "You Know, for Search" 40 } 41 [root@yinzhengjie bin]#
d>.rpm安裝並運行Elasticsearchgit
1 [root@yinzhengjie ~]# mkdir -pv /yinzhengjie/application/elasticsearch && cd /yinzhengjie/application/elasticsearch 2 [root@yinzhengjie elasticsearch]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.rpm 3 [root@yinzhengjie elasticsearch]# rpm --install elasticsearch-5.6.3.rpm 4 [root@yinzhengjie elasticsearch]# 5 [root@yinzhengjie elasticsearch]# ln -s `which java` /sbin/java ----->須要手動作一個軟鏈接 6 [root@yinzhengjie elasticsearch]# service elasticsearch start ----->作好鏈接以後可用啓動服務 7 [root@yinzhengjie elasticsearch]# 8 [root@yinzhengjie elasticsearch]# lsof -i:9200 ------->檢查服務是否正常啓動 9 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 10 java 3074 elasticsearch 135u IPv6 29720 0t0 TCP localhost:wap-wsp (LISTEN) 11 java 3074 elasticsearch 137u IPv6 29722 0t0 TCP localhost:wap-wsp (LISTEN) 12 [root@yinzhengjie elasticsearch]# 13 [root@yinzhengjie elasticsearch]# curl 127.0.0.1:9200 ------->驗證是否按照成功 14 { 15 "name" : "BAzujhz", 16 "cluster_name" : "elasticsearch", 17 "cluster_uuid" : "7jz3RzqdTiS--VoQADAE5g", 18 "version" : { 19 "number" : "5.6.3", 20 "build_hash" : "1a2f265", 21 "build_date" : "2017-10-06T20:33:39.012Z", 22 "build_snapshot" : false, 23 "lucene_version" : "6.6.1" 24 }, 25 "tagline" : "You Know, for Search" 26 } 27 [root@yinzhengjie elasticsearch]#
1 [root@yinzhengjie elasticsearch-5.6.3]# ll 2 total 244 3 drwxr-xr-x. 2 yinzhengjie yinzhengjie 4096 Oct 30 05:11 bin -------->運行elasticsearch實例和管理插件的一些腳本; 4 drwxr-xr-x. 3 yinzhengjie yinzhengjie 4096 Oct 30 05:07 config --------->配置文件路徑,包含elasticsearch.yml文件,注意RPM安裝的存放位置應該是/etc/elasticsearch這個目錄; 5 drwxrwxr-x. 3 yinzhengjie yinzhengjie 4096 Oct 30 05:07 data --------->在每一個索引/碎片的數據文件的位置,能夠有多個目錄; 6 drwxr-xr-x. 2 yinzhengjie yinzhengjie 4096 Oct 6 13:35 lib ---------->elasticsearch使用的庫; 7 -rw-r--r--. 1 yinzhengjie yinzhengjie 11358 Oct 6 13:32 LICENSE.txt 8 drwxr-xr-x. 2 yinzhengjie yinzhengjie 4096 Oct 30 05:06 logs ---------->存放日誌的文件夾,注意若是是RPM方式安裝的話應該在/var/log/elasticsearch這個目錄裏面,官網文檔是有說明的。 9 drwxr-xr-x. 13 yinzhengjie yinzhengjie 4096 Oct 6 13:35 modules 10 -rw-r--r--. 1 yinzhengjie yinzhengjie 194187 Oct 6 13:34 NOTICE.txt 11 drwxr-xr-x. 2 yinzhengjie yinzhengjie 4096 Oct 6 13:35 plugins --------->存放已經安裝的插件的存放位置 12 -rw-r--r--. 1 yinzhengjie yinzhengjie 9549 Oct 6 13:32 README.textile 13 [root@yinzhengjie elasticsearch-5.6.3]#