Elasticsearch之curl建立索引庫

來源:互聯網
上載者:User

標籤:本地   ack   127.0.0.1   地址   建議   ip地址   後台   post   status   

 

  關於curl的介紹,請移步

Elasticsearch學習概念之curl

 

  啟動es,請移步

Elasticsearch的前後台運行與停止(tar包方式)Elasticsearch的前後台運行與停止(rpm包方式)

  

 

 

  建立索引庫,我這裡命名為zhouls

[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://192.168.80.200:9200/zhouls‘
{"acknowledged":true}[[email protected] elasticsearch-2.4.3]$

這裡,是跟之前的elasticsearch.yml修改對應起來的。

 

 

 

   我們可以驗證下,輸入localhost或者127.0.0.1都會出現無法串連,不信你嘗試。

 

[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://192.168.80.200:9200/zhouls‘
{"acknowledged":true}[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://localhost:9200/zhouls‘
curl: (7) couldn‘t connect to host
[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://127.0.0.1:9200/zhouls‘
curl: (7) couldn‘t connect to host
[[email protected] elasticsearch-2.4.3]$

 

 

 

 

 

為了方便,更改為0.0.0.0

 

 

 

 

 

 

   然後,重啟es

[[email protected] elasticsearch-2.4.3]$ jps
2811 Jps
2741 Elasticsearch
[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://localhost:9200/zhouls‘
{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"}],"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"},"status":400}[[email protected] elasticurl -XPUT ‘http://127.0.0.1:9200/zhouls‘
{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"}],"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"},"status":400}[[email protected] elasticurl -XPUT ‘http://192.168.80.200:9200/zhouls‘
{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"}],"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"},"status":400}[[email protected] elasticsearch-2.4.3]$

 

 

 

 

 

     報這個錯誤,是正常的,因為,你重複建立索引庫。根據經驗之談,一般用內網ip。如我的192.168.80.200。建議指定內網ip

伺服器一般都會有多種ip地址,
本地迴環地址:127.0.0.1
內網地址:192.168.80.200
外網地址:10.29.0.2
    在這裡0.0.0.0 表示可以通過上面所有ip都可以訪問 

 

 

 

 

  以上是,Elasticsearch之curl建立索引庫的方式1,以下是,Elasticsearch之curl建立索引庫的方式2

[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://192.168.80.200:9200/zhouls‘
{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"}],"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"},"status":400}[[email protected] elasticsearch-2.4.3]$ curl -XPOST ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[[email protected] elasticsearch-2.4.3]$

 

 

 

   測試完,及時刪除。

[[email protected] elasticsearch-2.4.3]$ curl -XPUT ‘http://192.168.80.200:9200/zhouls‘
{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"}],"type":"index_already_exists_exception","reason":"already exists","index":"zhouls"},"status":400}[[email protected] elasticsearch-2.4.3]$ curl -XPOST ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[[email protected] elasticsearch-2.4.3]$ curl -XDELETE ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[[email protected] elasticsearch-2.4.3]$

Elasticsearch之curl建立索引庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.