`
ssxxjjii
  • 浏览: 931586 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

solrCloud 4.9 分布式集群部署及注意事项

    博客分类:
  • solr
 
阅读更多

http://www.cnblogs.com/huangfox/p/3920315.html

环境搭建

一.zookeeper

参考:http://blog.chinaunix.net/uid-25135004-id-4214399.html

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
现有4台机器 10.14.2.201 10.14.2.202 10.14.2.203 10.14.2.204
安装zookeeper集群
  
在所有机器上进行
1、下载安装包解压
 tar xvf zookeeper-3.4.5.tar.gz  -C /export/
 cd /export/
 ln -s zookeeper-3.4.5 zookeeper
 
2、设置环境变量
 vim /etc/profile
#Set ZooKeeper Enviroment
export ZOOKEEPER_HOME=/export/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
 
3、加载环境变量
 source   /etc/profile
4、配置zookeeper
cd /export/zookeeper/conf
cp zoo_sample.cfg  zoo.cfg
vim zoo.cfg
 
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/export/zookeeper/data
dataLogDir=/export/zookeeper/log
clientPort=2181
server.1=10.14.2.201:2888:3888
server.2=10.14.2.202:2888:3888
server.3=10.14.2.203:2888:3888
server.4=10.14.2.204:2888:3888
 
5、dataDir和日志目录dataLogDir
mkdir -p /export/zookeeper/data
mkdir -p /export/zookeeper/log
 
6、在10.14.2.201上
在dataDir目录下创建myid文件
echo 1 > /export/zookeeper/data/myid
 
myid中的数字与zoo.cfg中的"server.数字=ip或者域名:port1:port2"相对应,
配置文件中10.14.2.201对应的server.数字是1 所以myid的数字应为1
 
7、在10.14.2.202上
在dataDir目录下创建myid文件
echo 2 > /export/zookeeper/data/myid
 
8、在10.14.2.203上
在dataDir目录下创建myid文件
echo 3 > /export/zookeeper/data/myid
 
9、在10.14.2.204上
在dataDir目录下创建myid文件
echo 4 > /export/zookeeper/data/myid
 
在所用机器上执行
10、修改权限
chown hadoop.hadoop -R /export/zookeeper/
chown hadoop.hadoop -R /export/zookeeper
 
11、启动zookeeper
/export/zookeeper/bin/zkServer.sh start
 
12、观察zookeeper状态
   1> 10.14.2.201
   # /export/zookeeper/bin/zkServer.sh status
   JMX enabled by default
   Using config: /export/zookeeper/bin/../conf/zoo.cfg
   Mode: follower
 
   2> 10.14.2.202
   # /export/zookeeper/bin/zkServer.sh status
   JMX enabled by default
   Using config: /export/zookeeper/bin/../conf/zoo.cfg
   Mode: follower
  
   3> 10.14.2.203
   # /export/zookeeper/bin/zkServer.sh status
  JMX enabled by default
  Using config: /export/zookeeper/bin/../conf/zoo.cfg
  Mode: leader
  
   4> 10.14.2.204
   # /export/zookeeper/bin/zkServer.sh status
   JMX enabled by default
   Using config: /export/zookeeper/bin/../conf/zoo.cfg
   Mode: follower
    
13、此时zookeeper已安装并启动完毕

  

二.solrCloud

参考:http://lucien-zzy.iteye.com/blog/2002463

1.安装tomcat,配置端口。部署solr.war,将solr\example\lib\ext下的jar拷贝到solr\WEB-INF\lib下。

2.创建

/home/solr/solrcloud

/home/solr/solrcloud/config-files (放置solr\example\solr\collection1\conf 下的所有文件)

/home/solr/solrcloud/solr-lib (放置solr\WEB-INF\lib下的所有jar包)

3.配置中文分词器

4.创建solr数据目录

/home/solr/solr-cores

生成solr.xml,如下:

复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
<logging enabled="true">
<watcher size="100" threshold="INFO" />
</logging>
<cores defaultCoreName="collection1" adminPath="/admin/cores" host="${host:}" hostPort="8080" hostContext="${hostContext:solr}" zkClientTimeout="${zkClientTimeout:15000}">
</cores>
</solr>
复制代码

5.创建

tomcat/conf/Catalina

tomcat/conf/Catalina/localhost

并创建solr.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/soft/apache-tomcat-7.0.37/webapps/solr" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/home/solr/solr-cores" override="true"/>
</Context>

docBase根据实际情况配置;

solr/home为之前创建的目录:/home/solr/solr-cores

6.修改tomcat/bin/cataina.sh 文件,在最上方加入:JAVA_OPTS="-DzkHost=master:2181,slave1:2181,slave2:2181",或直接使用ip。

将以上配置发布到集群其他机器上。

7.SolrCloud是通过ZooKeeper集群来保证配置文件的变更及时同步到各个节点上,所以,需要将配置文件上传到ZooKeeper集群中。执行如下操作:

java -classpath .:/home/solr/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 192.168.91.128:2181,192.168.91.129:2181,192.168.91.130:2181 -confdir /home/solr/solrcloud/config-files/ -confname myconf  

-cmd upconfig:上传配置文件

-confdir:配置文件的目录

-confname:指定对应的名称

java -classpath .:/home/solr/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection collection1 -confname myconf -zkhost 192.168.91.128:2181,192.168.91.129:2181,192.168.91.130:2181

-cmd linkconfig:为指定collection"绑定"配置文件

-collection

-confname

8.检查zookeeper的配置信息

zkCli.sh -server ip:port

ls /configs/myconf

ls /live_nodes

9.启动tomcat,创建collection

curl 'http://192.168.91.128:8080/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=1'

action:CREATE

name:collection名称

numShards:分片数量

replicationFactor:副本集数量

也可以通过zk查询collection的情况:ls /collections/mycollection

 

-------------------------------

1.ZK CLI

ZooKeeper's Command Line Utility (CLI).

zkcli Parameters

Short

Parameter Usage

Meaning

 

-cmd <arg>

CLI Command to be executed: bootstrapupconfigdownconfiglinkconfigmakepathgetgetfileput,putfilelist or clear
This parameter is mandatory

-z

-zkhost <locations>

ZooKeeper host address. 
This parameter is mandatory for all CLI commands.

-c

-collection <name>

For linkconfig: name of the collection.

-d

-confdir <path>

For upconfig: a directory of configuration files.

-h

-help

Display help text.

-n

-confname <arg>

For upconfiglinkconfig: name of the configuration set.

-r

-runzk <port>

Run ZooKeeper internally by passing the Solr run port; only for clusters on one machine.

-s

-solrhome <path>

For bootstrap or when using -runzk: the mandatory solrhome location.

ZooKeeper CLI Examples

Below are some examples of using the zkcli CLI:
Uploading a Configuration Directory

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 127.0.0.1:9983
-confdir example/solr/collection1/conf -confname conf1 -solrhome example/solr

Put arbitrary data into a new ZK file

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:9983 -put /data.txt 'some data'

Put a local file into a new ZK file

java -classpath example/solr-webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:9983 -putfile /data.txt /some/local/file.txt

Linking a Collection to a Configuration Set

java -classpath example/solr-webapp/webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd linkconfig -zkhost 127.0.0.1:9983
-collection collection1 -confname conf1 -solrhome example/solr

Bootstrapping All the Configuration Directories in solr.xml

java -classpath example/solr-webapp/webapp/WEB-INF/lib/*
org.apache.solr.cloud.ZkCLI -cmd bootstrap -zkhost 127.0.0.1:9983
-solrhome example/solr

Scripts

There are scripts in example/cloud-scripts that handle the classpath and class name for you if you are using Solr out of the box with Jetty. Commands then become:

sh zkcli.sh -cmd linkconfig -zkhost 127.0.0.1:9983
-collection collection1 -confname conf1 -solrhome example/solr

 

 

2.Managing collections via the collections API

CREATE---

http://localhost:8983/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=4

name:collection的名称

numShards:指定分片数量(slices)

replicationFactor:副本数量

maxShardsPerNode:默认值为1,注意三个数值:numShards、replicationFactor、liveSolrNode,一个正常的solrCloud集群不容许同一个liveSolrNode上部署同一个shard的多个replic,因此当maxShardsPerNode=1时,numShards*replicationFactor>liveSolrNode时,报错。因此正确时因满足以下条件:
numShards*replicationFactor<liveSolrNode*maxShardsPerNode

createNodeSet:

collection.configName:指定该collection使用那份config,这份config必须存在于zk中。

DELETE---

http://localhost:8983/solr/admin/collections?action=DELETE&name=mycollection

RELOAD---

http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection

SPLIT SHARD---

http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=<collection_name>&shard=shardId

 

3.Creating cores via CoreAdmin

curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=mycore&collection=collection1&shard=shard2'

 

 

-------------------------------

Q1:Multiple schemas in the same SolrCloud ?

java -classpath .:/home/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 10.200.51.190:2224,10.200.51.192:2224,10.200.51.194:2224 -confdir /home/solrcloud/fox-config-files/ -confname foxconf

指定配置文件,上传到zk。

curl 'http://10.200.51.194:2223/solr/admin/collections?action=CREATE&name=fox4&numShards=1&replicationFactor=5&collection.configName=foxconf'

为创建的collection指定collection.configName。

分享到:
评论

相关推荐

    SANGFOR_aDesk_V4.9_VDC集群配置指南.pdf

    SANGFOR_aDesk_V4.9_VDC集群配置指南.pdf

    solr4.9+tomcat+zookeeper集群

    solr4.9+tomcat+zookeeper集群

    Dotfuscator Professional Edition 4.9完美破解版及使用教程

    Dotfuscator Professional Edition 4.9完全破解,永久免费 亲测可用完美破解无时间限制。 包括使用教程文档。 直接安装即可使用,不用打任何破解补丁,没有任何限制,已经完全破解。 1.无时间限制 2. 去除混淆后...

    DotfuscatorProfessionalEdition 4.9完美破解版及使用教程

    Dotfuscator Professional Edition 4.9完全破解版永久免费 NET 混淆加密工具+使用教程文档 直接安装即可使用,不用打任何破解补丁,没有任何限制,已经完全破解。 1.无时间限制. 2. 去除混淆后的程序集类型名称中...

    移植linux-4.9的相关文件及结果

    移植linux-4.9的结果文件:包括内核镜像,uboot以及根文件系统,支持DM9000。

    junit4.9.zip

    junit4.9.zip4.9.zipjunit4.9.zip

    WordPress 4.9 Beta 1 发布,解析更新

    WordPress 4.9 预计将在2017年11月14日公布。几天前发布了 WordPress 4.9 Beta 1,让我们一起来看下 WordPress 4.9 的具体更新内容吧! 改进外观定制器(Customizer) 外观 – 自定义 界面,允许你将设置选项保存...

    Jlink固件更新-恢复及Jlink4.9驱动4.9

    包含Jlink固件驱动工具,固件程序,教程,以及Jlink4.9驱动。

    SANGFOR_aDesk_V4.9_双网隔离部署配置指导.pdf

    SANGFOR_aDesk_V4.9_双网隔离部署配置指导.pdf

    gcc 4.9

    gcc 4.9 (gcc4.9.zip)

    Jlink驱动V4.9

    Jlink最新驱动V4.90,已经测试过,非常好用。

    Sniffer Portable 4.9

    Sniffer Portable 4.9是一款一流的便携式网管和应用故障诊断分析软件,不管是在有线网络还是在无线网络中,它都能够给予网管管理人员实时的网络监视、数据包捕获以及故障诊断分析能力。对于在现场迚行快速的网络和...

    junit-4.9.jar

    junit-4.9.jarjunit-4.9.jarjunit-4.9.jarjunit-4.9.jarjunit-4.9.jarjunit-4.9.jarjunit-4.9.jar

    linux内核版本4.9.37

    mv linux-4.9.37 linux-4.9.y cd linux-4.9.y patch -p1 &lt; ../linux-4.9.37.patch cd ../ tar -czf linux-4.9.y.tgz linux-4.9.y cd ../../ 或 1)将下载的 linux-4.9.37.tar.gz 存放到 osdrv的opensource/...

    金蝶智慧店铺版V4.9

    金蝶智慧店铺版V4.9

    DevExpress VCL v4.9

    请用7zip或winrar解压后,使用Auto-Installer v1.81 for DevExpress VCL v4.8-4.9 安装。 如果不能正常解压,请升级为新版本的7zip或WINRAR解压。 ------ 这些资源都是网上找到的,放在一起方便大家下载。RAR压缩30M...

    dotNET_Reactor4.9

    dotNET_Reactor4.9绿色版,自动解压缩之后就可以使用.

    BOSCH氧传感器LSU4.9

    博世LSU4.9氧传感器英文详细说明书, The wide band lambda sensor LSU is a planar ZrO2 dual cell limiting current sensor with an integrated heater. It is used to measure the oxygen content and the λ-...

    Sniffer Pro 4.9下载 part3

    因为VLAN统计功能只有在安装了Sniffer Portable 4.9支持的网卡及安装了增强驱动的网卡才可以使用,很遗憾没有睹其庐山面目) 3.捕获 在Sniffer Pro4.7以前捕获数据报时,专家系统不支持实时解码功能,自从4.8以后及...

Global site tag (gtag.js) - Google Analytics