博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Elasticsearch单机多实例
阅读量:6513 次
发布时间:2019-06-24

本文共 3939 字,大约阅读时间需要 13 分钟。

前言

团队新采购一批大内存服务器作为Elasticsaerch节点。根据ES官网文档,单机单实例最多不超64G内存,这批服务器用于单机单实例有些"大材小用" .由于之前用docker做ES集群碰到过坑, 所以这次采用实体跑多实例的方案。

环境

ES单机多实例有两种情况,一种为单集群多实例,另外一种为多集群多实例。 本篇主要介绍单机多集群多实例的情况。

由于大多节点配置等信息都雷同,本文用两台服务器做为示例

需求架构图

es.png

部署过程

下载

node1,node2

curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpmrpm -ivh elasticsearch-7.0.0-x86_64.rpm

创建目录

node1,node2

mkdir -p /data/elasticsearch/{t2,t1}/{data,repo,log}chown elasticsearch. elasticsearch/ -R

拷贝配置文件

node1,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/reponetwork:    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/reponetwork:    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/systemcp -avp elasticsearch.service  t2es.servicecd /etc/sysconfigcp -avp cp -avP elasticsearch  t2escp -avp cp -avP elasticsearch  t1es

修改启动服务配置

node1,node2

/usr/lib/systemd/system/t2es

[Unit]Description=t2-ElasticsearchDocumentation=http://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/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 --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配置一台主机可以存在的实例数量.

转载于:https://blog.51cto.com/maoyao/2400596

你可能感兴趣的文章
应用程序框架实战三十四:数据传输对象(DTO)介绍及各类型实体比较(转)
查看>>
放量滞涨,抛出信号
查看>>
windows 下配置 Nginx 常见问题(转)
查看>>
BeanFactory not initialized or already closed - call 'refresh' before accessing beans解决办法
查看>>
dSYM 文件分析工具
查看>>
R语言合并data.frame
查看>>
2015第17周二
查看>>
linux主机下的Vmware Workstation配置NAT设置 端口映射-Ubuntu为例
查看>>
unity physics joint
查看>>
TD的访问地址
查看>>
JAVA常见面试题之Forward和Redirect的区别
查看>>
tmpFile.renameTo(classFile) failed 错误
查看>>
【甘道夫】Apache Hadoop 2.5.0-cdh5.2.0 HDFS Quotas 配额控制
查看>>
一张图看懂normal,static,sealed,abstract 的 区别
查看>>
Task的使用
查看>>
grep和正则表达式
查看>>
s:iterator巧妙控制跳出循环
查看>>
移动互联网思维
查看>>
自适应滤波:递归最小二乘
查看>>
redis-手写redis切片和非切片连接池并注入springboot中
查看>>