solr5.3.1 集群服务搭建
一. 安装部署
zookeeper集群部署:
节点:
10.1.12.51:2181 node1
10.1.12.52:2181 node2
10.1.12.53:2181 node3
最新稳定版下载地址(当前3.4.6):
http://mirrors.cnnic.cn/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz
各节点上解压zookeeper到/usr/local
|
1
2
3
|
tar xf /usr/local/src/zookeeper-3.4.6.tar.gz -C /usr/localcd /usr/localln -s zookeeper-3.4.6 zookeeper |
创建如下数据目录结构:
/data/zookeeper/
├── data
└── log
|
1
|
mkdir -p /data/zookeeper/{data,log} |
各节点配置zookeeper:
|
1
2
3
4
5
6
7
8
9
10
11
|
cd /usr/local/zookeeper/conf cp zoo_sample.cfg zoo.cfgvim zoo.cfg修改如下:tickTime=2000initLimit=10syncLimit=5dataDir=/data/zookeeper/dataclientPort=2181server.1=10.1.12.51:2888:3888server.2=10.1.12.52:2888:3888server.3=10.1.12.53:2888:3888 |
各节点的数据目录下添加唯一的node id标识
|
1
2
3
4
5
6
|
node1: echo 1>/data/zookeeper/data/myidnode2:echo 2>/data/zookeeper/data/myidnode3:echo 3>/data/zookeeper/data/myid |
各节点修改ZOO_LOG_DIR环境变量:
|
1
|
echo -e "\nZOO_LOG_DIR=/data/zookeeper/log" >> /usr/local/zookeeper/bin/zkEnv.sh |
各节点上启动zookeeper:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
/usr/local/zookeeper/bin/zkServer.sh start添加zookeeper的sysv服务脚本vim /etc/init.d/zookeeper#!/bin/bash## chkconfig: 345 30 70# description: Starts/Stops Apache Zookeeper export ZOO_HOME=/usr/local/zookeeperexport ZOO_BIN=$ZOO_HOME/binexport ZOO_SER_BIN=$ZOO_BIN/zkServer.sh $ZOO_SER_BIN $1 |
#------finish-------
|
1
2
3
|
chmod +x /etc/init.d/zookeeperchkconfig -add zookeeperchkconfig zookeeper on |
solrcloud部署(3分片2复制集):
节点:
10.1.12.51:8983 shard1-repl1 shard2-repl2
10.1.12.52:8983 shard2-repl1 shard3-repl2
10.1.12.53:8983 shard3-repl1 shard1-repl2

