1、环境信息:CentOS版本
(1)CentOS-7-x86_64-Minimal-1810
下载地址:https://pan.baidu.com/s/1Hu6dMOTXQYK8ULEBcATZzw 提取 码:zw0s
(2)ElasticSearch 版本Elasticsearch 7.2.0
下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-2-0
(3)JDK 11 jdk-11.0.14_linux-x64_bin.tar.gz
下载地址:https://www.oracle.com/java/technologies/downloads/
2、JDK安装:
将下载的jdk拷贝到/url/local/目录
解压 tar -zxvf jdk-11.0.14_linux-x64_bin.tar.gz
重命名 jdk-11.0.14 jdk11
配置环境变量
vim /etc/profile
问题:由于CentOS7是最简版,没有vim命令
yum install vim 安装vim命令
安装完成后再profile最后添加如下内容:
export JAVA_HOME=/usr/local/jdk/11
export JRE_HOME=/
J
A
V
A
H
O
M
E
/
j
r
e
e
x
p
o
r
t
C
L
A
S
S
P
A
T
H
=
.
:
JAVA_HOME/jre export CLASSPATH=.:
JAVAHOME/jreexportCLASSPATH=.:JAVA_HOME/jre/lib/rt.jar:
J
A
V
A
H
O
M
E
/
l
i
b
/
d
t
.
j
a
r
:
JAVA_HOME/lib/dt.jar:
JAVAHOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
export PATH=
P
A
T
H
:
PATH:
PATH:JAVA_HOME/bin:$JRE_HOME/bin
保存 并运行source /etc/profile 使编辑内容生效
输入:java -version 查看jdk安装是否成功
3、ElasticSearch安装
我将ElasticSearch安装到了/opt目录下,
解压ElasticSearch tar -zxvf elasticsearch-7.2.0-linux-x86_64.tar.gz
为了配置方便将解压后的文件重命名mv mv elasticsearch-7.2.0 elasticsearch
elasticSearch 为了系统安全,不允许使用root账号启动
新建elastic 账号,并将elasticsearch 权限赋给elastic
useradd elastic
chown -R elastic:elastic /opt/elasticsearch
创建elastic 存储目录
mkdir /opt/elasticsearch/data
修改elasticsearch配置文件 vim /opt/elasticsearch/config/elasticsearch.yml
(1)修改日志目录
path.logs: /opt/elasticsearch/logs
(2)修改存储目录
path.data: /opt/elasticsearch/data
(3)允许远程访问
network.host: 0.0.0.0
启动:cd /opt/elasticsearch/bin
./elasticsearch
启动后出现以下错误:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.i
[1] 错误需要做以下修改:vim /etc/security/limits.conf 在最后增加如下内容
elastic soft nofile 65535
elastic hard nofile 65535
[2]错误 做如下修改:vim /etc/sysctl.conf 最后增加如下内容
vm.max_map_count=262144
运行 sysctl -p 使配置生效
[3]错误做如下修改:vim /opt/elasticsearch/config/elasticsearch.yml
增加如下配置:
network.host: 0.0.0.0
discovery.seed_hosts: [“127.0.0.1”,"[::1]"]
cluster.initial_master_nodes: [“node-1”]
http.cors.enabled: true
http.cors.allow-origin: “*”
启动:进入elasticsearch/bin目录
./elasticsearch 启动
./elasticsearch -d 后台启动
查看运行状态: