一:安装JDK
1:java安装地址
最新版:https://www.oracle.com/java/technologies/javase-downloads.html
历史版:https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html
2:安装java
(1):安装wget
yum install wget
注意:安装wget提示如下解决方案
解决方案:
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum makecache
yum update -y
然后重新安装即可
(2):安装java
wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm
rpm -ivh jdk-19_linux-x64_bin.rpm
(3):修改环境变量
vim /etc/profile
在文件中添加如下内容
export JAVA_HOME=/usr/local/jdk/jdk-19
export CLASSPATH=.:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
配置环境变量生效
source /etc/profile
(4):判断java是否安装成功
java -version
二:安装elasticsearch
1:添加elasticsearch用户
useradd elasticsearch
passwd elasticsearch
注意执行passwd时提示未找到此命令
解决方案:
yum search passwd
yum install passwd.x86_64
然后重新执行passwd命令即可
2:elasticsearch安装地址
https://www.elastic.co/cn/downloads/past-releases#elasticsearch
3:elasticsearch安装
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-8.6.1-linux-x86_64.tar.gz
mv elasticsearch-8.6.1 /usr/local/elasticsearch
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
4:开启9200端口或关闭防火墙
#启动Firewall
systemctl start firewalld
#设置开机自启动
systemctl enable firewalld.service
# 防火墙开放9200端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
# 刷新防火墙配置
firewall-cmd --reload
#关闭防火墙
systemctl disable firewalld
5:配置elasticsearch
(1):修改elasticsearch默认分配vm空间
vim /usr/local/elasticsearch/config/jvm.options
默认为4g,根据实际情况修改vm空间大小
将
修改成
2:配置elasticsearch
vim /usr/local/elasticsearch/config/elasticsearch.yml
常用配置
path.data: /path/to/data #数据存储位置
path.logs: /path/to/logs #日志存储位置
cluster.name: my-application #集群名称(用于描述集群目的的名称)
node.name: node-1 #节点名称
network.host: 0.0.0.0 #绑定节点IP和端口(0.0.0.0 是不绑定)
http.port:9200 #端口
bootstrap.mlockall: true #这个参数的目的是当你无法关闭系统的swap的时候,建议把这个参数设为true。防止在内存不够用的时候,elasticsearch的内存被交换至交换区,导致性能骤降
6:启动elasticsearch
su elasticsearch
cd /usr/local/elasticsearch
./bin/elasticsearch //启动 (./bin/elasticsearch –d//后台启动)使用elasticsearch用户启动