ES-6文章:
Elasticsearch6.6.0部署、原理和使用介绍: https://blog.csdn.net/wt334502157/article/details/119515730
ES-7文章:
Elasticsearch7.6.1部署、原理和使用介绍: https://blog.csdn.net/wt334502157/article/details/127693231
ES8正文- Elasticsearch8.3.2搭建部署详细步骤
| IP地址 | 操作系统 | 主机名 | 角色 |
|---|---|---|---|
| 172.28.54.213 | CentOS7.8 | es01 | master&data节点 |
| 172.28.54.214 | CentOS7.8 | es02 | master&data节点 |
| 172.28.54.215 | CentOS7.8 | es03 | master&data节点 |
- es各节点均为master,Elasticsearch-8版本部署的集群无主思想
- 这里使用了三台全新的机器,考虑到es版本8对java的要求相对较高,如机器部署的应用较多,避免java环境混乱以及应用之间相互影响,所以es8不建议使用在已经部署较多java环境的应用机器。
ES各版本对java版本的需求:
ES 7.x 及之前版本:选择 Java 8
ES 8.x,支持 Java 17 和 Java 18,推荐版本:
- 其中对于ES 8.0:Java版本仅支持 Java 17
- ES 8.1及以上版本:支持Java 17 以及 Java 18,建议使用Java 17
【注意】
- Java 9、Java 10、Java 12 和 Java 13 均为官方公布的短期版本,ES各版本均不推荐使用这几个
- ES 8.1及以上版本的es对应版本的 Logstash 不支持 Java 18
- elasticsearch项目的jdk目录下现在已经内置了openjdk18,也可以直接使用
x# 172.28.54.213hostnamectl set-hostname es01
# 172.28.54.214hostnamectl set-hostname es01
# 172.28.54.215hostnamectl set-hostname es01ES不能使用root用户来启动,否则会报错,使用普通用户来安装启动。创建一个普通用户以及定义一些常规目录用于存放我们的数据文件以及安装包等
xxxxxxxxxx# 3台机器都需要执行[root@es01 ~]# useradd wangting && echo wangting|passwd --stdin wangtingxxxxxxxxxx[root@es01 ~]# visudo# 增加一行普通用户权限内容wangting ALL=(ALL) NOPASSWD:ALL让普通用户有更大的操作权限,一般都会给普通用户设置sudo权限,方便普通用户的操作,避免操作时频繁输入密码
xxxxxxxxxx[root@es01 ~]# vim /etc/hosts# es172.28.54.213 es01172.28.54.214 es02172.28.54.215 es03如果在各节点的/etc/hosts中都配置了节点的ip解析,那后续在配置文件中,相关的ip配置都可以用解析名代替
各组件均可以在官方找到对应版本下载:
官方下载安装包地址:https://www.elastic.co/cn/downloads/elasticsearch
xxxxxxxxxx# 下载安装包[root@es01 ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.2-linux-x86_64.tar.gz[root@es01 ~]# ls -ltotal 526672-rw-r--r-- 1 root root 539306119 Jul 7 2022 elasticsearch-8.3.2-linux-x86_64.tar.gz
- 注意环境优化为各节点均要执行的实施操作,需要自行在每个节点去执行命令
系统允许 Elasticsearch 打开的最大文件数需要修改成65536
xxxxxxxxxx[root@es01 ~]# vim /etc/security/limits.conf# End of file* soft nofile 65536* hard nofile 131072* soft nproc 2048* hard nproc 65536
# 断开重连会话[root@es01 ~]# ulimit -n65536如果这个配置不优化后续启动服务会出现: [error] max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] elasticsearch
允许最大进程数配置修该成4096;不是4096则需要修改优化
xxxxxxxxxx[root@es01 ~]# vim /etc/security/limits.d/20-nproc.conf# Default limit for number of user's processes to prevent# accidental fork bombs.# See rhbz #432903 for reasoning.
* soft nproc 4096root soft nproc unlimited这个配置不优化启动服务会出现: [error]max number of threads [1024] for user [judy2] likely too low, increase to at least [4096]
设置一个进程可以拥有的虚拟内存区域的数量
xxxxxxxxxx# 增加配置项vm.max_map_count[root@es01 ~]# vim /etc/sysctl.conf vm.max_map_count=262144# 重载配置[root@es01 ~]# sysctl -p这个配置不优化启动服务会出现: [error]max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
xxxxxxxxxx[root@es01 ~]# mkdir -p /opt/module/[root@es01 ~]# chown -R wangting.wangting /opt/module/[root@es01 ~]# tar -xf elasticsearch-8.3.2-linux-x86_64.tar.gz -C /opt/module/[root@es01 ~]# chown -R wangting.wangting /opt/module/elasticsearch-8.3.2[root@es01 ~]# cd /opt/module/elasticsearch-8.3.2/[root@es01 elasticsearch-8.3.2]# ls -ltotal 892drwxr-xr-x 2 wangting wangting 4096 Jul 6 2022 bindrwxr-xr-x 3 wangting wangting 4096 Feb 10 15:05 configdrwxr-xr-x 8 wangting wangting 4096 Jul 6 2022 jdkdrwxr-xr-x 5 wangting wangting 4096 Jul 6 2022 lib-rw-r--r-- 1 wangting wangting 3860 Jul 6 2022 LICENSE.txtdrwxr-xr-x 2 wangting wangting 4096 Jul 6 2022 logsdrwxr-xr-x 66 wangting wangting 4096 Jul 6 2022 modules-rw-r--r-- 1 wangting wangting 874704 Jul 6 2022 NOTICE.txtdrwxr-xr-x 2 wangting wangting 4096 Jul 6 2022 plugins-rw-r--r-- 1 wangting wangting 2710 Jul 6 2022 README.asciidocxxxxxxxxxx[root@es01 elasticsearch-8.3.2]# vim /etc/profile# ESexport JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdkexport ES_HOME=/opt/module/elasticsearch-8.3.2export PATH=$PATH:$ES_HOME/bin
# 引用[root@es01 elasticsearch-8.3.2]# source /etc/profile[root@es01 ~]# /opt/module/elasticsearch-8.3.2/jdk/bin/java -versionopenjdk version "18.0.1.1" 2022-04-22OpenJDK Runtime Environment (build 18.0.1.1+2-6)OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
# ###节点es02上操作###[root@es02 ~]# vim /etc/profile# ESexport JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdkexport ES_HOME=/opt/module/elasticsearch-8.3.2export PATH=$PATH:$ES_HOME/bin
[root@es02 ~]# source /etc/profile
# ###节点es03上操作###[root@es03 ~]# vim /etc/profile# ESexport JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdkexport ES_HOME=/opt/module/elasticsearch-8.3.2export PATH=$PATH:$ES_HOME/bin
[root@es03 ~]# source /etc/profilexxxxxxxxxx# 创建数据文件目录[root@es01 ~]# mkdir -p /opt/module/elasticsearch-8.3.2/data# 创建证书生成目录[root@es01 ~]# mkdir -p /opt/module/elasticsearch-8.3.2/config/certs# 目录有改动,重新刷一下权限[root@es01 module]# chown -R wangting:wangting /opt/module/elasticsearch-8.3.2
# 分发至es02、es03# 新建目录[root@es02 ~]# mkdir -p /opt/module[root@es03 ~]# mkdir -p /opt/module# 分发到其他节点,并在02 03上查看操作文件权限[root@es01 ~]# scp -r /opt/module/elasticsearch-8.3.2 es02:/opt/module/elasticsearch-8.3.2[root@es01 ~]# scp -r /opt/module/elasticsearch-8.3.2 es03:/opt/module/elasticsearch-8.3.2# 目录文件权限刷用户所属[root@es02 module]# chown -R wangting:wangting /opt/module/elasticsearch-8.3.2[root@es03 module]# chown -R wangting:wangting /opt/module/elasticsearch-8.3.2xxxxxxxxxx# 在第一台服务器节点es01 设置集群多节点通信密钥# 切换普通用户实施[root@es01 module]# su - wangting[wangting@es01 ~]$ cd /opt/module/elasticsearch-8.3.2/bin[wangting@es01 bin]$ ./elasticsearch-certutil cawarning: ignoring JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdk; using bundled JDKThis tool assists you in the generation of X.509 certificates and certificatesigning requests for use with SSL/TLS in the Elastic stack.The 'ca' mode generates a new 'certificate authority'This will create a new X.509 certificate and private key that can be usedto sign certificate when running in 'cert' mode.
Use the 'ca-dn' option if you wish to configure the 'distinguished name'of the certificate authority
By default the 'ca' mode produces a single PKCS#12 output file which holds: * The CA certificate * The CA's private key
If you elect to generate PEM format certificates (the -pem option), then the output willbe a zip file containing individual files for the CA certificate and private key
Please enter the desired output file [elastic-stack-ca.p12]: # 回车即可Enter password for elastic-stack-ca.p12 : # 回车即可
# 用 ca 证书签发节点证书,过程中需按三次回车键,生成目录:es的home:/opt/elasticsearch-8.3.2/[wangting@es01 bin]$ ./elasticsearch-certutil cert --ca elastic-stack-ca.p12
If you specify any of the following options: * -pem (PEM formatted output) * -multiple (generate multiple certificates) * -in (generate certificates from an input file)then the output will be be a zip file containing individual certificate/key files
Enter password for CA (elastic-stack-ca.p12) : # 回车即可Please enter the desired output file [elastic-certificates.p12]: # 回车即可Enter password for elastic-certificates.p12 : # 回车即可
Certificates written to /opt/module/elasticsearch-8.3.2/elastic-certificates.p12
This file should be properly secured as it contains the private key for your instance.This file is a self contained file and can be copied and used 'as is'For each Elastic product that you wish to configure, you should copythis '.p12' file to the relevant configuration directoryand then follow the SSL configuration instructions in the product guide.
For client applications, you may only need to copy the CA certificate andconfigure the client to trust this certificate.
# 将生成的证书文件移动到 config/certs 目录中[wangting@es01 bin]$ cd /opt/module/elasticsearch-8.3.2/[wangting@es01 elasticsearch-8.3.2]$ ls -l | grep "elastic-"-rw------- 1 wangting wangting 3596 Feb 10 16:05 elastic-certificates.p12-rw------- 1 wangting wangting 2672 Feb 10 16:03 elastic-stack-ca.p12[wangting@es01 elasticsearch-8.3.2]$ [wangting@es01 elasticsearch-8.3.2]$ mv elastic-certificates.p12 config/certs/[wangting@es01 elasticsearch-8.3.2]$ mv elastic-stack-ca.p12 config/certs/xxxxxxxxxx# 签发 Https 证书[wangting@es01 elasticsearch-8.3.2]$ cd /opt/module/elasticsearch-8.3.2/bin/[wangting@es01 bin]$ ./elasticsearch-certutil httpwarning: ignoring JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdk; using bundled JDK
## Elasticsearch HTTP Certificate UtilityThe 'http' command guides you through the process of generating certificatesfor use on the HTTP (Rest) interface for Elasticsearch.This tool will ask you a number of questions in order to generate the rightset of files for your needs.## Do you wish to generate a Certificate Signing Request (CSR)?A CSR is used when you want your certificate to be created by an existingCertificate Authority (CA) that you do not control (that is, you don't haveaccess to the keys for that CA). If you are in a corporate environment with a central security team, then youmay have an existing Corporate CA that can generate your certificate for you.Infrastructure within your organisation may already be configured to trust thisCA, so it may be easier for clients to connect to Elasticsearch if you use aCSR and send that request to the team that controls your CA.If you choose not to generate a CSR, this tool will generate a new certificatefor you. That certificate will be signed by a CA under your control. This is aquick and easy way to secure your cluster with TLS, but you will need toconfigure all your clients to trust that custom CA.####################################################### 是否生成CSR,选择 N ,不需要 #######################################################Generate a CSR? [y/N]N
## Do you have an existing Certificate Authority (CA) key-pair that you wish to use to sign your certificate?
If you have an existing CA certificate and key, then you can use that CA tosign your new http certificate. This allows you to use the same CA acrossmultiple Elasticsearch clusters which can make it easier to configure clients,and may be easier for you to manage.
If you do not have an existing CA, one will be generated for you.####################################################### 是否使用已经存在的CA证书,选择 y ,因为已经创建签发好了CA #######################################################Use an existing CA? [y/N]y
## What is the path to your CA?Please enter the full pathname to the Certificate Authority that you wish touse for signing your new http certificate. This can be in PKCS#12 (.p12), JKS(.jks) or PEM (.crt, .key, .pem) format.####################################################### 指定CA证书的路径地址,CA Path:后写绝对路径 #######################################################CA Path: /opt/module/elasticsearch-8.3.2/config/certs/elastic-stack-ca.p12Reading a PKCS12 keystore requires a password.It is possible for the keystore's password to be blank,in which case you can simply press <ENTER> at the prompt
####################################################### 设置密钥库的密码,直接 回车 即可 #######################################################Password for elastic-stack-ca.p12:
## How long should your certificates be valid?
Every certificate has an expiry date. When the expiry date is reached clientswill stop trusting your certificate and TLS connections will fail.Best practice suggests that you should either:(a) set this to a short duration (90 - 120 days) and have automatic processesto generate a new certificate before the old one expires, or(b) set it to a longer duration (3 - 5 years) and then perform a manual updatea few months before it expires.
You may enter the validity period in years (e.g. 3Y), months (e.g. 18M), or days (e.g. 90D)####################################################### 设置证书的失效时间,这里的y表示年,5y则代表失效时间5年 #######################################################For how long should your certificate be valid? [5y] 5y
## Do you wish to generate one certificate per node?
If you have multiple nodes in your cluster, then you may choose to generate aseparate certificate for each of these nodes. Each certificate will have itsown private key, and will be issued for a specific hostname or IP address.
Alternatively, you may wish to generate a single certificate that is validacross all the hostnames or addresses in your cluster.
If all of your nodes will be accessed through a single domain(e.g. node01.es.example.com, node02.es.example.com, etc) then you may find itsimpler to generate one certificate with a wildcard hostname (*.es.example.com)and use that across all of your nodes.
However, if you do not have a common domain name, and you expect to addadditional nodes to your cluster in the future, then you should generate acertificate per node so that you can more easily generate new certificates whenyou provision new nodes.
####################################################### 是否需要为每个节点都生成证书,选择 N 无需每个节点都配置证书 #######################################################Generate a certificate per node? [y/N]N
## Which hostnames will be used to connect to your nodes?These hostnames will be added as "DNS" names in the "Subject Alternative Name"(SAN) field in your certificate.You should list every hostname and variant that people will use to connect toyour cluster over http.Do not list IP addresses here, you will be asked to enter them later.
If you wish to use a wildcard certificate (for example *.es.example.com) youcan enter that here.
Enter all the hostnames that you need, one per line.####################################################### 输入需连接集群节点主机名信息,一行输入一个IP地址,空行回车结束 #######################################################When you are done, press <ENTER> once more to move on to the next step.
es01es02es03
You entered the following hostnames.
- es01 - es02 - es03
##################################################### 确认以上是否为正确的配置,输入 Y 表示信息正确 #####################################################Is this correct [Y/n]Y
## Which IP addresses will be used to connect to your nodes?If your clients will ever connect to your nodes by numeric IP address, then youcan list these as valid IP "Subject Alternative Name" (SAN) fields in yourcertificate.
If you do not have fixed IP addresses, or not wish to support direct IP accessto your cluster then you can just press <ENTER> to skip this step.
Enter all the IP addresses that you need, one per line.##################################################### 输入需连接集群节点IP信息,一行输入一个IP地址,空行回车结束 #####################################################When you are done, press <ENTER> once more to move on to the next step.
172.28.54.213172.28.54.214172.28.54.215
You entered the following IP addresses.
- 172.28.54.213 - 172.28.54.214 - 172.28.54.215
##################################################### 确认以上是否为正确的配置,输入 Y 表示信息正确 #####################################################Is this correct [Y/n]Y
## Other certificate optionsThe generated certificate will have the following additional configurationvalues. These values have been selected based on a combination of theinformation you have provided above and secure defaults. You should not need tochange these values unless you have specific requirements.
Key Name: es01Subject DN: CN=es01Key Size: 2048
##################################################### 是否要更改以上这些选项,选择 N ,不更改证书选项配置 #####################################################Do you wish to change any of these options? [y/N]N
## What password do you want for your private key(s)?
Your private key(s) will be stored in a PKCS#12 keystore file named "http.p12".This type of keystore is always password protected, but it is possible to use ablank password.
##################################################### 是否要给证书加密,不需要加密,两次 回车 即可 #####################################################If you wish to use a blank password, simply press <enter> at the prompt below.Provide a password for the "http.p12" file: [<ENTER> for none]
## Where should we save the generated files?A number of files will be generated including your private key(s),public certificate(s), and sample configuration options for Elastic Stack products.These files will be included in a single zip archive.What filename should be used for the output zip file? [/opt/module/elasticsearch-8.3.2/elasticsearch-ssl-http.zip] Zip file written to /opt/module/elasticsearch-8.3.2/elasticsearch-ssl-http.zipxxxxxxxxxx# 解压[wangting@es01 bin]$ cd /opt/module/elasticsearch-8.3.2/[wangting@es01 elasticsearch-8.3.2]$ unzip elasticsearch-ssl-http.zip # 移动证书[wangting@es01 elasticsearch-8.3.2]$ mv ./elasticsearch/http.p12 config/certs/[wangting@es01 elasticsearch-8.3.2]$ mv ./kibana/elasticsearch-ca.pem config/certs/
# 将证书分发到其他节点02 03[wangting@es01 elasticsearch-8.3.2]$ cd /opt/module/elasticsearch-8.3.2/config/certs[wangting@es01 certs]$ lltotal 16-rw------- 1 wangting wangting 3596 Feb 10 16:05 elastic-certificates.p12-rw-rw-r-- 1 wangting wangting 1200 Feb 10 16:13 elasticsearch-ca.pem-rw------- 1 wangting wangting 2672 Feb 10 16:03 elastic-stack-ca.p12-rw-rw-r-- 1 wangting wangting 3652 Feb 10 16:13 http.p12[wangting@es01 certs]$ scp * es02:/opt/module/elasticsearch-8.3.2/config/certs/[wangting@es01 certs]$ scp * es03:/opt/module/elasticsearch-8.3.2/config/certs/如果提示:-bash: unzip: command not found,使用yum安装即可
[wangting@es01 elasticsearch-8.3.2]$ sudo yum install -y unzip
xxxxxxxxxx[wangting@es01 certs]$ cd /opt/module/elasticsearch-8.3.2/config/[wangting@es01 config]$ vim elasticsearch.yml cluster.name: bigdata-esnode.name: es-es01path.data: /opt/module/elasticsearch-8.3.2/datapath.logs: /opt/module/elasticsearch-8.3.2/logsnetwork.host: 0.0.0.0http.port: 9200discovery.seed_hosts: ["es01"]cluster.initial_master_nodes: ["es-es01", "es-es02","es-es03"]xpack.security.enabled: truexpack.security.enrollment.enabled: truexpack.security.http.ssl: enabled: true keystore.path: /opt/module/elasticsearch-8.3.2/config/certs/http.p12 truststore.path: /opt/module/elasticsearch-8.3.2/config/certs/http.p12xpack.security.transport.ssl: enabled: true verification_mode: certificate keystore.path: /opt/module/elasticsearch-8.3.2/config/certs/elastic-certificates.p12 truststore.path: /opt/module/elasticsearch-8.3.2/config/certs/elastic-certificates.p12http.host: [_local_, _site_]ingest.geoip.downloader.enabled: falsexpack.security.http.ssl.client_authentication: none【注意】:
xpack.security.http.ssl & xpack.security.transport.ssl后的子配置需要空一格,遵循yml的格式要求
如果不需要后续的http证书认证或者用户密码认证可以将xpack.security相关的功能falase关闭掉
xxxxxxxxxxxpack.security.http.sslenabledfalsexpack.security.transport.sslenabledfalse
有些业务使用场景中,可能会遇到跨域问题,当elasticsearch需要涉及到跨域问题时,可以在配置文件中最后增加配置:
xxxxxxxxxxhttp.cors.enabledtruehttp.cors.allow-origin"*"
xxxxxxxxxx[wangting@es01 elasticsearch-8.3.2]$ scp config/elasticsearch.yml es02:/opt/module/elasticsearch-8.3.2/config/[wangting@es01 elasticsearch-8.3.2]$ scp config/elasticsearch.yml es03:/opt/module/elasticsearch-8.3.2/config/
# es02修改 config/elasticsearch.yml[wangting@es02 ~]# vim /opt/module/elasticsearch-8.3.2/config/elasticsearch.yml # 设置节点名称node.name: es-es02
# es03修改 config/elasticsearch.yml[wangting@es03 ~]# vim /opt/module/elasticsearch-8.3.2/config/elasticsearch.yml # 设置节点名称node.name: es-es03每台节点依次启动(无顺序要求,只要多于2台,就可以启动集群,这就是es的无主模式,自动识别集群,选举master):
xxxxxxxxxx[wangting@es01 elasticsearch-8.3.2]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch -d[wangting@es02 elasticsearch-8.3.2]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch -d[wangting@es03 elasticsearch-8.3.2]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch -d登录网页,都与之前的密码一致:elastic/bigdata
【注意】
如果不留神使用root修改过目录下文件,则文件权限会变成root所属主,所以需要修改回普通用户
sudo chown -R wangting.wangting /opt/module/
ES服务启动后有2个端口
- 9200为客户端访问es的http协议RESTFUL端口
- 9300为ES集群之间组件的通信端口
xxxxxxxxxx# 手工指定elastic的新密码 (-i参数)[wangting@es01 ~]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch-reset-password -u elastic -iwarning: ignoring JAVA_HOME=/opt/module/elasticsearch-8.3.2/jdk; using bundled JDKbThis tool will reset the password of the [elastic] user.You will be prompted to enter the password.Please confirm that you would like to continue [y/N]y Did not understand answer 'by'Please confirm that you would like to continue [y/N]y
Enter password for [elastic]: # 输入用户elastic的密码Re-enter password for [elastic]: # 输入用户elastic的密码Password for the [elastic] user successfully reset.xxxxxxxxxx# 也可以不加-i参数让系统随机给个字符串密码,但是很难记住,很少使用# 为elastic账号自动生成新的随机密码,输出至控制台;不加参数[wangting@es01 ~]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch-reset-password -u elastic
https://ip:9200 (注意是https)
账号密码为上面创建的:elastic / elastic的密码

