本文共 3939 字,大约阅读时间需要 13 分钟。
团队新采购一批大内存
服务器作为Elasticsaerch
节点。根据ES官网文档,单机单实例最多不超64G内存,这批服务器用于单机单实例有些"大材小用" .由于之前用docker
做ES集群碰到过坑, 所以这次采用实体跑多实例的方案。
ES单机多实例有两种情况,一种为单集群多实例,另外一种为多集群多实例。 本篇主要介绍单机多集群多实例的情况。
由于大多节点配置等信息都雷同,本文用两台服务器做为示例
需求架构图
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
initial_master_nodes
.cluster.routing.allocation.same_shard.host
防止一台主机存在多个相同切片.node.max_local_storage_nodes
配置一台主机可以存在的实例数量.转载于:https://blog.51cto.com/maoyao/2400596