Elastic Search學習筆記1——安裝elasticsearch2.4.6

Elastic Searchhtml

簡介

  1. 基於Apache Lucene的開源搜索引擎
  2. 採用Java編寫 RESTful API風格
  3. 較容易的橫向擴展

應用場景

  1. 海量數據分析引擎
  2. 數據搜索引擎
  3. 數據倉庫

下載

https://www.elastic.co/downloads/elasticsearchjava

https://www.elastic.co/downloads/past-releasesnode

https://github.com/elastic/elasticsearch/releasesgit

安裝

  1. Download and unzip Elasticsearch
    Elasticsearch can also be installed from our package repositories using apt or yum, or installed on Windows using an MSI installer package. See Repositories in the Guide.
  2. Run bin/elasticsearch (or bin\elasticsearch.bat on Windows)
  3. Run curl http://localhost:9200/ or Invoke-RestMethod http://localhost:9200 with PowerShell
  4. Dive into the getting started guide and video.

https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.htmlgithub

https://www.elastic.co/webinars/getting-started-elasticsearchweb

解壓bootstrap

配置瀏覽器

打開config/elasticsearch.yml安全

#集羣名稱  
cluster.name: app-name  
# 單節點名稱  master/slave1
node.name: master 
#設置綁定的ip地址  
network.host: 127.0.0.1  
#端口  
http.port: 9200  
# 找到master節點  
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

啓動
./bin/elasticsearchapp

後臺運行
./bin/elasticsearch -d

查看日誌
tail -f logs/elasticsearch.log

當看到提示
publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200} started
表示啓動成功


若啓動報錯

java.lang.RuntimeException: don't run elasticsearch as root.  
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:94)  
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:160)  
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286)  
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:45)

即不容許root啓動

2.X解決方案

./bin/elasticsearch -Des.insecure.allow.root=true

中止服務

第一種

ps -ef | grep elastic

root     25531     1  0 May24 ?        01:53:55 /usr/java/jdk1.7.0_79/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/local/src/elasticsearch-2.4.6 -cp /usr/local/src/elasticsearch-2.4.6/lib/elasticsearch-2.4.6.jar:/usr/local/src/elasticsearch-2.4.6/lib/* org.elasticsearch.bootstrap.Elasticsearch start -Des.insecure.allow.root=true -d

第二種

jps

25531 Elasticsearch

5.X+版本

注:ES有執行腳本的能力,因安全因素,不能在root用戶下運行,強行運行會報以下錯誤:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

groupadd es          #增長es組
useradd es -g es -p pwd          #增長es用戶並附加到es組
chown -R es:es elasticsearch-5.1.1          #給目錄權限
su es          #使用es用戶
./bin/elasticsearch -d          #後臺運行es
 

測試

打開瀏覽器輸入 127.0.0.1:9200

{  
    name: "GG9WPj_",  
    cluster_name: "elasticsearch",  
    cluster_uuid: "4ZrTtRADRaCtnb84OxAbFg",  
    version: {  
        number: "5.6.0",  
        build_hash: "781a835",  
        build_date: "2017-09-07T03:09:58.087Z",  
        build_snapshot: false,  
        lucene_version: "6.6.0"  
    },  
    tagline: "You Know, for Search"  
}
相關文章
相關標籤/搜索