index 索引 (数据库)
type 类型 (表)
document 文档 (field)
基于RESTfulweb 接口
GET 获取资源
POST 新建资源和更新资源
PUT 更新资源
DELETE 用来删除资源
linux安装jdk
1 下载所需版本:https://www.oracle.com/technetwork/java/javase/downloads/index.html
2 上传解压到 /usr/local/
3 在 /etc/profile 文件配置JAVA_HOME 路径
export JAVA_HOME="/usr/local/jdk1.8.0_191"
export PATH="PATH"
export CLASSPATH=".:$JAVA_HOME/lib"
4 使配置生效:source /etc/profile
5 查询jdk是否安装成功:java -version
linux安装ElasticSearch
1 下载ElasticSearch 最新版本
https://www.elastic.co/downloads/elasticsearch
2 上传解压到 /usr/local/
3 出于安全考虑专门新建一个用户和用户组来启动elasticsearch
groupadd eszu
useradd esuser -g eszu -p 123456
4 su esuser
5 启动elasticsearch
cd /usr/local/elasticsearch/bin
./elasticsearch
6 测试elasticsearch是否启动成功
curl 127.0.0.1:9200
出现以下显示表示启动成功了
{
"name" : "6zb2SdL",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "TiKvHR4KQUeMdb2feqlHtw",
"version" : {
"number" : "6.5.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "816e6f6",
"build_date" : "2018-11-09T18:58:36.352602Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
6为了让window端可以远程访问elasticsearch,需要修改elasticsearch/config/elasticsearch.yml
network.host:192.168.0.1(填你的虚拟机IP)
http.port:9200
7 重启elasticsearch
su esuser
/usr/local/elasticsearch/bin/elasticsearch
可能回报以下错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
打开 /etc/security/limits.d/20-nproc.conf
写入:
eschenhua soft nofile 65536
eschenhua hard nofile 65536
eschenhua soft nproc 4096
eschenhua hard nproc 4096
原来root和*的注释掉
再打开 /etc/sysctl.conf
写入:vm.max_map_count=655360
8关闭虚拟机重启 再启动elasticsearch
如果报以下错误
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/elasticsearch/elasticsearch-6.2.2-1/config/jvm.options
elasticsearch用户没有该文件夹的权限,执行命令
chown -R esyonghu:eszu /usr/local/elasticsearch/
安装elasticsearch-head插件(es的客户端工具)
1 先安装git和node.js
yum install nodejs
yum install git-core
2 cd /usr/local/
git clone git://github.com/mobz/elasticsearch-head.git
3 安装head插件的依赖包
npm install -g grunt-cli
4 cd /usr/local/elasticsearch-head
cnpm install
如果cnpm命令找不到,则执行
npm install -g cnpm --registry=https://registry.npm.taobao.org
再cnpm instll
5 vim Gruntfile.js
在connect---server---optionis下添加:hostname:'*',允许所有IP可以访问
6 vim _site/app.js
找到:this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://loaclhost:9200"
把localhost 改成你自己的IP
7配置es允许跨域访s
打开es的配置文件elasticsearch.yml,在文件末尾增加两行代码即可
http.cors.enabled: true
http.cors.allow-origin: "*"
8打开9100端口
firewall-cmd --zone=public --add-port=9100/tcp --permanent
重启防火墙:firewal-cmd --reload
9启动es-head
/usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server
windows访问es-head
IP:9100
安装kibana
1 下载kibana
https://www.elastic.co/downloads/kibana
上传 解压到 /usr/local/
2 修改配置文件
vim /usr/local/kibana/config/kibana.yml
server.host: "你的IP"
elasticserach.url: "http://你的IP:9200"
3 开启5601端口
firewall-cmd --permanent --zone=public --add-port=5601/tcp
4启动kibana
cd /usr/local/kibana/bin/
./kibana
windows访问:
IP:5601
安装中文分词器
下载
https://github.com/medcl/elasticsearch-analysis-ik
上传解压到 /usr/local/
进入到es-analysis-ik
mvn clean install -Dmaven.test.skip=true
如果mvn命令找不到
则下载mvn
https://maven.apache.org/download.cgi
上传解压到 /usr/local
打开 /etc/profile 添加
export M3_HOME=/usr/local/maven3
export PATH=M3_HOME/bin:$PATH
source /etc/profile
然后再执行mvn clean install -Dmaven.test.skip=true
cd /usr/local/elasticsearch-analysis-ik-master/target/releases
unzip elasticsearch-analysis-ik-6.5.0.zip /usr/local/elasticsearch-6.5.0/plugins/ik
重启es