文章目录
1、安装JDK
卸载JDK
rpm -qa | grep java | xargs rpm -e --nodeps
链接:http://note.youdao.com/noteshare?id=55bdeb5d7a3ebe617d5a40699d86bd73&sub=9D68DCF83E2747D98A655CB2992EF9EE
创建用户
# 创建组
groupadd elkGroup
# 创建用户和分组
useradd -g elkGroup elk
# 设置密码
passwd elk
2.安装elasticsearch
https://www.cnblogs.com/jingping/p/9448099.html
遇到的问题:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]\
虚拟机安装,访问不了,防火墙问题
一、iptables防火墙
1、基本操作
# 查看防火墙状态
service iptables status
# 停止防火墙
service iptables stop
# 启动防火墙
service iptables start
# 重启防火墙
service iptables restart
# 永久关闭防火墙
chkconfig iptables off
# 永久关闭后重启
chkconfig iptables on
2、开启80端口
vim /etc/sysconfig/iptables
# 加入如下代码
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
保存退出后重启防火墙
service iptables restart
二、firewall防火墙
1、查看firewall服务状态
systemctl status firewalld
出现Active: active (running)切高亮显示则表示是启动状态。
出现 Active: inactive (dead)灰色表示停止,看单词也行。
2、查看firewall的状态
firewall-cmd --state
3、开启、重启、关闭、firewalld.service服务
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
4、查看防火墙规则
firewall-cmd --list-all
5、查询、开放、关闭端口
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
# 参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
配置集群
机器1【192.168.47.128】
使用es用户创建data和logs的目录
path.data: /home/es/elasticsearch-6.6.1/data
path.logs: //home/es/elasticsearch-6.6.1/logs
linux系统下修改某个文件夹下所有的文件权限
sudo chmod -R 777 /home/es/elasticsearch-6.6.1
cluster.name: my-application
node.name: node-1
path.data: /home/es/elasticsearch-6.6.1/data
path.logs: //home/es/elasticsearch-6.6.1/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.47.128
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.47.128:9300","192.168.47.129:9300","192.168.47.130:9300"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
node.master: true
node.data: false
node.ingest: false
search.remote.connect: false
discovery.zen.ping_timeout: 120s
http.cors.enabled: true
http.cors.allow-origin: "*"
机器2【192.168.47.129】
cluster.name: my-application
node.name: node-2
path.data: /home/es/elasticsearch-6.6.1/data
path.logs: //home/es/elasticsearch-6.6.1/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.47.129
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.47.128:9300","192.168.47.129:9300","192.168.47.130:9300"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
node.master: true
node.data: false
node.ingest: false
search.remote.connect: false
discovery.zen.ping_timeout: 120s
http.cors.enabled: true
http.cors.allow-origin: "*"
机器3【192.168.47.130】
cluster.name: my-application
node.name: node-3
path.data: /home/es/elasticsearch-6.6.1/data
path.logs: //home/es/elasticsearch-6.6.1/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.47.130
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.47.128:9300","192.168.47.129:9300","192.168.47.130:9300"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
node.master: true
node.data: false
node.ingest: false
search.remote.connect: false
discovery.zen.ping_timeout: 120s
http.cors.enabled: true
http.cors.allow-origin: "*"
-- 切换普通用户启动
su es
/home/es/elasticsearch-5.4.0/bin/elasticsearch ---前台启动
/home/es/elasticsearch-5.4.0/bin/elasticsearch -d ---后台启动
查看启动进程方式一:jps | grep Elasticsearch
查看启动进程方式二: ps -ef|grep elasticsearch
关闭:
kill -15 pid
访问链接
http://192.168.47.129:9200/?pretty
集群
https://blog.csdn.net/weixin_41734700/article/details/80540367
设置系统开机启动
https://www.cnblogs.com/Rawls/p/10937280.html
中文分词安装
https://github.com/medcl/elasticsearch-analysis-ik/tree/6.x
使用链接查询elasticsearch的版本
http://192.168.47.129:9200/?pretty
再使用命令安装【修改为相应的版本】
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.0/elasticsearch-analysis-ik-6.3.0.zip
查看文件并修改文件目录权限
cd /plugins
ll
chown -R es:es ik/
查看进程
ps -ef|grep elasticsearch
杀掉进程
kill -15
su es
./elasticsearch -d
使用postman查询
- 选择body模式,raw模式
- 返回值设置为json格式
- 填写请求内容为:
http://elasticsearch001.zjcx-local.com:9200/_analyze
{
"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
},
{
"token": "国歌",
"start_offset": 7,
"end_offset": 9,
"type": "CN_WORD",
"position": 9
}
]
}