elasticsearch2.3安装以及集群部署
一、下載
1.1安裝elasticsearch-2.3.3要求是安裝官方新版的Java,必須是JDK 1.7以上,1.7以下執行的時候會報以下錯誤。安裝環境變量后記得source /etc/profile
[liuxun elasticsearch-2.3.3]$ ./bin/elasticsearch Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0at java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)at java.lang.ClassLoader.defineClass(ClassLoader.java:615)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)at java.net.URLClassLoader.access$000(URLClassLoader.java:58)at java.net.URLClassLoader$1.run(URLClassLoader.java:197)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit.1.2下載最新版elasticsearch
[root@localhost server]# wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.3.3/elasticsearch-2.3.3.zip [root@localhost server]# unzip -o elasticsearch-2.3.3.zip [root@localhost server]# chmod -R 777 elasticsearch-2.3.3 [root@localhost server]# exit [liuxun@localhost server]$ cd elasticsearch-2.3.3 [liuxun@localhost server]$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) [liuxun@localhost elasticsearch-2.3.3]$ ./bin/elasticsearchelasticsearch不能用root賬戶啟動,要用別的賬戶。我用的就是當前用戶。所以切到當前用戶后記得查看JDK版本。用root安裝的JDK當切到用戶模式下需要執行source /etc/profile才生效。
如果想在后臺以守護進程模式運行,添加 -d 參數。
二、驗證
[liuxun server]$ curl 'http://localhost:9200/?pretty' {"name" : "Chaos","cluster_name" : "elasticsearch","version" : {"number" : "2.3.2","build_hash" : "b9e4a6acad4008027e4038f6abed7f7dba346f94","build_timestamp" : "2016-04-21T16:03:47Z","build_snapshot" : false,"lucene_version" : "5.5.0"},"tagline" : "You Know, for Search" }三、插件介紹及安裝
Head
Head是一個用來監控Elasticsearch狀態的客戶端插件。
[liuxun@localhost elasticsearch-2.3.3]$ ./bin/plugin install mobz/elasticsearch-head安裝后再瀏覽器中輸入:?http://localhost:9200/_plugin/head/? ?,會打開如下界面:
圖中顯示了一個節點Benedict Kine,每個節點擁有不同index的數據,Head提供了HTTP客戶端。
?
安裝 ?elasticsearch-kopf 插件
./bin/elasticsearch install lmenezes/elasticsearch-kopfhttp://192.168.38.131:9200/_plugin/head/
集群配置
1、修改文件名稱,然后復制一份節點。
[root@localhost elasticsearch]# mv elasticsearch-2.3.3 elasticsearch-2.3.3_n1 [root@localhost elasticsearch]# cp -ri elasticsearch-2.3.3_n1/ elasticsearch-2.3.3_n22、修改配置文件
這是主節點,改成一下內容
[root@localhost elasticsearch]# vi elasticsearch-2.3.3_n1/config/elasticsearch.yml # ======================== Elasticsearch Configuration ========================= # 也是指定了集群名稱 cluster.name: es-cluster #指定了節點名稱 node.name: node-1 #指定了該節點可能成為 master 節點,還可以是數據節點 node.master: true node.data: true #指定節點IP地址 network.host: 192.168.38.131 #指定http端口,你使用head、kopf等相關插件使用的端口 http.port: 9200 #為節點之間的通信設置一個自定義端口(默認為9300) ? ? transport.tcp.port: 9300然后修改節點配置文件,改成一下內容
[root@localhost elasticsearch]# vi elasticsearch-2.3.3_n2/config/elasticsearch.yml # ======================== Elasticsearch Configuration ========================= #也是指定了集群名稱 cluster.name: es-cluster #指定了節點名稱 node.name: node-2 #指定了該節點可能成為 master 節點,還可以是數據節點 node.master: true node.data: true #指定節點IP地址 network.host: 192.168.38.131 #,指定http端口,你使用head、kopf等相關插件使用的端口 http.port: 9201 # 為節點之間的通信設置一個自定義端口(默認為9300) ? ? transport.tcp.port: 9301 #告訴該的節點,可能的master節點是什么。 discovery.zen.ping.unicast.hosts: ["192.168.38.131:9300"]然后分別啟動,記得用退出root,用戶模式啟動。
kopf
head
IK集成參考文檔
https://github.com/medcl/elasticsearch-analysis-ik
from:?https://my.oschina.net/liuxundemo/blog/688736
總結
以上是生活随笔為你收集整理的elasticsearch2.3安装以及集群部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: exVim安装
- 下一篇: jdk动态代理实现原理