首页 > 其他分享 >安装ES8.6.1集群

安装ES8.6.1集群

时间:2023-03-08 12:00:55浏览次数:53  
标签:8.6 local ES8.6 elasticsearch usr 集群 安装 172.21 es

环境

服务器IP 节点ID 端口 集群名称
172.21.61.10 es-1 9200/9700 es-test
172.21.61.11 es-2 9200/9700 es-test
172.21.61.12 es-3 9200/9700 es-test

安装

下载安装包

cd /root/soft
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.1-linux-x86_64.tar.gz
scp elasticsearch-8.6.1-linux-x86_64.tar.gz 172.21.61.11:/root/soft
scp elasticsearch-8.6.1-linux-x86_64.tar.gz 172.21.61.12:/root/soft

所有节点创建用户

groupadd elasticsearch
useradd elasticsearch -g elasticsearch

创建目录

所有节点执行如下步骤
mkdir /data/es/{logs,data} -p
tar xzvf elasticsearch-8.6.1-linux-x86_64.tar.gz -C /usr/local

授权

所有节点执行如下步骤
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-8.6.1
chown -R elasticsearch:elasticsearch /data/es

配置修改

172.21.61.10修改内容

vim /usr/local/elasticsearch-8.6.1/config/elasticsearch.yml

点击查看代码
cluster.name: es-test
node.name: es-1
node.roles: [master,data]
path.data: /data/es/data
path.logs: /data/es/logs
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.21.61.10:9300","172.21.61.11:9300","172.21.61.12:9300"]
cluster.initial_master_nodes: ["es-1","es-2","es-3"]
# 下方内容是用于ssl认证的
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: none
xpack.security.transport.ssl.keystore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false

172.21.61.11修改内容

vim /usr/local/elasticsearch-8.6.1/config/elasticsearch.yml

点击查看代码
cluster.name: es-test
node.name: es-2
node.roles: [master,data]
path.data: /data/es/data
path.logs: /data/es/logs
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.21.61.10:9300","172.21.61.11:9300","172.21.61.12:9300"]
cluster.initial_master_nodes: ["es-1","es-2","es-3"]
# 下方内容是用于ssl认证的
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: none
xpack.security.transport.ssl.keystore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false

172.21.61.13修改内容

vim /usr/local/elasticsearch-8.6.1/config/elasticsearch.yml

点击查看代码
cluster.name: es-test
node.name: es-3
node.roles: [master,data]
path.data: /data/es/data
path.logs: /data/es/logs
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.21.61.10:9300","172.21.61.11:9300","172.21.61.12:9300"]
cluster.initial_master_nodes: ["es-1","es-2","es-3"]
# 下方内容是用于ssl认证的
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: none
xpack.security.transport.ssl.keystore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /usr/local/elasticsearch-8.6.1/config/certs/elastic-certificates.p12
ingest.geoip.downloader.enabled: false

环境配置

所有节点都需要修改

修改最大文件数

点击查看代码
cat >> /etc/security/limits.conf <<EOF
elasticsearch soft nofile 65536
elasticsearch hard nofile 65536
EOF

修改系统内核配置

点击查看代码
echo "fs.file-max=655360" >> /etc/sysctl.conf
echo "vm.max_map_count=655360" >> /etc/sysctl.conf
sysctl -p

修改虚拟内存

点击查看代码
# 此处根据自己的需求及规模进行调整
sed -i "s/## -Xms4g/-Xms2g/" /usr/local/elasticsearch-8.6.1/config/jvm.options
sed -i "s/## -Xmx4g/-Xmx2g/" /usr/local/elasticsearch-8.6.1/config/jvm.options

认证

在172.21.61.10上面操作就行

点击查看代码
# 签发ca证书
/usr/local/elasticsearch-8.6.1/bin/elasticsearch-certutil ca 
`【ENTER】`   什么也不用输入直接回车
`【ENTER】`   什么也不用输入直接回车
 
# 用ca证书签发节点证书
/usr/local/elasticsearch-8.6.1/bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12  
`【ENTER】`   什么也不用输入直接回车
`【ENTER】`   什么也不用输入直接回车
`【ENTER】`   什么也不用输入直接回车
 
# 将证书放到certs目录(手动创建)
mkdir /usr/local/elasticsearch-8.6.1/config/certs 
mv /usr/local/elasticsearch-8.6.1/elastic-certificates.p12  /usr/local/elasticsearch-8.6.1/elastic-stack-ca.p12 /usr/local/elasticsearch-8.6.1/config/certs 
scp -r /usr/local/elasticsearch-8.6.1/config/certs 172.21.61.11:/usr/local/elasticsearch-8.6.1/config/
scp -r /usr/local/elasticsearch-8.6.1/config/certs 172.21.61.12:/usr/local/elasticsearch-8.6.1/config/

ik分词插件安装

cd /root/soft
mkdir ik
cd ik
需要下载与es版本一致的ik分词版本包
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.6.1/elasticsearch-analysis-ik-8.6.1.zip
unzip elasticsearch-analysis-ik-8.6.1.zip
rm -f elasticsearch-analysis-ik-8.6.1.zip
cd ..
cp -r ik /usr/local/elasticsearch-8.6.1/plugins/
将插件复制到其余节点
scp -r /usr/local/elasticsearch-8.6.1/plugins/ik 172.21.61.11:/usr/local/elasticsearch-8.6.1/plugins/
scp -r /usr/local/elasticsearch-8.6.1/plugins/ik 172.21.61.12:/usr/local/elasticsearch-8.6.1/plugins/
每台服务器授权
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-8.6.1

启动

切换用户

su - elasticsearch
cd /usr/local/elasticsearch-8.6.1/bin
./elasticsearch -d
查看端口是否启动
netstat -lanp | egrep "9200|9300" | grep LISTEN

修改密码:

在某一台服务器上操作即可

点击查看代码
# 第一种,配置每个账号的密码
./elasticsearch-setup-passwords interactive
******************************************************************************
Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This       command will be removed in a future release.
******************************************************************************
 
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
 
 
Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
 
# 第二种,随机生成特定账号的密码
./elasticsearch-reset-password -u elastic
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y
 
 
Password for the [elastic] user successfully reset.
New value: ihn1eUl0-cSGQ2ekMBTj

常用查看

查看集群状态

点击查看代码
curl -k --user elastic:ihn1eUl0-cSGQ2ekMBTj -XGET  "http://172.21.61.10:9200/_cat/nodes?v"
# 此处ip不是172.21.61..x是因为我的服务器还有其他服务开启了tun的。
ip             heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.21.61.10           41          97   4    0.70    0.54     0.33 dm        *      es-1
172.21.61.11             28          97   4    0.15    0.30     0.41 dm        -      es-2
172.21.61.12             24          97   4    0.27    0.46     0.53 dm        -      es-3

列出所有索引

点击查看代码
curl -k --user elastic:ihn1eUl0-cSGQ2ekMBTj -XGET  "http://172.21.61.10:9200/_cat/indices?v"
 
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

创建并查看索引

点击查看代码
curl -k --user elastic:ihn1eUl0-cSGQ2ekMBTj -X PUT "http://172.21.61.10:9200/test?pretty"
 
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "test"
}
 
curl -k --user elastic:ihn1eUl0-cSGQ2ekMBTj -XGET  "http://172.21.61.10:9200/_cat/indices?v"
 
health status index uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   test  N89aJeQsTpiBtbDLh-I1pQ   1   1          0            0       450b           225b

登陆网页查看是否正常

http://172.21.61.10:9200

标签:8.6,local,ES8.6,elasticsearch,usr,集群,安装,172.21,es
From: https://www.cnblogs.com/chunjeh/p/17191559.html

相关文章

  • linux php安装gd扩展
    第一步:首先可以利用find/-namephp.ini查找一下,系统是否有php的配置文件,找到自己mysql的安装目录第二步:找到mysql的解压目录,cd apcache/php-5.6.33/ext/gd这是我的目......
  • Maven安装与配置
    Maven安装与配置下载安装下载地址:https://maven.apache.org/download.cgi下载后解压配置环境变量配置MAVEN_HOME配置Path变量win+R运行cmd,输入mvn-versio......
  • 使用TestFlight安装ios SwichBot的测试版本
    一、版本链接https://testflight.apple.com/join/1UYD4l6X二、获取TestFlightApp在链接里点击第一步下面的按钮,跳转到TestFlight下载。 下载完毕后,回到链接。......
  • 乐固加固、360加固后安装不了问题。
    腾讯云应用安全已在加固过程中删除签名信息,加固后的安装包需要重新签名。同样近期360加固助手签名设置也需要购买高级加固服务。在进行加固后我们需要手动签名cmd手动签名......
  • VMware安装教程及步骤
    一、安装VMware虚拟机注意:一次只能安装一个VMwareWorkstation版本。在安装新版本之前,必须卸载任何之前版本的VMwareWorkstation。1、下载VMware链接:https:/......
  • 1.VMware安装
    1.VMware安装1.版本选择安装rhel8版本需要Vmware版本在15版本以上,否则会出现不兼容。2.创建虚拟机"创建新的虚拟机","典型配置","稍后安装操作系统","选择对应版本的操作......
  • toncat安装
    第一步下载 1.进入官网ApacheTomcat®-Welcome!,在左侧中的Download找到自己需要的Tomcat版本 2.本文选择了64位的Windowszip版本,这个可以根据需求选择不同的版......
  • Tomcat安装及配置教程
     java环境的配置 1java环境的配置应该都学过吧,这里简单的讲一下。下载安装javaJDK,注意安装的路径,我们需要进行环境变量的配置。2安装完成以后,配置......
  • luffy登录注册页面 redis介绍安装 redis普通连接与连接池 redis数据类型 redis字符串
    目录回顾登录页面分析代码登录页面注册页面Redis介绍与安装介绍:面试题:redis为什么这么快?安装安装目录启动客户端连接Redis普通连接和连接池普通连接连接池连接传统方案连接......
  • Windows下Redis的安装和使用
    一、下载1.要安装Redis,首先要获取安装包。Windows的Redis安装包需要到以下GitHub链接找到。链接:https://github.com/tporadowski/redis/releases。打开网站后,找到Release......