Elasticsearch部署安装

环境准备

Anolis OS 8

Firewall关闭状态,端口自行处理

Elasticsearch:7.16.1(该版本需要jdk11)

JDK:11.0.19

JDK

bash 复制代码
# 解压
tar -zxvf jdk-11.0.19_linux-x64_bin.tar.gz

# 编辑/etc/profile
vim /etc/profile

# 加入如下配置
export JAVA_HOME=/home/jdk-11.0.19
export JRE_HOME=/home/jdk-11.0.19/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin

# 保存退出后,使该配置文件即刻生效
source /etc/profile

# 使用如下命令,能正确显示信息,说明环境配置成功
java -version

Elasticsearch

bash 复制代码
############ 安装 ############
# 下载elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.16.1-linux-x86_64.tar.gz

# 解压
tar -zxf elasticsearch-7.16.1-linux-x86_64.tar.gz -C /usr/local/

# 配置变量
# 编辑/etc/profile
vim /etc/profile

# 加入如下配置
export PATH=$PATH:/usr/local/elasticsearch-7.16.1/bin

# 保存退出后,使该配置文件即刻生效
source /etc/profile


############ 配置 ############
mkdir /home/elasticsearch/data
mkdir /home/elasticsearch/logs
# 注意授权
chmod -R 777 /home/elasticsearch/

# 修改 Elasticsearch配置文件
vim /usr/local/elasticsearch-7.16.1/config/elasticsearch.yml

cluster.name: my-application
node.name: node-1
# 自定义数据存储路径
path.data: /home/elasticsearch/data
# 自定义日志存在路径
path.logs: /home/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
# 关闭密码认证
xpack.security.enabled: false
# 集群模式,single-node 是单节点
discovery.type: single-node
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true



# 修改 Elasticsearch JVM的内存限制
vim /usr/local/elasticsearch-7.16.1/config/jvm.options
#建议调至当前可用内存的一半
-Xms2g
-Xmx2g

创建elastic用户、授予elastic权限,并启动服务

bash 复制代码
# 添加elastic用户,禁止ssh登录
useradd -s /sbin/nologin elastic
 
# 授权
chown -R elastic:elastic /usr/local/elasticsearch-7.16.1/
 
# 切换 elastic 用户
su - elastic -s /bin/bash

# 验证版本
elasticsearch --version
 
# 启动服务
elasticsearch -d

# 查看端口是否监听
netstat -lntp |grep 9200

# 服务没问题后退出当前用户
exit

Elasticsearch开启密码(如有需要)

bash 复制代码
/usr/local/elasticsearch-7.16.1/bin/elasticsearch-setup-passwords interactive
输入:y
输入自定义密码:123456

IK分词器安装

找到相对应的版本下载

https://github.com/medcl/elasticsearch-analysis-ik/releases

bash 复制代码
mkdir /usr/local/elasticsearch-7.16.1/plugins/ik

cd /usr/local/elasticsearch-7.16.1/plugins/ik

unzip elasticsearch-analysis-ik-7.16.1.zip

重启Elasticsearch

bash 复制代码
su - elastic -s /bin/bash

# 停止服务
ps -ef |grep -w elasticsearch-7.16.1 |grep -v grep | awk '{print $2}' |xargs kill

# 启动服务
elasticsearch -d
相关推荐
cui_win9 分钟前
每日一令:Linux 极简通关指南 - 汇总
linux·运维·服务器
知星小度S38 分钟前
Linux权限探秘:驾驭权限模型,筑牢系统安全
linux·运维·服务器
Kaede63 小时前
如何应对Linux云服务器磁盘空间不足的情况
linux·运维·服务器
Kookoos6 小时前
Dynamics 365 Finance + Power Automate 自动化凭证审核
运维·自动化·dynamics 365·power automate
努力学习的小廉10 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗10 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
jiunian_cn12 小时前
【Linux】centos软件安装
linux·运维·centos
藥瓿亭12 小时前
K8S认证|CKS题库+答案| 6. 创建 Secret
运维·ubuntu·docker·云原生·容器·kubernetes·cks
2302_8097983212 小时前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器
嵌入式大圣12 小时前
Neko虚拟浏览器远程协作方案:Docker+内网穿透技术部署实践
运维·docker·容器