沉沙
2019-05-30
来源 :
阅读 1797
评论 0
摘要:本篇文章探讨了大数据技术之Elasticsearch单机多实例,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。
本篇文章探讨了大数据技术之Elasticsearch单机多实例,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。

团队新采购一批大内存服务器作为Elasticsaerch节点。根据ES官网文档,单机单实例最多不超64G内存,这批服务器用于单机单实例有些""大材小用"" .由于之前用docker做ES集群碰到过坑, 所以这次采用实体跑多实例的方案。
ES单机多实例有两种情况,一种为单集群多实例,另外一种为多集群多实例。 本篇主要介绍单机多集群多实例的情况。
由于大多节点配置等信息都雷同,本文用两台服务器做为示例
需求架构图
node1,node2
curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm rpm -ivh elasticsearch-7.0.0-x86_64.rpm
node1,node2
mkdir -p /data/elasticsearch/{t2,t1}/{data,repo,log}chown elasticsearch. elasticsearch/ -Rnode1,node2
cd /etc/ cp -avP elasticsearch/ t1es/ cp -avP elasticsearch/ t2es/
node1
/etc/t2es/elasticsearch.yml
cluster: name: t2es routing: allocation: same_shard.host: true initial_master_nodes: - t2-node-70 - t2-node-71 - ... node: name: t2-node-70 master: true data: true max_local_storage_nodes: 2path: data: /data/elasticsearch/t2/data logs: /data/elasticsearch/t2/log repo: /data/elasticsearch/t2/repo network: host: t2-node-70http: port: 9200transport.tcp.port: 9300discovery.zen.ping.unicast.hosts: [""t2-node-70:9300"",""t2-node-71:9300"" ...] discovery.zen.fd.ping_timeout: ""10s""discovery.zen.fd.ping_retries: 10reindex.remote.whitelist: ""192.168.1.*:*""
/etc/t1es/elasticsearch.yml
cluster: name: t1es routing: allocation: same_shard.host: true initial_master_nodes: - t1-node-70 - t1-node-71 - ... node: name: t1-node-70 master: true data: true max_local_storage_nodes: 2path: data: /data/elasticsearch/t1/data logs: /data/elasticsearch/t1/log repo: /data/elasticsearch/t1/repo network: host: t1-node-70http: port: 9201transport.tcp.port: 9301discovery.zen.ping.unicast.hosts: [""t1-node-70:9301"",""t1-node-71:9301"" ...] discovery.zen.fd.ping_timeout: ""10s""discovery.zen.fd.ping_retries: 10reindex.remote.whitelist: ""192.168.1.*:*""
node2
/etc/t2es/elasticsearch.yml
...network: host: t1-node-70http: port: 9201transport.tcp.port: 9301...
/etc/t1es/elasticsearch.yml
...network: host: t1-node-70http: port: 9201transport.tcp.port: 9301...
node1,node2
cd /usr/lib/systemd/system cp -avp elasticsearch.service t2es.servicecd /etc/sysconfig cp -avp cp -avP elasticsearch t2es cp -avp cp -avP elasticsearch t1es
node1,node2
/usr/lib/systemd/system/t2es
[Unit]Description=t2-ElasticsearchDocumentation=//www.elastic.coWants=network-online.targetAfter=network-online.target[Service]RuntimeDirectory=elasticsearchPrivateTmp=trueEnvironment=ES_HOME=/usr/share/elasticsearchEnvironment=ES_PATH_CONF=/etc/t2esEnvironment=PID_DIR=/var/run/elasticsearchEnvironment=ENV_PATH=/etc/sysconfig/t2es
# EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/usr/share/elasticsearchUser=elasticsearchGroup=elasticsearchExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/t2es.pid --quietStandardError=inheritLimitNOFILE=65535LimitNPROC=4096LimitAS=infinityLimitFSIZE=infinityTimeoutStopSec=0KillSignal=SIGTERMKillMode=processSendSIGKILL=noSuccessExitStatus=143[Install]WantedBy=multi-user.target/usr/lib/systemd/system/t1es
...
Environment=ES_PATH_CONF=/etc/t2es
Environment=PID_DIR=/var/run/elasticsearch
Environment=ENV_PATH=/etc/sysconfig/t2es
# EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/usr/share/elasticsearch
User=elasticsearch
Group=elasticsearch
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/t2es.pid --quiet
...编辑/usr/share/elasticsearch/bin/elasticsearch-env
修改 source /etc/sysconfig/elasticsearch
if [ ! -z ${ENV_PATH} ]then source ${ENV_PATH} else source /etc/sysconfig/elasticsearchfi/etc/sysconfig/t2es
所有参数配置可以在这里面加
ES_PATH_CONF=/etc/t2esES_STARTUP_SLEEP_TIME=5
node1,node2
systemctl t1es startsystemctl t2es start
Elasticsearch 7.x系列需要配置initial_master_nodes.
cluster.routing.allocation.same_shard.host防止一台主机存在多个相同切片.
node.max_local_storage_nodes配置一台主机可以存在的实例数量.
"
本文由职坐标整理发布,学习更多的相关知识,请关注职坐标IT知识库!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号