Elasticsearch 入门:安装 curl 及加载案例数据

curl 是利用 URL 语法在命令行方式下工作的开源文件传输工具。

关于 curl 的介绍,参考官网:https://curl.haxx.se/


安装 curl

wget http://curl.haxx.se/download/curl-7.52.1.tar.gz
tar -zxf curl-7.52.1.tar.gz
cd curl-7.52.1
./configure -prefix=/usr/local/curl
make
make install
export PATH=$PATH:/usr/local/curl/bin
curl -V

curl 用法   https://curl.haxx.se/docs/manpage.html

# curl -X<REST Verb> <Node>:<Port>/<Index>/<Type>/<ID>
  <REST Verb>:REST风格的语法谓词
  <Node>:节点ip
  <port>:节点端口号,默认9200
  <Index>:索引名
  <Type>:索引类型
  <ID>:操作对象的ID号

对 Elasticsearch 操作(如查看 es 集群状态、节点、索引信息等)

curl '192.168.1.222:9200/_cat/health?v'
curl '192.168.1.222:9200/_cat/nodes?v'
curl '192.168.1.222:9200/_cat/indices?v'

导入案例数据 (官方下载地址:Loading Sample Data

(官网下载可能较慢,另参考下载  Kibana Sample Data


在加载  Shakespeare 和logs 数据集之前需要映射(创建索引逻辑组) 参考 Mapping 

curl -XPUT http://192.168.1.222:9200/shakespeare -d '
{
 "mappings" : {
  "_default_" : {
   "properties" : {
    "speaker" : {"type": "string", "index" : "not_analyzed" },
    "play_name" : {"type": "string", "index" : "not_analyzed" },
    "line_id" : { "type" : "integer" },
    "speech_number" : { "type" : "integer" }
   }
  }
 }
}
';

curl -XPUT http://192.168.1.222:9200/logstash-2015.05.18 -d '
{
  "mappings": {
    "log": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  }
}
';

curl -XPUT http://192.168.1.222:9200/logstash-2015.05.19 -d '
{
  "mappings": {
    "log": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  }
}
';

curl -XPUT http://192.168.1.222:9200/logstash-2015.05.20 -d '
{
  "mappings": {
    "log": {
      "properties": {
        "geo": {
          "properties": {
            "coordinates": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  }
}
';

完成后查看索引

> curl '192.168.1.222:9200/_cat/indices?v'

health status index               uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   bank                vMe9pY2IQ6GayEp6YlDVOA   5   1       1000            0    666.6kb        666.6kb
yellow open   logstash-2015.05.20 LAMCVpXXRLKxNJ10VJMsyA   5   1       4750            0     30.9mb         30.9mb
yellow open   shakespeare         PVDyOj2NT16d2_c5mfp66w   5   1     111396            0     29.6mb         29.6mb
yellow open   logstash-2015.05.18 hu-In77qSzelQgnGnnacgA   5   1       4631            0     31.5mb         31.5mb
yellow open   logstash-2015.05.19 Ee4WnAg_R1WuCz7XRF9DTg   5   1       4624            0     31.5mb         31.5mb

加载数据

curl -XPOST '192.168.1.222:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
curl -XPOST '192.168.1.222:9200/shakespeare/_bulk?pretty' --data-binary @shakespeare.json
curl -XPOST '192.168.1.222:9200/_bulk?pretty' --data-binary @logs.jsonl

浏览器访问: http://192.168.1.222:5601/  创建3个索引匹配模式

ba*
shakes*
logstash-2015.05*


Kibana 安装参考:Elasticsearch 5.0 安装 kibana 5.0


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值