標籤:本地 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建立索引庫