最新稳定版下载地址(当前5.3.1)
http://mirrors.cnnic.cn/apache/lucene/solr/5.3.1/solr-5.3.1.tgz
各节点解压安装操作:
|
1
2
3
|
cd /usr/local/srctar xzf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2./install_solr_service.sh solr-5.3.1.tgz -i /usr/local -d /data/solrcloud -u solr -s solr -p 8983 |
各节点solr服务配置修改:
1.调整jvm堆内存大小
|
1
|
echo 'SOLR_JAVA_MEM="-Xms10g -Xmx10g"' >> /data/solrcloud/solr.in.sh |
2.添加zookeeper
|
1
|
echo 'ZK_HOST=10.1.12.51:2181,10.1.12.52:2181,10.1.12.53:2181' >> /data/solrcloud/solr.in.sh |
3.添加solr依赖jar包
这里使用ik分词器,支持solr5.x版本下载地址为: https://github.com/EugenePig/ik-analyzer-solr5
|
1
2
3
|
cp ~/ik-analyzer-solr5-5.x.jar /usr/local/solr/server/solr-webapp/webapp/WEB-INF/libcp -n /usr/local/solr/dist/*.jar /usr/local/solr/server/solr-webapp/webapp/WEB-INF/libcp ~/mysql-connector-java-5.1.35.jar /usr/local/solr/server/lib |
4.重启solr服务
|
1
|
/etc/init.d/solr restart |
创建colletion(其中一个节点下操作即可)
|
1
2
|
su -c '/usr/local/solr/bin/solr create -c core_bingdu -d /opt/core_bingdu_conf -n core_bingdu -s 3 -rf 2 -port 8983' - solrsu -c '/usr/local/solr/bin/solr create -c core_bingdu_user -d /opt/core_bingdu_user_conf -n core_bingdu_user -s 3 -rf 2 -port 8983' - solr |
二. 集群操作
修改solr的collection配置后上传到zookeeper:
当前solr的collection配置副本存放在opt目录下
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@mongo-shard1-1 opt]# tree ..├── core_bingdu_conf│ ├── admin-extra.html│ ├── admin-extra.menu-bottom.html│ ├── admin-extra.menu-top.html│ ├── data-config.xml│ ├── dataimport.properties│ ├── _rest_managed.json│ ├── schema.xml│ └── solrconfig.xml└── core_bingdu_user_conf ├── admin-extra.html ├── admin-extra.menu-bottom.html ├── admin-extra.menu-top.html ├── data-config.xml ├── dataimport.properties ├── _rest_managed.json ├── schema.xml └── solrconfig.xml |
对以上配置文件进行修改后需要手动上传到zookeeper:
1)整个配置目录上传
|
1
2
3
|
cd /usr/local/solr/server/scripts/cloud-scripts./zkcli.sh -zkhost 10.1.12.51:2181 -cmd upconfig -confdir /opt/core_bingdu_conf -confname core_bingdu./zkcli.sh -zkhost 10.1.12.51:2181 -cmd upconfig -confdir /opt/core_bingdu_user_conf -confname core_bingdu_user |
2)单文件上传
|
1
2
|
./zkcli.sh -zkhost 10.1.12.51:2181 -cmd putfile /configs/core_bingdu/solrconfig.xml /opt/core_bingdu_conf/solrconfig.xml./zkcli.sh -zkhost 10.1.12.51:2181 -cmd putfile /configs/core_bingdu_user/solrconfig.xml /opt/core_bingdu_user_conf/solrconfig.xml |
三. solr 的一些常规操作:
基于命令:
<solr_install_dir>/bin/solr command [options...]
支持的command如下:
start, stop, restart, status, healthcheck, create, create_core, create_collection, delete
其中start,stop,restart,status操作已经封装到sysv风格的服务脚本中,例如重启solr服务:
|
1
|
/etc/init.d/solr restart |
检查solr集群各节点状态:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
[root@mongo-shard1-1 bin]# ./solr healthcheck -c core_bingdu -z 10.1.12.52:2181{ "collection":"core_bingdu", "status":"healthy", "numDocs":180900, "numShards":3, "shards":[ { "shard":"shard1", "status":"healthy", "replicas":[ { "name":"core_node2", "url":"http://10.1.12.51:8983/solr/core_bingdu_shard1_replica2/", "numDocs":60424, "status":"active", "uptime":"2 days, 17 hours, 13 minutes, 9 seconds", "memory":"3.4 GB (%36) of 9.6 GB", "leader":true}, { "name":"core_node5", "url":"http://10.1.12.53:8983/solr/core_bingdu_shard1_replica1/", "numDocs":60424, "status":"active", "uptime":"2 days, 16 hours, 58 minutes, 39 seconds", "memory":"2.2 GB (%22.5) of 9.6 GB"}]}, { "shard":"shard2", "status":"healthy", "replicas":[ { "name":"core_node3", "url":"http://10.1.12.52:8983/solr/core_bingdu_shard2_replica1/", "numDocs":59916, "status":"active", "uptime":"2 days, 17 hours, 14 minutes, 3 seconds", "memory":"3 GB (%31.1) of 9.6 GB", "leader":true}, { "name":"core_node6", "url":"http://10.1.12.53:8983/solr/core_bingdu_shard2_replica2/", "numDocs":59916, "status":"active", "uptime":"2 days, 16 hours, 58 minutes, 39 seconds", "memory":"2.2 GB (%22.5) of 9.6 GB"}]}, { "shard":"shard3", "status":"healthy", "replicas":[ { "name":"core_node1", "url":"http://10.1.12.51:8983/solr/core_bingdu_shard3_replica1/", "numDocs":60560, "status":"active", "uptime":"2 days, 17 hours, 13 minutes, 9 seconds", "memory":"3.5 GB (%36) of 9.6 GB"}, { "name":"core_node4", "url":"http://10.1.12.52:8983/solr/core_bingdu_shard3_replica2/", "numDocs":60560, "status":"active", "uptime":"2 days, 17 hours, 14 minutes, 3 seconds", "memory":"3 GB (%31.2) of 9.6 GB", "leader":true}]}]} |
创建集合:
|
1
|
bin/solr create -c core_bingdu -d /opt/core_bingdu_conf -n core_bingdu -s 3 -rf 2 -port 8983 |
这里说明一下选项:
-c: 指定集合或core名称(对于单实例模式的solr,colletion和core的意思基本相同,集群模式下,colletion等于每个shard下对应的core的集合)
-d:指定本地的solr配置目录(一个临时目录,用于存放solr配置文件,如solrconfig.xml,schema.xml),每次该目录的配置发生修改都需要手动上传到zookeeper的/configs目录节点下
-n: 指定zookeeper的/configs目录节点下创建的子目录节点名称,这里为/configs/core_bingdu
-s: 指定对应集合的分片数, 指定分片数后solr会根据各个节点上的负载在其上创建分片
-rf: 指定每个shard创建多少个复制节点
-port: 指定solr服务端口,不指定默认为8983
删除集合:
|
1
|
bin/solr delete -c core_bingdu |
基于solr api方式的操作:
创建集合:
|
1
|
http://localhost:8983/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=4 |
删除集合:
|
1
|
http://localhost:8983/solr/admin/collections?action=DELETE&name=mycollection |
重新载入集合:
|
1
|
http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection |
列出所有集合:
|
1
|
http://10.1.12.53:8983/solr/admin/collections?action=LIST |
将一个分片拆分成两个分片(用于集群扩展):
|
1
|
http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=anotherCollection&shard=shard1 |
为指定集合创建别名:
|
1
|
http://localhost:8983/solr/admin/collections?action=CREATEALIAS&name=testalias&collections=anotherCollection,testCollection |
删除集合别名:
|
1
|
http://localhost:8983/solr/admin/collections?action=DELETEALIAS&name=testalias |
删除复制节点:
|
1
|
http://localhost:8983/solr/admin/collections?action=DELETEREPLICA&collection=test2&shard=shard2&replica=core_node3 |
添加复制节点:
|
1
|
http://localhost:8983/solr/admin/collections?action=ADDREPLICA&collection=test2&shard=shard2&node=192.167.1.2:8983_solr |
查看overseer状态:
solr集群中唯一负责action处理的节点,负责其他分片,节点的状态跟踪,为节点分配分片
|
1
|
http://localhost:8983/solr/admin/collections?action=OVERSEERSTATUS&wt=json |
集群状态检查:
|
1
|
http://localhost:8983/solr/admin/collections?action=clusterstatus&wt=json |
还有其他集合api,详细说明请参考:
https://cwiki.apache.org/confluence/display/solr/Collections+API
创建全量索引
|
1
|
/usr/bin/curl -G "http://10.1.12.53:8983/solr/core_bingdu/dataimport?command=full-import&clean=true&commit=true" 2&> /dev/null |
创建增量索引
|
1
|
/usr/bin/curl -G "http://10.1.12.53:8983/solr/core_bingdu_user/dataimport?command=delta-import&clean=false&commit=true" 2&> /dev/null |
更多请参阅官方文档:
http://mirrors.cnnic.cn/apache/lucene/solr/ref-guide/apache-solr-ref-guide-5.3.pdf
solr5.3.1 集群服务搭建的更多相关文章
- LVS负载均衡集群服务搭建详解(二)
lvs-nat模型构建 1.lvs-nat模型示意图 本次构建的lvs-nat模型的示意图如下,其中所有的服务器和测试客户端均使用VMware虚拟机模拟,所使用的CentOS 7 VS内核都支持ipv ...
- LVS负载均衡集群服务搭建详解(一)
LVS概述 1.LVS:Linux Virtual Server 四层交换(路由):根据请求报文的目标IP和目标PORT将其转发至后端主机集群中的某台服务器(根据调度算法): 不能够实现应用层的负载均 ...
- Nginx+Tomcat+Memcached负载均衡集群服务搭建
操作系统:CentOS6.5 本文档主要讲解,如何在CentOS6.5下搭建Nginx+Tomcat+Memcached负载均衡集群服务器,Nginx负责负载均衡,Tomcat负责实际服务,Memc ...
- cas4.2.7 集群服务搭建
cas服务端集群,网上资料很多,无非就是session共享,ticket共享. 但是session共享是必须的吗?或者能实现集群吗? 实践: 1. ticket共享,直接上代码 package org ...
- Redis6.0.6集群服务搭建
实现目标 一台主机上搭建3主3从高可用redis集群 环境 Linux :CentOS7 Redis : 6.0.6 准备工作 1.查看是否有安装wget命令,如果没有安装使用yum命令安装wgt命令 ...
- ZooKeeper一二事 - 搭建ZooKeeper伪分布式及正式集群 提供集群服务
集群真是好好玩,最近一段时间天天搞集群,redis缓存服务集群啦,solr搜索服务集群啦,,,巴拉巴拉 今天说说zookeeper,之前搭建了一个redis集群,用了6台机子,有些朋友电脑跑步起来,有 ...
- 使用Codis搭建redis集群服务
转(http://www.jianshu.com/p/f8e968e57863) 一. 应用场景 redis 作为数据结构存储引擎,有着很多优点 高性能单机引擎可以达到5-10W qps 数据结构全面 ...
- centos HA高可用集群 heartbeat搭建 heartbeat测试 主上停止heartbeat服务 测试脑裂 两边都禁用ping仲裁 第三十二节课
centos HA高可用集群 heartbeat搭建 heartbeat测试 主上停止heartbeat服务 测试脑裂 两边都禁用ping仲裁 第三十二节课 heartbeat是Linu ...
- CentOs7.3 搭建 SolrCloud 集群服务
一.概述 Lucene是一个Java语言编写的利用倒排原理实现的文本检索类库: Solr是以Lucene为基础实现的文本检索应用服务.Solr部署方式有单机方式.多机Master-Slaver方式.C ...
随机推荐
- 十五、C# 使用查询表达式的LINQ
使用查询表达式的LINQ 本章介绍了一种新的语法,查询表达式. 1.查询表达式概述 2.特点:投射 筛选 排序 Let 分组 3.作为方法调用 标准查询运算符所实现的查询在功能上 ...
- C#入门经典(第五版)学习笔记(四)
---------------集合.比较和转换--------------- C#中的数组是作为System.Array类的实例实现的,它们是集合类(Collection Classes)中的一种类型 ...
- 你好,C++(2)1.3 C++世界版图1.4 如何学好C++
1.3 C++世界版图 C++语言的发展过程,不仅是一个特性不断增加.内容不断丰富的过程,更是一个在应用领域中不断攻城略地的过程.在其30余年的发展过程中,C++在多个应用领域都得到了广泛的应用和发 ...
- 解决linux .so的链接时符号依赖问题
问题描述 target: a.out SO:libmyfile.so 依赖描述: a.out: libmyfile.so libmyfile.so: libssl.so.1.0.0 libssl.s ...
- php5.6安装
# yum --enablerepo=remi,remi-php56 install php-fpm php-common php-mysql php-opcache php-pear php-gd ...
- HTML5画布
- 拓扑排序-DFS
拓扑排序的DFS算法 输入:一个有向图 输出:顶点的拓扑序列 具体流程: (1) 调用DFS算法计算每一个顶点v的遍历完成时间f[v] (2) 当一个顶点完成遍历时,将该顶点放到一个链表的最前面 (3 ...
- 局部变量存储区域静态变量存储区域static变量存储区域
局部变量存储区域静态变量存储区域static变量存储区域 常见的存储区域可分为: 1.栈 由编译器在需要的时候分配,在不需要的时候自动清楚的变量的存储区.里面的变量通常是局部变量.函数参数等. 2.堆 ...
- 关于DEDECMS目录移动方法
最近在做一个美容医院的站,由于我的本地的PHP服务器上有几个站,又不能放在根目录下,只能在根目录下新建一个目录来存放这个站,于是就有了这篇文章. 如果我们直接将根目录下的A文件夹下的DEDECMS文件 ...
- python自动开发之第十三天
1.Paramiko模块下的demo.py程序 前面利用Python中的Paramiko模块可以进行SSH的连接,以及用来传送文件(SFTP),但是无论是哪一种方式,连接都是短暂的,并非是长连 ...