码迷,mamicode.com
首页 > Web开发 > 详细

Elasticsearch之curl创建索引库

时间:2017-02-20 18:17:37      阅读:823      评论:0      收藏:0      [点我收藏+]

标签:本地   ack   127.0.0.1   地址   建议   ip地址   后台   post   status   

 

  关于curl的介绍,请移步

Elasticsearch学习概念之curl

 

  启动es,请移步

Elasticsearch的前后台运行与停止(tar包方式)

Elasticsearch的前后台运行与停止(rpm包方式)

  

 

 

  创建索引库,我这里命名为zhouls

技术分享

技术分享

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

这里,是跟之前的elasticsearch.yml修改对应起来的。

技术分享

 

 

 

   我们可以验证下,输入localhost或者127.0.0.1都会出现无法连接,不信你尝试。

 技术分享

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

 

 

 

 

 

为了方便,更改为0.0.0.0

技术分享

 

 

 

 

 

 

   然后,重启es

技术分享

[hadoop@djt002 elasticsearch-2.4.3]$ jps
2811 Jps
2741 Elasticsearch
[hadoop@djt002 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}[hadoop@djt002 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}[hadoop@djt002 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}[hadoop@djt002 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

技术分享

[hadoop@djt002 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}[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[hadoop@djt002 elasticsearch-2.4.3]$

 

 

 

   测试完,及时删除。

技术分享

[hadoop@djt002 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}[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[hadoop@djt002 elasticsearch-2.4.3]$ curl -XDELETE ‘http://192.168.80.200:9200/zhouls1‘
{"acknowledged":true}[hadoop@djt002 elasticsearch-2.4.3]$

Elasticsearch之curl创建索引库

标签:本地   ack   127.0.0.1   地址   建议   ip地址   后台   post   status   

原文地址:http://www.cnblogs.com/zlslch/p/6420572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!