es6.3集群安装方法(elasticsearch)
(一)下载安装包
elasticsearch-6.3.0.tar.gz
elasticsearch-analysis-ik-6.3.0.zip
下载地址:
https://www.elastic.co/cn/downloads/past-releases
https://github.com/medcl/elasticsearch-analysis-ik/tags?after=v6.3.0
(二)创建非root用户es
es 不能在root用户下启动,所有需要新创建一个用户es
useradd es
passwd es
1
如果是已经建好的目录权限是root
需要改目录及子目录的权限
chown es.es -R /usr/cwgis/app/es
chown es.es -R /usr/cwgis/data/es
(三)安装es
安装到目录/usr/cwgis/app/es
数据和日志目录
/usr/cwgis/data/es/esdata
/usr/cwgis/data/es/eslog
解压文件
tar -zxvf elasticsearch-6.3.0.tar.gz
mv elasticsearch-6.3.0 es
配置参数文件/es/config/elasticsearch.yml
主要添加如下内容:
cluster.name: es_sapsoft
node.name: node111
#不同机子改为不同机器名或IP,如node112,node123,
#注意:冒号后面有一个空格
path.data: /usr/cwgis/data/es/esdata
path.logs: /usr/cwgis/data/es/eslog
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: node111 #不同机子改为不同机器名或IP
http.port: 9200
#9300为集群服务的端口
discovery.zen.ping.unicast.hosts: ["node111", "node112", "node113", "node115", "node116", "node117", "node118", "node119", "node120", "node121", "node122", "node123"]
#为了避免stop,集群节点数最少为 半数+1
discovery.zen.minimum_master_nodes: 7
http.cors.enabled: true
http.cors.allow-origin: "*"
分发安装目录
cc.sh /usr/cwgis/app/es /usr/cwgis/app/ es
cc.sh /usr/cwgis/data/es /usr/cwgis/data/ es
(四)安装ik分词器(提供分词查询,所有机器必须安装)
1.ik分词器
安装到es/plugins/ik 目录下,需要新建一个ik目录
解压文件elasticsearch-analysis-ik-6.3.0.zip到目录/usr/cwgis/app/es/plugins/ik
分发插件安装目录
cc.sh /usr/cwgis/app/es/plugins/ik /usr/cwgis/app/es/plugins/ es
2.拼音分词器
安装到es/plugins/pinyin 目录下,需要新建一个pinyin目录
elasticsearch-analysis-pinyin-6.3.0.zip
下载地址:https://github.com/medcl/elasticsearch-analysis-pinyin
选择releases版本项下载6.3.0版本
解压文件elasticsearch-analysis-pinyin-6.3.0.zip到目录/usr/cwgis/app/es/plugins/pinyin
分发插件安装目录
cc.sh /usr/cwgis/app/es/plugins/pinyin /usr/cwgis/app/es/plugins/ es
(五)修改centos中的系统文件内容:
vi /etc/security/limits.conf 修改内容如下:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
分发配置文件cc.sh /etc/security/limits.conf /etc/security/limits.conf es
vi /etc/security/limits.d/20-nproc.conf 修改内容如下:
* soft nproc 2048
分发配置文件cc.sh /etc/security/limits.d/20-nproc.conf /etc/security/limits.d/20-nproc.conf es
vi /etc/sysctl.conf 修改内容如下:
vm.max_map_count=655360
分发配置文件cc.sh /etc/sysctl.conf /etc/sysctl.conf es
并执行命令sysctl -p
runCmd.sh “sysctl -p” es
(六)启动es集群
后台启动命令:/es/bin/elasticsearch -d
需要以es用户启动es集群,不能用root有户启动
su es
1
runCmd.sh "/usr/cwgis/app/es/bin/elasticsearch -d" es
(七)显示查看web页面
http://node111:9200/_cat/
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
查看所有节点地址:http://node111:9200/_cat/nodes
192.168.30.112 38 43 0 0.00 0.01 0.05 mdi - node112
192.168.30.116 34 26 0 0.00 0.01 0.05 mdi - node116
192.168.30.117 22 34 0 0.00 0.01 0.05 mdi * node117
192.168.30.120 35 27 0 0.00 0.01 0.05 mdi - node120
192.168.30.118 34 29 0 0.00 0.01 0.05 mdi - node118
192.168.30.111 22 54 0 0.00 0.02 0.05 mdi - node111
192.168.30.119 35 28 0 0.04 0.09 0.07 mdi - node119
192.168.30.123 31 30 0 0.01 0.04 0.05 mdi - node123
192.168.30.113 29 40 0 0.00 0.01 0.05 mdi - node113
192.168.30.121 31 30 0 0.00 0.01 0.05 mdi - node121
192.168.30.115 37 28 0 0.00 0.01 0.05 mdi - node115
192.168.30.122 31 27 0 0.05 0.10 0.08 mdi - node122
- node117表示当前活动主master节点
(八)es测试
创建index
[es@node111 root]$ curl -XPUT "http://node111:9200/index"
{"acknowledged":true,"shards_acknowledged":true,"index":"index"}
分词测试
分析类型:ik_smart
[es@node111 root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "analyzer": "ik_smart", "text": "手机充值" }'
{
"tokens" : [
{
"token" : "手机",
"start_offset" : 0,
"end_offset" : 2,
"type" : "CN_WORD",
"position" : 0
},
{
"token" : "充值",
"start_offset" : 2,
"end_offset" : 4,
"type" : "CN_WORD",
"position" : 1
}
]
}
分析类型ik_max_word
[es@node111 root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "analyzer": "ik_max_word", "text": "中华人民共和国" }'
{
"tokens" : [
{
"token" : "中华人民共和国",
"start_offset" : 0,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 0
},
{
"token" : "中华人民",
"start_offset" : 0,
"end_offset" : 4,
"type" : "CN_WORD",
"position" : 1
},
{
"token" : "中华",
"start_offset" : 0,
"end_offset" : 2,
"type" : "CN_WORD",
"position" : 2
},
{
"token" : "华人",
"start_offset" : 1,
"end_offset" : 3,
"type" : "CN_WORD",
"position" : 3
},
{
"token" : "人民共和国",
"start_offset" : 2,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 4
},
{
"token" : "人民",
"start_offset" : 2,
"end_offset" : 4,
"type" : "CN_WORD",
"position" : 5
},
{
"token" : "共和国",
"start_offset" : 4,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 6
},
{
"token" : "共和",
"start_offset" : 4,
"end_offset" : 6,
"type" : "CN_WORD",
"position" : 7
},
{
"token" : "国",
"start_offset" : 6,
"end_offset" : 7,
"type" : "CN_CHAR",
"position" : 8
}
]
}
拼音分词测试
[es@node111 root]$ curl -XPOST http://node111:9200/_analyze?pretty -H 'Content-Type:application/json' -d '{ "analyzer": "pinyin", "text": "张学友" }'
{
"tokens" : [
{
"token" : "zhang",
"start_offset" : 0,
"end_offset" : 0,
"type" : "word",
"position" : 0
},
{
"token" : "zxy",
"start_offset" : 0,
"end_offset" : 0,
"type" : "word",
"position" : 0
},
{
"token" : "xue",
"start_offset" : 0,
"end_offset" : 0,
"type" : "word",
"position" : 1
},
{
"token" : "you",
"start_offset" : 0,
"end_offset" : 0,
"type" : "word",
"position" : 2
}
]
}
—the—end—
参考地址:
https://blog.csdn.net/u012666361/article/details/80111696
https://blog.csdn.net/liangzhao_jay/article/details/56840941
http://blog.sina.com.cn/s/blog_6592485b0102z4w5.html
es head插件安装方法参考地址:
https://blog.csdn.net/qq_24570443/article/details/82151056
下载es head google扩展插件(最简单的方式)
https://download.csdn.net/download/z670707170/10647995
google游览器安装离线扩展程序方法:
eshead.crx 改扩展名为rar,然后解压到目录
拷贝目录到google游览器/更多工具/扩展程序/开发者模式/加载已解压的扩展程序
中,就可以在google游览器地址栏后面添加一个es head 插件小图标,点击就进入es head插件界面中录入es服务地址:
http://localhost:9200 或
http://node111:9200 就可以查看web客户端管理界面。