1. 程式人生 > 實用技巧 >elasticsearch安裝教程

elasticsearch安裝教程

執行環境如下

Centos 6.4

elasticsearch1.7.2

jdk-7u67-linux-x64.rpm


一、檢查當前作業系統的版本

[[email protected]~]#hostname//檢視當前的主機名稱
es
[[email protected]~]#uname-m//檢視系統是多少位
x86_64
[[email protected]~]#uname-r//檢視核心版本
2.6.32-358.el6.x86_64
[[email protected]~]#cat/etc/redhat-release//檢視Centos版本號
CentOSrelease6.4(Final)
[
[email protected]
~]#


二、安裝JDK環境(jdk-7u67-linux-x64.rpm)

[[email protected]src]#rpm-ivhjdk-7u67-linux-x64.rpm
Preparing...###########################################[100%]
1:jdk###########################################[100%]
UnpackingJARfiles...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...

配置環境變數vi /etc/profile 在這個檔案的最後新增上配置

#setjavaenvironment
JAVA_HOME=/usr/java/jdk1.7.0_67
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
exportJAVA_HOMECLASSPATHPATH

立刻讓環境變數配置檔案生效

[[email protected]~]#
[[email protected]~]#source/etc/profile//這兩種生效方法你用哪種都可以的
[[email protected]~]#
[[email protected]
~]#./etc/profile [[email protected]~]#

測試一下環境變數是否成功安裝

[[email protected]~]#java-version
javaversion"1.7.0_67"
Java(TM)SERuntimeEnvironment(build1.7.0_67-b01)
JavaHotSpot(TM)64-BitServerVM(build24.65-b04,mixedmode)

JDK安裝完畢......



三、安裝elasticsearch1.7.2 軟體

[[email protected]elasticsearch-1.7.2]#pwd
/usr/local/elasticsearch-1.7.2
[[email protected]elasticsearch-1.7.2]#ll
total40
drwxr-xr-x.2rootroot4096Mar1722:49bin
drwxr-xr-x.2rootroot4096Mar1722:49config
drwxr-xr-x.3rootroot4096Mar1722:49lib
-rw-rw-r--.1rootroot11358Sep142015LICENSE.txt
-rw-rw-r--.1rootroot150Sep142015NOTICE.txt
-rw-rw-r--.1rootroot8700Sep142015README.textile


啟動 elasticsearch

[[email protected]bin]#pwd
/usr/local/elasticsearch-1.7.2/bin
[[email protected]bin]#ll
total324
-rwxr-xr-x.1rootroot8114Sep142015elasticsearch
-rw-rw-r--.1rootroot901Sep142015elasticsearch.bat
-rw-rw-r--.1rootroot2797Sep142015elasticsearch.in.bat
-rwxr-xr-x.1rootroot2170Sep142015elasticsearch.in.sh
-rw-rw-r--.1rootroot104448Sep142015elasticsearch-service-mgr.exe
-rw-rw-r--.1rootroot103936Sep142015elasticsearch-service-x64.exe
-rw-rw-r--.1rootroot80896Sep142015elasticsearch-service-x86.exe
-rwxr-xr-x.1rootroot2523Sep142015plugin
-rw-rw-r--.1rootroot482Sep142015plugin.bat
-rw-rw-r--.1rootroot6210Sep142015service.bat
[[email protected]bin]#/bin/sh./elasticsearch//啟動了....



開始進入測試了....


克隆一個SecureCRT 會話選項來關閉防火牆設定

[[email protected]~]#/etc/init.d/iptablesstop
iptables:Flushingfirewallrules:[OK]
iptables:SettingchainstopolicyACCEPT:filter[OK]
iptables:Unloadingmodules:[OK]

關閉之後 在瀏覽器上面輸入地址:http://172.16.10.100:9200/



wKiom1bqVYbSOJJZAABtBuAbsz8153.png




成功安裝.....




四、我們要配置成開自啟動服務


到這裡把軟體下載:https://github.com/elastic/elasticsearch-servicewrapper


並上傳伺服器上面去

[[email protected]src]#pwd
/usr/local/src
[[email protected]src]#unzipelasticsearch-servicewrapper-master.zip//解壓軟體
[[email protected]src]#ll
total153708
-rw-r--r--.1rootroot28478292Dec2910:47elasticsearch-1.7.2.tar.gz
drwxr-xr-x.3rootroot4096Feb1403:02elasticsearch-servicewrapper-master
-rw-r--r--.1rootroot2054227Mar1714:10elasticsearch-servicewrapper-master.zip
-rw-r--r--.1rootroot126857158Dec2117:09jdk-7u67-linux-x64.rpm
[[email protected]src]#mvelasticsearch-servicewrapper-master/service//usr/local/elasticsearch-1.7.2/bin/
[[email protected]src]#
//將service目錄移動到elasticsearch下面的bin目錄下面去




[[email protected]service]#pwd
/usr/local/elasticsearch-1.7.2/bin/service
[[email protected]service]#./elasticsearch
Usage:./elasticsearch[console|start|stop....]

Commands:
consoleLaunchinthecurrentconsole.
startStartinthebackgroundasadaemonprocess.
stopStopifrunningasadaemonorinanotherconsole.
restartStopifrunningandthenstart.
condrestartRestartonlyifalreadyrunning.
statusQuerythecurrentstatus.
installInstalltostartautomaticallywhensystemboots.
removeUninstall.
dumpRequestaJavathreaddumpifrunning.




開始安裝服務

[[email protected]service]#./elasticsearchinstall//開始安裝
DetectedRHELorFedora:
InstallingtheElasticsearchdaemon..
[[email protected]service]#/etc/init.d/elasticsearchstatus//檢視執行狀態
Elasticsearchisnotrunning.
[[email protected]service]#chkconfig--listelasticsearch
elasticsearch0:off1:off2:on3:on4:on5:on6:off




========================

配置OK....恭喜你





轉載於:https://blog.51cto.com/771541213/1752099