从头开始学ElasticSearch

来源:互联网 发布:王思仪铁观音淘宝店 编辑:程序博客网 时间:2024/05/29 14:17
修改配置 /etc/elasticsearch/elasticsearch.yml
进行集群配置:
################################### Cluster ################################### # 代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产生的,主从节点是对于集群内部来说的. # ES的一个概念就是去中心化,字面上理解就是无中心节点,这是对于集群外部来说的,因为从外部来看ES集群,在逻辑上是个整体,你与任何一个节点的通信和与整个ES集群通信是等价的。
# cluster.name可以确定你的集群名称,当你的elastic search集群在同一个网段中elastic search会自动的找到具有相同cluster.name的elastic search服务. 
# 所以当同一个网段具有多个elastic search集群时cluster.name就成为同一个集群的标识. 
#cluster.name: elastic search - See more at: http://bigbo.github.io/pages/2015/04/10/elasticsearch_config/#sthash.2E8RxUKK.dpuf
# 节点名称同理,可自动生成也可手动配置. #node.name: "Franz Kafka" # 允许一个节点是否可以成为一个master节点,es是默认集群中的第一台机器为master,如果这台机器停止就会重新选举master. #node.master: true # 允许该节点存储数据(默认开启) #node.data: true 
# 配置文件中给出了三种配置高性能集群拓扑结构的模式,如下: 
# 1. 如果你想让节点从不选举为主节点,只用来存储数据,可作为负载器 # node.master: false # node.data: true #
# 2. 如果想让节点成为主节点,且不存储任何数据,并保有空闲资源,可作为协调器 # node.master: true # node.data: false # 
# 3. 如果想让节点既不称为主节点,又不成为数据节点,那么可将他作为搜索器,从节点中获取数据,生成搜索结果等 # node.master: false # node.data: false - See more at: http://bigbo.github.io/pages/2015/04/10/elasticsearch_config/#sthash.2E8RxUKK.dpuf


系统设置
由于ES不可使用root用户启动,所以要进行一些系统配置
创建新的linux用户:adduser es_user
更改文件夹属性: chmod -R 744 /path/{$ES_HOME}


常用命令:
1.查询健康状态“
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
节点状态
curl -XGET 'http://localhost:9200/_nodes/stats?pretty'
2.查询搜索内容
curl 'http://localhost:9200/tom-2015-12-16/_search?q=1234?pretty'
curl 'localhost:9200/tom-2015-12-16/_search?q=*&pretty'
3.查询es所有内容
curl 'http://localhost:9200/_search?pretty'
4.查询所有的index
curl localhost:9200/_cat/indices?v
5.删除index
curl -XDELETE 'http://localhost:9200/index_name’(把index_name改为你想要删除的index)
6.查询所有分片(shards)的状态
curl localhost:9200/_cat/shards
原创粉丝点击