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
相关推荐
程序员-Benothing6 小时前
Vim编辑器从入门到精通:模式、快捷键、配置、插件
linux·运维·服务器
m0_646429977 小时前
Docker 完整核心知识点总结(超通俗易懂版)
运维·docker·容器
亚川楼宇自控系统数据中心厂家7 小时前
IBMS 集成管理系统:如何打通楼宇自控实现建筑一体化管控
运维
迪康Defender7 小时前
终端安全审批体系设计:如何平衡安全管控与业务连续性
运维·服务器·安全·运维开发·学习方法·业界资讯·远程工作
luo_guibin9 小时前
Linux系统下OpenSSL升级全流程,新旧版本切换
linux·运维·服务器
7177779 小时前
支持混合云的 DevOps 平台有哪些:主流方案对比与选型指南
运维·devops
看着博客敲代码9 小时前
No space left on device:服务器被 SSH 爆破到日志写满的完整排查与止血
linux·运维·服务器·安全·ssh
编程序的员9 小时前
使用OpenTelemetry来监控Rust应用
运维·rust·monitoring·opentelemetry
实战派K8S&DB9 小时前
TDSQL 核心模块与进程体系
运维·数据库·分布式·sql·mysql
Rooting++9 小时前
用友打包的APP壳子怎么获取SHA1码?
运维·服务器