cfanbo / cfanbo.github.io

1 stars 0 forks source link

sphinx分布式索引简介 | 学习笔记 #215

Open cfanbo opened 1 year ago

cfanbo commented 1 year ago

https://blog.haohtml.com/archives/13724/

sphinx分布式索引原理: 当searchd收到一个对分布式索引的查询时,它做如下操作: 连接到远程代理 执行查询 (在远程代理执行搜索的同时)对本地索引进行查询 接收来自远程代理的搜索结果 将所有结果合并,删除重复项 将合并后的结果返回给客户端 在应用程序看来,普通索引和分布式索引完全没有区别。 任一个searchd实例可以同时做为主控端(master,对搜索结果做聚合)和从属端(只做本地 搜索)。这有如下几点好处: 集群中的每台机器都可以做为主控端来搜索整个集群,搜索请求可以在主控端之间获 得负载平衡,相当于实现了一种HA(high availability,高可用性),可以应对某个 节点失效的情况。 如果在单台多CPU或多核机器上使用,一个做为代理对本机进行搜索的searchd实例 就可以利用到全部的CPU或者核。 更好的HA支持已在计划之中,到时将允许指定哪些代理之间互相备份、有效性检查、跟踪 运行中的代理、对检索请求进行负载均衡,等等。 sphinx分布式索引配置: index dist1 { local index to be searched there can be many local indexes configured local = test1 local = test1stemmed remote agent multiple remote agents may be specified syntax for TCP connections is ‘hostname:port:index1,[index2[,…]]’ syntax for local UNIX connections is ‘/path/to/socket:index1,[index2[,…]]’ agent = localhost:9313:remote1 agent = localhost:9314:remote2,remote3 agent = /var/run/searchd.