Centos7安装Elasticsearch 8.6.2(傻瓜式安装)
你好呀,我的老朋友!我是老寇,欢迎来到老寇云平台!
跟我一起安装Elasticsearch。
# 下载elasticsearch
elasticsearch官网地址# 下载分词
elasticsearch-analysis-ik地址elasticsearch-analysis-pinyin地址
# 安装软件
# 解压压缩包
cd /opt
tar -zxvf elasticsearch-8.6.2-linux-x86_64.tar.gz
unzip -d /opt/pinyin elasticsearch-analysis-pinyin-8.6.2.zip
unzip -d /opt/ik elasticsearch-analysis-ik-8.6.2.zip
mv elasticsearch-8.6.2 /usr/local/elasticsearch
mv pinyin /usr/local/elasticsearch/plugins/pinyin
mv ik /usr/local/elasticsearch/plugins/ik
# 新增用户名和设置新密码
useradd elasticsearch
passwd elasticsearch
# 创建data和logs文件夹
mkdir -p /usr/local/elasticsearch/home/data
mkdir -p /usr/local/elasticsearch/home/logs
# 授予权限
chmod -R 777 /usr/local/elasticsearch
# 设置elasticsearch.yml
cd /usr/local/elasticsearch/config
vi elasticsearch.yml
# 增加
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: 0.0.0.0
cluster.name: laokou-elasticsearch #可自定义
node.name: node-elasticsearch #可自定义
http.port: 9200
cluster.initial_master_nodes: ["node-elasticsearch"] #这里就是node.name
path.data: /usr/local/elasticsearch/home/data # 数据目录位置
path.logs: /usr/local/elasticsearch/home/logs # 日志目录位置
# 设置堆内存
vi jvm.options
-Xms512m
-Xmx512m
# 修改jdk位置
cd /usr/local/elasticsearch/bin
vi elasticsearch-env
export ES_JAVA_HOME=$JAVA_HOME
# 开启ssl
cd /usr/local/elasticsearch/bin
# ES的根目录生成CA证书
./elasticsearch-certutil ca
# 根据生成的证书,生成p12密钥
./elasticsearch-certutil cert --ca elastic-stack-ca.p12
mkdir /usr/local/elasticsearch/config/certs
cd ..
cp elastic-stack-ca.p12 config/certs
cp elastic-certificates.p12 config/certs
cd config
vi elasticsearch.yml
# 授予权限
chown elasticsearch: /usr/local/elasticsearch/config/certs/elastic-certificates.p12
# 增加
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
# 报错处理
# max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf
vm.max_map_count = 655360
# 刷新参数
sysctl -p
# max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
vi /etc/security/limits.conf
elasticsearch soft nofile 65535
elasticsearch hard nofile 65537
# 启动
# 切换用户
su elasticsearch
cd /usr/local/elasticsearch/bin
./elasticsearch
# 设置密码
cd /usr/local/elasticsearch/config
vi elasticsearch.yml
# 增加
http.cors.allow-headers: Authorization
# 重启elasticsearch
cd /usr/local/elasticsearch/bin
./elasticsearch-setup-passwords interactive
# 后台运行
chmod +x /usr/local/elasticsearch/bin/elasticsearch
cd /usr/local/elasticsearch/bin
./elasticsearch -d
我是老寇,我们下次再见啦!
上次更新: 11/22/2024, 4:10:36 AM