Centos 6.7安裝Elasticsearch2.3.3

來源:互聯網
上載者:User

Centos 6.7安裝Elasticsearch2.3.3

閑來無事,就來學習下被稱為新全文的Elasticsearch。新手第一次裝新全文,問題還是挺多的。

1.關於Elasticsearch

Elasticsearch是一個基於Lucene的搜尋工具,它使用Java開發並且使用Lucene作為核心來實現索引和搜尋的功能。但是它的目的是通過簡單的Restful API來隱藏Lucene的複雜性,從而讓全文檢索搜尋變得簡單。

但是,Elasticsearch不僅僅是Lucene和全文檢索搜尋,我們還能這樣去描述它:
1)分布式的即時檔案儲存體,每個欄位都被索引並可被搜尋
2)分布式的即時分析搜尋引擎
3)可以擴充到上百台伺服器,處理PB級結構化或非結構化資料
而且,所有的這些功能被整合到一個服務裡面,你的應用可以通過簡單的RestfulAPI、各種語言的用戶端甚至命令列與之互動。

2. 下載最新版的Elasticsearch的安裝包,該版本可直接部署到Linux系統上

安裝之前,請確認已安裝好最新版的JDK版本,安裝步驟請參照其他網友文章。最好把安裝的工具包放在/opt目錄,本人安裝在centos 6.7下的/home目錄下使用,wget命令得到該zip安裝包。

[plain]view plaincopy
  1. Elasticsearch2.3.3
  2. ZIPhttps://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.3.3/elasticsearch-2.3.3.zip</span>
  3. Woohoo!Yourdownloadisalmostcomplete!It'sclearyou'reabouttodogreatthingswithdata.Whetherthisisyourfirst,tenth,orumpteenthdownloadofanopensourceElasticproject,there'salwayssomethingnewtolearn.
  4. So,beforeyoudiveintothedocumentation,haveaganderatthegoodnessbelow.Trysomethingnew,expandtoanewusecase,thinkupsomethingtotallynovel,and,aboveall,staycurious.

3. 正式安裝Elasticsearch

在root使用者,/home目錄下解壓zip包,建立軟串連In -s Elasticsearch2.3.3 elasticsearch,cd /elasticsearch後,執行 ./bin/elasticsearch,會出現如下的錯誤:

[plain]view plaincopy
  1. [root@xxxxbin]#./elasticsearch
  2. Exceptioninthread"main"java.lang.RuntimeException:don'trunelasticsearchasroot.</span>
  3. atorg.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
  4. atorg.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
  5. atorg.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
  6. atorg.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  7. Refertothelogforcompleteerrordetails.

這是Elasticsearch出於系統安全考慮設定的條件。由於Elasticsearch可以接收使用者輸入的指令碼並且執行,為了系統安全考慮,因此可以建立一個單獨的使用者用來運行Elasticsearch。

1) 建立單獨的使用者組和elsearch使用者:

[plain]view plaincopy
  1. groupaddelsearch
  2. useraddelsearch-gelsearch-pelasticsearch

2) 更改/home/elasticsearch使用者及組:

[plain]view plaincopy
  1. <spanstyle="white-space:pre"></span></span>cd/home
  2. <spanstyle="white-space:pre"></span></span>chown-Relsearch:elsearchelasticsearch

3) 使用elsearch使用者執行安裝命令

[plain]view plaincopy
  1. <spanstyle="white-space:pre"></span></span>suelsearch
  2. <spanstyle="white-space:pre"></span></span>cdelasticsearch/bin執行./elasticsearch
4. 關於安裝plugins(外掛程式管理)

[plain]view plaincopy
  1. Exceptioninthread"main"java.lang.IllegalStateException:Unabletoaccess'path.plugins'(/home/hye/elasticsearch/plugins)
  2. Likelyrootcause:java.nio.file.AccessDeniedException:/home/hye/elasticsearch/plugins
  3. atsun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
  4. atsun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
  5. atsun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
  6. atsun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
  7. atjava.nio.file.Files.createDirectory(Files.java:674)
  8. atjava.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
  9. atjava.nio.file.Files.createDirectories(Files.java:767)
  10. atorg.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:337)
  11. atorg.elasticsearch.bootstrap.Security.addPath(Security.java:314)
  12. atorg.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:246)
  13. atorg.elasticsearch.bootstrap.Security.createPermissions(Security.java:212)
  14. atorg.elasticsearch.bootstrap.Security.configure(Security.java:118)
  15. atorg.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:196)
  16. atorg.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167)
  17. atorg.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
  18. atorg.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  19. Refertothelogforcompleteerrordetails.

請按照官網的plguins Managerment的介紹和安裝方法進行安裝:

4.1安裝前的準備

[plain]view plaincopy
  1. Runningasroot
  2. IfElasticsearchwasinstalledusingthedeborrpmpackagethenrunbin/pluginasrootsoitcanwritetotheappropriatefilesondisk.Otherwiserunbin/pluginastheuserthatownsalloftheElasticsearchfiles.

4.2 正式安裝plugins外掛程式

本人安裝的是Core Elasticsearch plugins,按照圖中的安裝步驟,完成安裝。

