entos7系统部署elastic6.4.3版本集群
2023-12-13 19:56:47
1.环境准备:
?? ?3台机器,要求如下:
?? ??? ?- memory: 2G+
?? ??? ?- disk: 20G+
?? ??? ?- cpu: 2core+
?? ??? ?- IP/主机名:
?? ??? ??? ?10.0.0.101 elk101
?? ??? ??? ?10.0.0.102 elk102
?? ??? ??? ?10.0.0.103 elk103
2.下载ES软件和jdk
es包下载地址: ?wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz
jdk下载地址 ? ?https://www.oracle.com/java/technologies/downloads/#java8-linux?? ?
3.创建ES的工作目录
[root@elk101 ~]# mkdir -pv /linuxmc/{softwares,data,logs}
[root@elk102 ~]# mkdir -pv /linuxmc/{softwares,data,logs}
[root@elk103 ~]# mkdir -pv /linuxmc/{softwares,data,logs}
4.解压软件包
[root@elk101 ~]# tar xf elasticsearch-6.4.3.tar.gz -C /linuxmc/softwares/
[root@elk102 ~]# tar xf elasticsearch-6.4.3.tar.gz -C /linuxmc/softwares/
[root@elk103 ~]# tar xf elasticsearch-6.4.3.tar.gz -C /linuxmc/softwares/
5.创建运行elasticsearch服务用户并修改权限
[root@elk101 ~]# useradd linuxmc
[root@elk101 ~]# chown linuxmc:linuxmc /linuxmc -R
[root@elk102 ~]# useradd linuxmc
[root@elk102 ~]# chown linuxmc:linuxmc /linuxmc -R
[root@elk103 ~]# useradd linuxmc
[root@elk103 ~]# chown linuxmc:linuxmc /linuxmc -R
6.修改文件描述符最大及进程数量打开上限及
[root@elk101 ~]# cat > /etc/security/limits.d/es.conf <<EOF
* ? ? ? ? ?soft ? ?nofile ? ? 65535
* ? ? ? ? ?hard ? ?nofile ? ? 131070
* ? ? ? ? ?hard ? ?nproc ? ? 8192
EOF
[root@elk102 ~]# cat > /etc/security/limits.d/es.conf <<EOF
* ? ? ? ? ?soft ? ?nofile ? ? 65535
* ? ? ? ? ?hard ? ?nofile ? ? 131070
* ? ? ? ? ?hard ? ?nproc ? ? 8192
EOF
[root@elk103 ~]# cat > /etc/security/limits.d/es.conf <<EOF
* ? ? ? ? ?soft ? ?nofile ? ? 65535
* ? ? ? ? ?hard ? ?nofile ? ? 131070
* ? ? ? ? ?hard ? ?nproc ? ? 8192
EOF
7.修改虚拟内存映射上限
?? ?查看内核参数:
[root@elk101 ~]# sysctl -q vm.max_map_count
vm.max_map_count = 262144
[root@elk102 ~]# sysctl -q vm.max_map_count
vm.max_map_count = 262144
[root@elk103 ~]# sysctl -q vm.max_map_count
vm.max_map_count = 262144
?? ?永久生效内核参数(重启OS后配置不丢失) ?强烈推荐
[root@elk101 ~]# cat > /etc/sysctl.d/es.conf <<EOF
vm.max_map_count=262144
EOF
[root@elk102 ~]# cat > /etc/sysctl.d/es.conf <<EOF
vm.max_map_count=262144
EOF
[root@elk103 ~]# cat > /etc/sysctl.d/es.conf <<EOF
vm.max_map_count=262144
EOF
[root@elk101 ~]# sysctl -f /etc/sysctl.d/es.conf
[root@elk102 ~]# sysctl -f /etc/sysctl.d/es.conf
[root@elk103 ~]# sysctl -f /etc/sysctl.d/es.conf
8.修改配置文件
[root@elk101 ~]# egrep -v "^#|^$" /linuxmc/softwares/elasticsearch-6.4.3/config/elasticsearch.yml?
cluster.name: linuxmc-es6 ?# 集群名称
node.master: true ?# 是否成为master
node.name: node-1 ?# 节点名
path.data: /linuxmc/data/es6 ?# 数据目录
path.logs: /linuxmc/logs/es6 ?# 日志目录
bootstrap.memory_lock: true ?# 内存锁,禁止使用swap
network.host: 0.0.0.0 ?# 访问ip
http.port: 9200 ?# 默认访问端口
transport.tcp.port: 9300 ?# tcp传输端口
transport.tcp.compress: true ?# 设置是否压缩tcp传输时的数据,默认为false,不压缩。
discovery.zen.ping.unicast.hosts: ["10.0.0.101:9300","10.0.0.102:9300","10.0.0.103:9300"] ?# 集群节点
gateway.recover_after_nodes: 2 ?# 设置集群中N个节点启动时进行数据恢复,默认为1
[root@elk102 ~]# egrep -v "^#|^$" /linuxmc/softwares/elasticsearch-6.4.3/config/elasticsearch.yml?
cluster.name: linuxmc-es6
node.name: node-2
path.data: /linuxmc/data/es6
path.logs: /linuxmc/logs/es6
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["10.0.0.101:9300","10.0.0.102:9300","10.0.0.103:9300"]
gateway.recover_after_nodes: 2
[root@elk103 ~]# egrep -v "^#|^$" /linuxmc/softwares/elasticsearch-6.4.3/config/elasticsearch.yml?
cluster.name: linuxmc-es6
node.name: node-3
path.data: /linuxmc/data/es6
path.logs: /linuxmc/logs/es6
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["10.0.0.101:9300","10.0.0.102:9300","10.0.0.103:9300"]
gateway.recover_after_nodes: 2
9.修改es堆内存大小
[root@elk101 ~]# egrep -v "^#|^$" /oldboyedu/softwares/elasticsearch-7.17.5/config/jvm.options |grep Xm
-Xms256m
-Xmx256m
生产环境中:
(1)建议设置物理服务器内存的一半;
(2)内存不得超过32Gb;
(3)建议将"-Xmx"和"-Xms"的值设置一致;
10.解压jdk到指定目录
[root@elk101 ~]# tar xf jdk-8u291-linux-x64.tar.gz -C /linuxmc/softwares/
[root@elk102 ~]# tar xf jdk-8u291-linux-x64.tar.gz -C /linuxmc/softwares/
[root@elk103 ~]# tar xf jdk-8u291-linux-x64.tar.gz -C /linuxmc/softwares/
11.配置环境变量
[root@elk101 ~]# cat > /etc/profile.d/jdk.sh <<'EOF'
#!/bin/bash
export JAVA_HOME=/linuxmc/softwares/jdk1.8.0_291
export PATH=$PATH:$JAVA_HOME/bin
EOF
[root@elk101 ~]# source ?/etc/profile.d/jdk.sh?
[root@elk101 ~]#?
[root@elk101 ~]# java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
[root@elk101 ~]#?
11.创建软链接
[root@elk101 ~]# ln -s /linuxmc/softwares/jdk1.8.0_291/bin/java /usr/local/bin/java
[root@elk102 ~]# ln -s /linuxmc/softwares/jdk1.8.0_291/bin/java /usr/local/bin/java
[root@elk103 ~]# ln -s /linuxmc/softwares/jdk1.8.0_291/bin/java /usr/local/bin/java
12.编写ES服务的启动脚本
[root@elk101 ~]# cat > /usr/lib/systemd/system/es6.service <<EOF
[Unit]
Description=www.linuxmc.com
After=network.target
[Service]
User=linuxmc
Group=linuxmc
Type=simple
ExecStart=/linuxmc/softwares/elasticsearch-6.4.3/bin/elasticsearch
LimitNOFILE=131070
LimitNPROC=65535
LimitMEMLOCK=infinity
[Install]
WantedBy=multi-user.target
EOF
[root@elk102 ~]# cat > /usr/lib/systemd/system/es6.service <<EOF
[Unit]
Description=www.linuxmc.com
After=network.target
[Service]
User=linuxmc
Group=linuxmc
Type=simple
ExecStart=/linuxmc/softwares/elasticsearch-6.4.3/bin/elasticsearch
LimitNOFILE=131070
LimitNPROC=65535
LimitMEMLOCK=infinity
[Install]
WantedBy=multi-user.target
EOF
[root@elk103 ~]# cat > /usr/lib/systemd/system/es6.service <<EOF
[Unit]
Description=www.linuxmc.com
After=network.target
[Service]
User=linuxmc
Group=linuxmc
Type=simple
ExecStart=/linuxmc/softwares/elasticsearch-6.4.3/bin/elasticsearch
LimitNOFILE=131070
LimitNPROC=65535
LimitMEMLOCK=infinity
[Install]
WantedBy=multi-user.target
EOF
?? ?
13.所有节点同时启动服务
[root@elk101 ~]# systemctl enable --now es6
[root@elk102 ~]# systemctl enable --now es6
[root@elk103 ~]# systemctl enable --now es6
14.验证服务是否正常
[root@elk101 ~]# systemctl status es6
[root@elk101 ~]# ss -ntl | grep 9
LISTEN ? ? 0 ? ? ?128 ? ? ? [::]:9200 ? ? ? ? ? ? ? ? [::]:* ? ? ? ? ? ? ? ? ?
LISTEN ? ? 0 ? ? ?128 ? ? ? [::]:9300 ? ? ? ? ? ? ? ? [::]:* ? ? ? ? ? ? ? ? ?
[root@elk101 ~]#?
[root@elk101 ~]# curl 10.0.0.101:9200
{
? "name" : "elk101",
? "cluster_name" : "linuxmc-linux86-es6",
? "cluster_uuid" : "w9OoBMxLTXKKiE-k7c8rBA",
? "version" : {
? ? "number" : "7.17.5",
? ? "build_flavor" : "default",
? ? "build_type" : "tar",
? ? "build_hash" : "8d61b4f7ddf931f219e3745f295ed2bbc50c8e84",
? ? "build_date" : "2022-06-23T21:57:28.736740635Z",
? ? "build_snapshot" : false,
? ? "lucene_version" : "8.11.1",
? ? "minimum_wire_compatibility_version" : "6.8.0",
? ? "minimum_index_compatibility_version" : "6.0.0-beta1"
? },
? "tagline" : "You Know, for Search"
}
[root@elk101 ~]# curl 10.0.0.101:9200/_cat/nodes
10.0.0.101 50 49 20 0.45 0.38 0.22 cdfhilmrstw * elk101
10.0.0.102 52 42 22 0.67 0.41 0.22 cdfhilmrstw - elk102
10.0.0.103 46 42 22 0.45 0.32 0.18 cdfhilmrstw - elk103
[root@elk101 ~]#?
日常查看补充:
?? ?1.查看服务状态
[root@elk101 ~]# systemctl status es6 -l
?? ?2.通过系统日志查看
[root@elk101 ~]# journalctl -u es6 ?
?? ?3.查看启动日志
[root@elk101 ~]# tail -100f /linuxmc/softwares/elasticsearch-6.4.3/logs/elasticsearch.log?
?
文章来源:https://blog.csdn.net/LoveYourelf/article/details/134825581
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!