1.Solr5.2.1安装
1.1 Solr版本要求必须是5.2.1,见官网
1.2 Solr下载:http://archive.apache.org/dist/lucene/solr/5.2.1/solr-5.2.1.tgz
1.3 解压solr-5.2.1.tgz到/opt/module/目录下面
[kris@hadoop2 module]$ tar -zxvf solr-5.2.1.tgz -C /opt/module/
1.4 修改solr-5.2.1的名称为solr
[kris@hadoop2 module]$ mv solr-5.2.1/ solr
1.5 进入solr/bin目录,修改solr.in.sh文件
[kris@hadoop2 solr]$ vim bin/solr.in.sh
#添加下列指令
ZK_HOST="hadoop2:2181,hadoop3:2181,hadoop4:2181"
SOLR_HOST="hadoop101"
# Sets the port Solr binds to, default is 8983
#可修改端口号
SOLR_PORT=8983
1.6 分发Solr,进行Cloud模式部署
[kris@hadoop2 module]$ xsync solr
提示:分发完成后,分别对hadoop3、hadoop4主机/opt/module/solr/bin下的solr.in.sh文件,修改为SOLR_HOST=对应主机名。
1.7 在三台节点上分别启动Solr,这个就是Cloud模式
[kris@hadoop2 solr]$ bin/solr start
[kris@hadoop3 solr]$ bin/solr start
[kris@hadoop4 solr]$ bin/solr start
提示:启动Solr前,需要提前启动Zookeeper服务。
1.8 Web访问8983端口,可指定三台节点中的任意一台IP,http://hadoop2:8983/solr/#/
提示:UI界面出现Cloud菜单栏时,Solr的Cloud模式才算部署成功。
1.9 编写Solr启动停止脚本
(1)在hadoop2的/opt/module/solr/bin目录下创建脚本
[kris@hadoop2 bin]$ vim s.sh
在脚本中编写如下内容
#!/bin/bash case $1 in"start"){ for i in hadoop2 hadoop3 hadoop4 do ssh $i "/opt/module/solr/bin/solr start" done };; "stop"){ for i in hadoop2 hadoop3 hadoop4 do ssh $i "/opt/module/solr/bin/solr stop" done };; esac
(2)增加脚本执行权限 [kris@hadoop2 bin]$ chmod +x s.sh
(3)Solr集群启动脚本 [kris@hadoop2 module]$ s.sh start
(4)Solr集群停止脚本 [kris@hadoop2 module]$ s.sh stop
2.Atlas集成Solr
2.1 进入/opt/module/atlas/conf目录,修改配置文件
[kris@hadoop2 conf]$ vim atlas-application.properties
#修改如下配置
atlas.graph.index.search.solr.zookeeper-url=hadoop2:2181,hadoop3:2181,hadoop4:2181
2.2 将Atlas自带的Solr文件夹拷贝到外部Solr集群的各个节点。
[kris@hadoop2 conf]$
cp -r /opt/module/atlas/conf/solr /opt/module/solr/
2.3 进入到/opt/module/solr路径,修改拷贝过来的配置文件名称为atlas_conf
[kris@hadoop2 solr]$ mv solr atlas_conf
2.4 在Cloud模式下,启动Solr(需要提前启动Zookeeper集群),并创建collection
[kris@hadoop2 solr]$ bin/solr create -c vertex_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2
[kris@hadoop3 solr]$ bin/solr create -c edge_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2
[kris@hadoop4 solr]$ bin/solr create -c fulltext_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2
-shards 3:表示该集合分片数为3
-replicationFactor 2:表示每个分片数都有2个备份
vertex_index、edge_index、fulltext_index:表示集合名称
注意:如果需要删除vertex_index、edge_index、fulltext_index等collection可以执行如下命令。
[kris@hadoop101 solr]$ bin/solr delete -c ${collection_name} 创建collection的详细如下:
[kris@hadoop2 solr]$ bin/solr create -c vertex_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2 Connecting to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Uploading /opt/module/solr/atlas_conf for config vertex_index to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Creating new collection 'vertex_index' using command: http://hadoop2:8983/solr/admin/collections?action=CREATE&name=vertex_index&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=vertex_index
{ "responseHeader":{ "status":0, "QTime":5435}, "success":{"":{ "responseHeader":{ "status":0, "QTime":5094}, "core":"vertex_index_shard1_replica1"}}} [kris@hadoop3 solr]$ bin/solr create -c edge_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2 Connecting to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Uploading /opt/module/solr/atlas_conf for config edge_index to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Creating new collection 'edge_index' using command: http://hadoop3:8983/solr/admin/collections?action=CREATE&name=edge_index&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=edge_index { "responseHeader":{ "status":0, "QTime":3280}, "success":{"":{ "responseHeader":{ "status":0, "QTime":3116}, "core":"edge_index_shard3_replica2"}}} [kris@hadoop4 solr]$ bin/solr create -c fulltext_index -d /opt/module/solr/atlas_conf -shards 3 -replicationFactor 2 Connecting to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Uploading /opt/module/solr/atlas_conf for config fulltext_index to ZooKeeper at hadoop2:2181,hadoop3:2181,hadoop4:2181 Creating new collection 'fulltext_index' using command: http://hadoop4:8983/solr/admin/collections?action=CREATE&name=fulltext_index&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=fulltext_index { "responseHeader":{ "status":0, "QTime":3455}, "success":{"":{ "responseHeader":{ "status":0, "QTime":3115}, "core":"fulltext_index_shard3_replica1"}}}
2.5 验证创建collection成功
登录solr web控制台:http://192.168.0.111:8983/solr/#/~cloud 看到如下图显示: