ES部署
安装包版本:elasticsearch-7.10.1
JDK版本:jdk17
1、环境准备
建立安装目录,解压安装包
mkdir /opt/ela
ar xf elasticsearch-7.10.1-linux-x86_64.tar.gz -C /opt/ela/
mv /opt/ela/elasticsearch-7.10.1/ /opt/ela/ela-7.10
mkdir /opt/ela/ela-7.10/tmp 临时目录
配置java环境
tar xf jdk-17_linux-x64_bin.tar.gz -C /opt/ela/ela-7.10/ 解压jdk包
mv /opt/ela/jdk-17.0.1/ /opt/ela/jdk17
vim /opt/ela/ela-7.10/bin/elasticsearch-env 编辑配置文件
# now set the path to java 找到这行下修改
JAVA_HOME=$ES_HOME/jdk1.8 配置JDK路径
ES_TMPDIR=$ES_HOME/tmp 配置生成临时文件的目录
建立ela用户,设置属主属组
useradd ela
chown -R ela:ela /opt/ela/
配置elasticsearch.yml文件
vim /opt/ela/ela-7.10/config/elasticsearch.yml
集群名称
cluster.name: ela-cluster
节点名称,可设置为${hostname},使用主机名作为节点名称
node.name: node-1
数据文件目录
path.data: /opt/ela/ela-7.10/data
日志文件目录
path.logs: /opt/ela/ela-7.10/logs
本机ip
network.host: 192.168.88.142
http服务端口
http.port: 19200
集群节点间通信和提供JAVA访问的端口
transport.tcp.port: 19300
单节点实例
discovery.type: single-node
配置jvm.options文件
vim /opt/ela/ela-7.10/config/jvm.options
一般只需要配置xms和xmx即可,配置的大小不要超过服务器内存总数的50%,要保留充分的内存给system本身的cache,两个值大小应设置为一致
-Xms1g
-Xmx1g
启动单实例ES
注意使用ela用户启动,注意,不能使用root用户,否则会报错
su ela
/opt/ela/ela-7.10/bin/elasticsearch -d
访问ES
[ela@es-1 ES]$ curl -XGET http://192.168.88.142:19200/
{
"name" : "node-1",
"cluster_name" : "ela-cluster",
"cluster_uuid" : "DHa29Jf5Qla0K99pXuz1Lw",
"version" : {
"number" : "7.10.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
"build_date" : "2020-12-05T01:00:33.671820Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
单实例部署成功
ip | 节点名称 |
---|---|
192.168.88.142 | node1 |
192.168.88.143 | node2 |
192.168.88.144 | node3 |
配置elasticsearch.yml文件
vim /opt/ela/ela-7.10/config/elasticsearch.yml
修改elasticsearch.yml以下配置,修改成本机节点名称、ip
node.name: node2
network.host: 192.168.88.143
列出作为master候补的节点列表,注意逗号后加空格,否则集群启动不成功
discovery.seed_hosts: ["192.168.88.142", "192.168.88.143", "192.168.88.144"]
配置初始节点的node.name列表,仅在第一次启动时使用,启动成功后删除,注意主机名称不要有-,因为文件不识别,相应要修改node.name的名称,与之对应
cluster.initial_master_nodes: ["node1", "node2", "node3"]
做好系统相关调优
vim /etc/security/limits.conf
* soft nofile 65535"
* hard nofile 65535"
vim /etc/sysctl.conf
vm.max_map_count=262144
将应用目录传送到其他2台上,注意清空ela-7.10/data下的所有内容
启动集群
/opt/ela/ela-7.10/bin/elasticsearch -d
查看集群状态
curl -XGET http://192.168.88.142:19200/_cluster/health?pretty
{
"cluster_name" : "ela-cluster",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
number_of_nodes及number_of_data_nodes显示为3个,表明集群搭建成功