[plain]view plaincopy
  1. PluginManagement
  2. CoreElasticsearchpluginsedit
  3. CoreElasticsearchpluginscanbeinstalledasfollows:
  4. sudobin/plugininstall[plugin_name]
  5. Forinstance,toinstallthecoreICUplugin,justrunthefollowingcommand:
  6. sudobin/plugininstallanalysis-icu
  7. ThiscommandwillinstalltheversionofthepluginthatmatchesyourElasticsearchversion.
  8. Communityandnon-corepluginsedit
  9. Non-corepluginsprovidedbyElasticsearch,orpluginsprovidedbythecommunity,canbeinstalledfromdownload.elastic.co,fromMaven(CentralandSonatype),orfromGitHub.Inthiscase,thecommandisasfollows:
  10. sudobin/plugininstall[org]/[user|component]/[version]</span><spanstyle="font-size:14px;">

5. 啟動Elasticsearch

使用非root使用者進行安裝:

[plain]view plaincopy
  1. <spanstyle="white-space:pre"></span>suelsearch
  2. <spanstyle="white-space:pre"></span>cdelasticsearch/bin
  3. <spanstyle="white-space:pre"></span>./elasticsearch

[plain]view plaincopy
  1. 如果想要Elasticsearch在後端運行:
  2. <spanstyle="white-space:pre"></span>./elasticsearch-d

控制台顯示:(啟動Elasticsearch成功)

[plain]view plaincopy
  1. [elsearch@xhyu-100elasticsearch]$./bin/elasticsearch
  2. [2016-06-1900:27:24,188][WARN][bootstrap]unabletoinstallsyscallfilter:seccompunavailable:CONFIG_SECCOMPnotcompiledintokernel,CONFIG_SECCOMPandCONFIG_SECCOMP_FILTERareneeded
  3. [2016-06-1900:27:24,417][INFO][node][Mad-Dog]version[2.3.3],pid[4260],build[218bdf1/2016-05-17T15:40:04Z]
  4. [2016-06-1900:27:24,417][INFO][node][Mad-Dog]initializing...
  5. [2016-06-1900:27:25,040][INFO][plugins][Mad-Dog]modules[reindex,lang-expression,lang-groovy],plugins[analysis-icu],sites[]
  6. [2016-06-1900:27:25,066][INFO][env][Mad-Dog]using[1]datapaths,mounts[[/(/dev/sda3)]],netusable_space[33.4gb],nettotal_space[45.6gb],spins?[possibly],types[ext4]
  7. [2016-06-1900:27:25,066][INFO][env][Mad-Dog]heapsize[1015.6mb],compressedordinaryobjectpointers[true]
  8. [2016-06-1900:27:25,066][WARN][env][Mad-Dog]maxfiledescriptors[4096]forelasticsearchprocesslikelytoolow,considerincreasingtoatleast[65536]
  9. [2016-06-1900:27:27,264][INFO][node][Mad-Dog]initialized
  10. [2016-06-1900:27:27,264][INFO][node][Mad-Dog]starting...
  11. [2016-06-1900:27:27,330][INFO][transport][Mad-Dog]publish_address{192.168.31.200:9300},bound_addresses{192.168.31.200:9300}
  12. [2016-06-1900:27:27,333][INFO][discovery][Mad-Dog]elasticsearch/-H0Z_q6iRsuYDXd1b1jCAg
  13. [2016-06-1900:27:30,390][INFO][cluster.service][Mad-Dog]new_master{Mad-Dog}{-H0Z_q6iRsuYDXd1b1jCAg}{192.168.31.200}{192.168.31.200:9300},reason:zen-disco-join(elected_as_master,[0]joinsreceived)
  14. [2016-06-1900:27:30,420][INFO][http][Mad-Dog]publish_address{192.168.31.200:9200},bound_addresses{192.168.31.200:9200}
  15. [2016-06-1900:27:30,420][INFO][node][Mad-Dog]started
  16. [2016-06-1900:27:30,441][INFO][gateway][Mad-Dog]recovered[0]indicesintocluster_state

6. Elasticsearch介面驗證失敗,修改Elasticsearch設定檔

未修改設定檔前,使用非root使用者進行elasticsearch安裝。

[plain]view plaincopy
  1. [root@xxxxelasticsearch]#curl-XGEThttp://機器ip:9200/
  2. curl:(7)couldn'tconnecttohost

按照網上的文章和官網安裝說明,並沒有修改預設設定檔的說法。

[plain]view plaincopy
  1. /home/hye/elasticsearch/config

修改完後,開啟驗證介面,最好找個好點瀏覽器,QQ瀏覽器就別用了。可以用Chrome瀏覽器。

在介面輸入:http://安裝機器ip:9200/,頁面回饋資訊如下:

[plain]view plaincopy
  1. {
  2. "name":"Mad-Dog",
  3. "cluster_name":"elasticsearch",
  4. "version":{
  5. "number":"2.3.3",
  6. "build_hash":"218bdf10790eef486ff2c41a3df5cfa32dadcfde",
  7. "build_timestamp":"2016-05-17T15:40:04Z",
  8. "build_snapshot":false,
  9. "lucene_version":"5.5.0"
  10. },
  11. "tagline":"YouKnow,forSearch"
  12. }

至此,安裝結束。。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.