ELK(二)elasticsearch进阶集群

倒排索引

由属性值来确定记录的位置,因而称为倒排索引(类似hadoop统计单词个数,加入了单词出现的文档编号和频率)

elasticsearch的全文搜索支持相似度及权重配置(略)

Elasticsearch集群

通过cluster.name设置集群名称,每个节点通过node.name指定节点的名称。

节点的类型主要有4种:

  • master节点

配置文件中node.master属性为true(默认为true),就有资格被选为master节点。
master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等。

  • data节点

配置文件中node.data属性为true(默认为true),就有资格被设置成data节点。
data节点主要用于执行数据相关的操作。比如文档的CRUD。

  • 客户端节点

配置文件中node.master属性和node.data属性均为false。不能作为master节点,也不能作为data节点。
可以作为客户端节点,用于响应用户的请求,把请求转发到其他节点

  • 部落节点

当一个节点配置tribe.*的时候,它是一个特殊的客户端,它可以连接多个集群,在所有连接的集群上执
行搜索和其他操作。

 

集群搭建

mkdir -p /haoke/es-cluster/node01
docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml /root/elasticsearch.yml
cp elasticsearch.yml /haoke/es-cluster/node01/elasticsearch.yml
docker cp elasticsearch:/usr/share/elasticsearch/config/jvm.options /root/jvm.options
cp jvm.options /haoke/es-cluster/node01/jvm.options
vi /haoke/es-cluster/node01/elasticsearch.yml
(minimum_master_nodes,官方推荐:(N/2)+1,N为集群中节点数)

cluster.name: es-itcast-cluster
network.host: 0.0.0.0
network.publish_host: 172.26.10.222
node.name: node01
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["172.26.10.222:9300","172.26.10.223:9300"]
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"

chmod 777 node01/
mkdir -p /haoke/es-cluster/node01/data
chmod 777 /haoke/es-cluster/node01/data

复制一份虚拟机
cp node01 node02
chmod 777 node02/
rm -rf node02/data
mkdir -p /haoke/es-cluster/node02/data
chmod 777 /haoke/es-cluster/node02/data
vi /haoke/es-cluster/node02/elasticsearch.yml

cluster.name: es-itcast-cluster
network.host: 0.0.0.0
network.publish_host: 172.26.10.223
node.name: node02
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["172.26.10.222:9300","172.26.10.223:9300"]
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"

#创建容器
docker create --name es-node01 --net host \
-v /haoke/es-cluster/node01/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /haoke/es-cluster/node01/jvm.options:/usr/share/elasticsearch/config/jvm.options \
-v /haoke/es-cluster/node01/data:/usr/share/elasticsearch/data elasticsearch:6.5.4

docker create --name es-node02 --net host \
-v /haoke/es-cluster/node02/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /haoke/es-cluster/node02/jvm.options:/usr/share/elasticsearch/config/jvm.options \
-v /haoke/es-cluster/node02/data:/usr/share/elasticsearch/data elasticsearch:6.5.4

#启动容器
--docker start es-node01 && docker logs -f es-node01
--docker start es-node02 && docker logs -f es-node02


报错:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least
vi /etc/sysctl.conf 
vm.max_map_count=655360
sysctl -p
docker start es-node01 && docker logs -f es-node01
docker start es-node02 && docker logs -f es-node02

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值