本版本可以不需要安装jdk
1.Elasticsearch下载地址:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz
2.将Elasticsearch压缩包上传到linux服务器,然后解压到usr/local
tar -avxf elasticsearch-7.4.2-linux-x86_64.tar.gz -C /usr/local/
3.进入解压目录,新建data目录
cd /usr/local/elasticsearch-7.4.2
mkdir data
4.修改config/elasticsearch.yml
vim config/elasticsearch.yml
5.修改elasticsearch.yml配置文件,将需要的配置注释取消,vim查找命令是 Esc以后点击:(冒号)再点击/写上字符串,然后在回车 就找到对应位置。如需要找cluster.name
点击Esc :/cluster.name 回车
cluster.name: my-application #集群名称,将注释取消
node.name: node-1 #节点名称,将注释取消
path.data: /usr/local/elasticsearch-7.4.2/data #数据存储目录,将注释取消
path.logs: /usr/local/elasticsearch-7.4.2/logs #日志存储目录,将注释取消
network.host: 0.0.0.0 #设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
http.port: 9200 #取消端口注释
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]
修改好后Esc :wq 保存退出
6.进入bin目录
cd /usr/local/elasticsearch-7.4.2/bin
7.运行elasticsearch
./elasticsearch
8.内存不够了 ,修改内存
cd /usr/local/elasticsearch-7.4.2/config
vim jvm.options
修改如下内容
-Xms200m
-Xmx200m
:wq 保存并退出vim,再次启动es
报错了,不能以root用户来启动
10.添加一个其他的用户,密码不能过于简单,不能和用户名重复,不能低于8位
adduser es
passwd es
11.改一下es目录所属用户
chown es /usr/local/elasticsearch-7.4.2/ -R
es soft nproc 4096
es hard nproc 4096
es soft nofile 65536
es hard nofile 65536
vim 编辑 /etc/security/limits.conf,在末尾加上:
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
vim /etc/security/limits.d/20-nproc.conf ,在末尾添加如下
es soft nproc 4096
vim 编辑 /etc/sysctl.conf,在末尾加上:
vm.max_map_count = 655360
执行 sysctl -p
切换用户
su es
后台启动
./bin/elasticsearch -d
查看启动进程ps -ef|grep elasticsearch
如果发现自己浏览器还是访问不到9200,那就看一下服务器上的安全组是否没设置,我就是这个原因
kibana7.4.2的安装
下载地址:https://artifacts.elastic.co/downloads/kibana/kibana-7.4.2-linux-x86_64.tar.gz
切换回root用户解压
tar -zxvf kibana-7.4.2-linux-x86_64.tar.gz -C /usr/local
修改配置文件
server.port: 5601 #端口号
server.host: "0.0.0.0" #允许远程访问
elasticsearch.username "es" #es设置的用户名
elasticsearch.password: "studydemo" #es设置的密码
elasticsearch.hosts: ["http://ip:9200"] #Elasticsearch主机地址
切换bin目录
cd /usr/local/kibana-7.4.2-linux-x86_64/bin
启动,官方不建议使用root使用,所以用root时需要加上--allow-root,你也可以建用户来启动他
./kibana --allow-root