-

xxxxxxxxxx[wangting@es01 ~]$ /opt/module/elasticsearch-8.3.2/bin/elasticsearch -d【注意】:
- -d 为后台运行,不加-d只能前台运行,关了会话窗口服务也会同时终止
- 3台机器都需要启动elasticsearch
- 运行日志没有配置定义,默认在服务目录下:elasticsearch-8.3.2/logs/ ,有异常可以先查看日志
xxxxxxxxxx[wangting@es01 ~]$ ps -ef | grep elasticsearch|grep -vE "grep|controller" |awk -F" " '{print $2}' | xargs kill -9xxxxxxxxxx# 需先配置免密登录[wangting@es01 ~]$ ssh-keygen -t rsa[wangting@es01 ~]$ ssh-copy-id es01[wangting@es01 ~]$ ssh-copy-id es02[wangting@es01 ~]$ ssh-copy-id es03
# 编写脚本[wangting@es01 ~]$ vim my_es.shif (($#==0)); then echo -e "请输入参数:\n start 启动elasticsearch集群;\n stop 停止elasticsearch集群;\n" && exitfi
case $1 in "start") for host in es01 es02 es03 do echo "---------- $1 $host 的elasticsearch ----------" ssh $host "/opt/module/elasticsearch-8.3.2/bin/elasticsearch -d >/dev/null 2>&1" done ;; "stop") for host in es01 es02 es03 do echo "---------- $1 $host 的elasticsearch ----------" ssh $host "ps -ef | grep elasticsearch|grep -v grep|grep -v controller |awk '{print $2}' | xargs kill -9" > /dev/null 2>&1 done ;; *) echo -e "---------- 请输入正确的参数 ----------\n" echo -e "start 启动elasticsearch集群;\n stop 停止elasticsearch集群;\n" && exit ;;esac启动集群:
等待脚本执行结束
xxxxxxxxxx[wangting@es01 ~]$ bash my_es.sh start停止集群:
xxxxxxxxxx[wangting@es01 ~]$ bash my_es.sh stop