下载地址
全家桶版本要一致否则会闪退
ElasticSearch: https://mirrors.huaweicloud.com/elasticsearch/?C=N&O=D
logstash: https://mirrors.huaweicloud.com/logstash/?C=N&O=D
kibana: https://mirrors.huaweicloud.com/kibana/?C=N&O=D
jdk:https://mirrors.huaweicloud.com/java/jdk/
elasticsearch-head:https://github.com/mobz/elasticsearch-head
Windows运行elasticsearch
双击文件:bin/elasticsearch.bat
配置跨域访问
冒号后有空格
记事本打开文件,路径config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
localhost:9200
elasticsearch-head插件安装
https://github.com/mobz/elasticsearch-head/
安装nodejs的并启动es插件
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
cnpm run start
Linux安装ES
集群教程
https://www.cnblogs.com/biehongli/p/11650045.html
数据入库文章
https://blog.csdn.net/qq_37660829/article/details/80904452
https://blog.csdn.net/baidu_38299797/article/details/101366284
jdk安装
jdk要放在非root文件夹下
否则用自己创建的wj账号,切换账号后输入java -version会提示找不到jdk
启动ES会提示没有java环境
jdk不要放在root目录下,然后解压jdk,
tar -zxvf jdk-8u151-linux-x64.tar.gz
设置环境变量,打开配置文件,在最后写入环境变量
vim /etc/profile
最后追加
export JAVA_HOME=/es/jdk1.8.0_151
export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
刷新配置
source /etc/profile
elasticsearch解压
elasticsearch不要放在root目录下
tar -zxvf elasticsearch-7.9.2-linux-x86_64.tar.gz
用户与权限
- 由于安全考虑elasticsearch不允许root权限用户直接启动
adduser wj
passwd wj
chown -R wj es
chmod -R 777 es
配置文件
cd es
cd elasticsearch-7.9.2
vim config/elasticsearch.yml
- 修改elasticsearch.yml 去掉注释并修改
node.name: node-1
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
- 设置跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
保存:wq
- 解决内存不够的问题,没有则新增内容
vim /etc/sysctl.conf
vm.max_map_count=655360
- 重新加载配置使变更起效
sysctl -p
- 切换用户
su wj
- 启动
切换到ES文件夹
./bin/elasticsearch 或 ./bin/elasticsearch -d
-
远程访问
服务器IP_9022端口,例如114.116.111.166:9200 -
配置文件参考
ES节点1配置_主
cluster.name: wj-my-application
node.name: node-1
network.host: 0.0.0.0
network.publish_host: 114.116.111.166
#node.master: true 这句不需要
discovery.seed_hosts: ["114.116.111.166", "114.116.99.151", "114.116.109.67"]
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
ES节点2配置_副
cluster.name: wj-my-application
node.name: node-2
network.host: 0.0.0.0
network.publish_host: 114.116.99.151
discovery.seed_hosts: ["114.116.111.166", "114.116.99.151", "114.116.109.67"]
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
ES节点3配置_副
cluster.name: wj-my-application
node.name: node-3
network.host: 0.0.0.0
network.publish_host: 114.116.109.67
discovery.seed_hosts: ["114.116.111.166", "114.116.99.151", "114.116.109.67"]
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
JVM内存设置
点击查看内存设置规则
最大31Gb,数据与内存比搜索1:24配置,日志1:48-1:96.。预留一半给操作系统
数据500GB,500/24约等于21GB
vim /es/elasticsearch-7.8.0/config/jvm.options
# JVM最大、最小使用内存
-Xms8g
-Xmx8g
./bin/elasticsearch -Ehttp.port=8200 -Epath.data=node2
114.116.111.166:9200/_cat/nodes
常用命令
$netstat -lntp 查看端口