Elasticsearch 下载
https://www.elastic.co/downloads/elasticsearch
ik分词器下载
https://github.com/medcl/elasticsearch-analysis-ik/releases
1. tar zxvf elasticsearch-6.5.0.tar.gz //解压
2. rm elasticsearch-6.5.0.tar.gz //删除
3. mv elasticsearch-6.5.0 elasticsearch //重命名
4. groupadd elsearch //组的添加
5. useradd elsearch -g elsearch //用户
6. chown -R elsearch:elsearch elasticsearch //更改该elasticsearch文件夹下所属的用户 和 用户组
7. mkdir /data/es
8. chown -R elsearch:elsearch /data/es
9. su elsearch
10. mkdir es/data
11. mkdir es/logs
12. 修改elasticsearch.yml 文件如下
cat /usr/local/elasticsearch/config/elasticsearch.yml |grep ^[^#]
cluster.name: my-es //集群名字
node.name: node-1
path.data: /data/es/data
path.logs: /data/es/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false //新增配置
network.host: 192.168.0.33
http.port: 9200
====集群配置==== vim config/elasticsearch.yml
<code>cluster.name: lcc-application # 必须一样
node.name: node-191-168-10-175 # 必须不一样
path.data: /home/es/elasticsearch/elasticsearch-6.2.0_data/data/
path.logs: /home/es/elasticsearch/elasticsearch-6.2.0_data/logs/
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0 //0为允许远程访问
http.port: 9200
# 集群发现
#集群节点ip或者主机
discovery.zen.ping.unicast.hosts: ["192.168.10.173", "192.168.10.174","192.168.10.175"]
#设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。默认为1,对于大的集群来说,可以设置大一点的值(2-4)
discovery.zen.minimum_master_nodes: 3
# 下面两行配置为haad插件配置,三台服务器一致。
http.cors.enabled: true
http.cors.allow-origin: "*"
==== ====
12.1 报错: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
修复: elasticsearch.yml中增加配置 cluster.initial_master_nodes: ["node-1"]
13. ./elasticsearch/bin/elasticsearch -d //启动 -d后台启动
启动后会报:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
14. 问题[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
vi /etc/security/limits.conf //修改此文件后是立即生效的,或者重新登录elsearch用户
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
说明:* 代表针对所有用户
noproc 是代表最大进程数
nofile 是代表最大文件打开数
有soft,hard以及-,
soft指的是当前系统生效的设置值。
hard 表明系统中所能设定的最大值。soft的限制不能比hard限制高。
用-就表明同时设置了soft和hard的值。
问题[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
修改文件
vim /etc/security/limits.d/20-nproc.conf
* soft nproc 4096 //改为4096
15. 问题[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:使用下面的命令确认
sysctl -p
16.临时关闭Selinux
setenforce 0 //关闭Selinux
#停止firewalld服务
systemctl stop firewalld
17.ie访问
http://192.168.0.34:9200/
18.关闭es :
1种:ps -ef | grep elastic
kill -9 2382
2种:CTRL+C组合键 //不能用ctrl+z
3种:通过发送TERM信号终止服务器进程.
4种:使用REST APIcurl -XPOST 'http://localhost:9200/_shutdown'.
安装ik分词器
1. 下载ik 的zip包,zip包不用编译,tar.gz包需要编译
https://github.com/medcl/elasticsearch-analysis-ik/releases/
2. 下载elasticsearch-analysis-ik-6.5.0.zip到elasticsearch/plugins/ik目录下 目录ik要自己新建
3. 解压zip到ik目录下: unzip elasticsearch-analysis-ik-6.5.0.zip
4. 正常启动es
配置默认分词器为 ik,并指定分词器为 ik_max_word。
index.analysis.analyzer.default.tokenizer : "ik_max_word"
index.analysis.analyzer.default.type: "ik"
然后重启 ES 即可。验证 IK 是否成功安装,访问下
localhost:9200/_analyze?analyzer=ik&pretty=true&text=中华人民共和国
安装kibana
1. 下载https://www.elastic.co/cn/downloads/kibana 版本要和es版本相同
2. 直接解压到 /usr/local/elasticsearch/kibana-6.2.2-linux-x86_64
3. 配置
# vim /usr/local/elasticsearch/kibana/config/kibana.yml
server.port: 5601 # kibana运行的端口号
server.host: "192.168.0.34" # kibana运行在哪台机器,如:0.0.0.0允许远程访问
elasticsearch.url: "https://192.168.0.34:9200" # kibana监控哪台es机器
4.启动# /usr/local/elasticsearch/kibana/bin/kibana
5.查看界面https://192.168.0.34:5601 可以直接访问