下往上看
1.Gateway代表ES数据持久化概念,ES建立索引默认存储在内存,ES只有当内存不足或关闭重新启动的情况下才持久化到磁盘里面,支持多种Gateway。
2.lucene Directory它是lucene 索引文件组成的一些目录,负责管理一些索引文件和数据的读取写入(添加 删除 合并等等)
3.River 代表一个数据源,以插件的形式读取数据方式。
4.Mapping 映射 (申明类型)
5.Search Module 和 Index Module 搜索模块和索引模块
6.Discovery负责集群节点自动发现和msater节点选举(不会存在单点故障出现)广播的方式进行通信
7.Scripting 脚本语言,支持多种自定义查询语言
8.Transport传输协议默认使用TCP协议进行交互同时支持HTTP协议Thrift和memcached
9.上层有各种API对EC进行操作
es安装:
用es用户安装
JDK安装:
#安装java环境
vim /etc/profile
export JAVA_HOME=/usr/local/jdk11
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
EC安装:
1.下载
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.0-linux-x86_64.tar.gz
2.解压
tar -xvf elasticsearch-7.9.0-linux-x86_64.tar.gz
3.配置:
3.安装
cd elasticsearch-7.9.0/bin ./elasticsearch -d
4.报错问题处理
问题1:ERROR: [1]max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决办法: root用户
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/sysctl.conf
echo "vm.max_map_count=262144" >> /etc/sysctl.conf # sysctl -p #使修改立即生效
问题2:ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
解决办法: node.name: node-1
cluster.initial_master_nodes: ["node-1"]
yum install nodejs npm git -y
git clone git://github.com/mobz/elasticsearch-head.git
curl -XPUT 'http://master:9200/test/'
curl -H "Content-Type: application/json" -XPOST http://master:9200/test/user/1 -d'{"name":"jack","age":28}'
curl -H "Content-Type: application/json" -XPUT http://master:9200/test/user/1 -d'{"name":"js","age":29}'
curl -XGET http://master:9200/test/user/1
curl -XGET 'http://master:9200/test/user/1?_source=name&pretty'
查询所有
curl -XGET http://master:9200/test/user/_search?pretty
条件查找
curl -XGET 'http://master:9200/test/user/_search?q=name:jack&pretty=true'
curl -H "Content-Type: application/json" -XPUT http://master:9200/test/user/4/_create -d'{"name":"pipi","age":17}'
curl -H "Content-Type: application/json" -XGET http://master:9200/test/user/_search -d'{"query":{"match":{"name":"pipi"}}}'
curl -H "Content-Type: application/json" -XPOST http://master:9200/test2/user/1/_create -d'{"name":"nick","age":16}'
curl -H "Content-Type: application/json" -XGET http://master:9200/test/user/_mget?pretty -d'{"docs":[{"_id":1},{"_id":2}]}'
curl -H "Content-Type: application/json" -XGET http://master:9200/test/user/_mget?pretty -d'{"ids":["1","2"]}'