Elasticsearch+hbase 實現hbase中資料的快速查詢(一)
之前雖做了solr-hbase構建二級索引以及快速查詢,但是考慮到以後生成的資料可能會很多,一旦到了億級以上,solr查詢效率會漸漸慢下來.老闆不滿意,又聽了幾位專家的建議,採用Elasticsearch+hbase 來實現hbase中資料的快速查詢.
首先,安裝Elasticsearch.
CDH中沒有整合Elasticsearch,所以只好獨立安裝.
1.下載elasticsearch-5.2.1.tar.gz
解壓
tar zxvf /usr/local/elasticsearch/elasticsearch-5.2.1.tar.gz
vi /usr/local/elasticsearch/elasticsearch-5.2.1/config/elasticsearch.yml
c2節點:
找到node.name,改成:es-node1
找到network.host,去掉#,改為centos真實的ip, 10.0.0.12
discovery.zen.ping.unicast.hosts: [“10.0.0.12”, “10.0.0.13”,”10.0.0.14”]
c3節點:
找到node.name,改成:es-node2
找到network.host,去掉#,改為centos真實的ip, 10.0.0.13
discovery.zen.ping.unicast.hosts: [“10.0.0.12”, “10.0.0.13”,”10.0.0.14”]
c4節點:
找到node.name,改成:es-node3
找到network.host,去掉#,改為centos真實的ip, 10.0.0.14
discovery.zen.ping.unicast.hosts: [“10.0.0.12”, “10.0.0.13”,”10.0.0.14”]
新建使用者組:
groupadd group_es
useradd -g group_es es_user
passwd es_user
給es_user 許可權區域設為es目錄:
chown -R es_user.group_es /usr/local/elasticsearch
啟動:
su es_user
cd /usr/local/elasticsearch/
nohup elasticsearch-5.2 .1/bin/elasticsearch & > nohup.out
停止:
ps -ef | grep elasticsearch
kill -9 pid
自帶命令啟動|停止方式:
su - es_user -c "/usr/local/elasticsearch/elasticsearch-5.2.1/bin/elasticsearch &"
由於這裡是在已有的環境中安裝ES,包括jdk版本等,會遇到一些錯誤.
錯誤解決:
Exception in thread “main” java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 52.0
原因:jdk版本問題太低
解決方案1:更換jdk版本,ElasticSearch5.0.0支援jdk1.8.0以上
解決方案2:
安裝jdk8,路徑:/usr/local/jdk1.8.0_144
每臺機器,在/etc/profile 中加入:
export ES_JAVA_HOME=/usr/local/jdk1.8.0_144
source /etc/profile
vi /usr/local/elasticsearch/elasticsearch-5.2.1/bin/elasticsearch
將上圖JAVA_HOME 替換為ES_JAVA_HOME
重啟es,就可以了.
如果依然報了 “Elasticsearch requires at least Java 8 but your Java version from XXXX does not meet this requirement”
上面的錯誤提示是在“elasticsearch.in.bat”這個檔案下的。在那個檔案下依然會有一個叫 %JAVA_HOME%的相關配置。把那個檔案的JAVA_HOME 替換成我們新建的 ES_JAVA_HOME。
然後儲存,啟動ES服務!
ERROR:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
原因:無法建立本地檔案問題,使用者最大可建立檔案數太小
解決方案:
切換到root使用者,編輯limits.conf配置檔案, 新增類似如下內容:
vi /etc/security/limits.conf
新增如下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
備註:* 代表Linux所有使用者名稱稱(比如 hadoop)
儲存、退出、重新登入才可生效
**ERROR:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]**
原因:最大虛擬記憶體太小
解決方案:切換到root使用者下,修改配置檔案sysctl.conf
vi /etc/sysctl.conf
新增下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
然後重新啟動elasticsearch,即可啟動成功。
ERROR修改配置中叢集名字後啟動失敗
yml的配置檔案中 冒號後邊要跟有 一個空格,不要出現tab符,如下:
cluster.name: test
此外,ES還有一些外掛安裝,用來監控ES狀態的.自ES5.x以後,外掛都要獨立安裝了,具體可以找下百度和google.
這裡有個bigdesk外掛注意一下:
git clone https://github.com/hlstudio/bigdesk.git
安裝:
cd /usr/local/elasticsearch/bigdesk/_site
python -m SimpleHTTPServer
後臺執行:
nohup python -m SimpleHTTPServer & > nohup.out