今天SolrCloud的1号服务器挂了,管理员跟我说应该是硬盘坏了,数据可能保不住。虽然5台服务器,每个分片都有3个备份,也就是说有3台服务器运行,整个SolrCloud服务器就能正常运行。但是1号服务器挂了还是造成一些影响。
首先,前端网站和SolrCloud是用RESTful API连接的,而且,是用一个固定ip地址,刚刚好就是1号服务器。所以,需要前端工程师把所有的ip切换到2号上。
还有一个就是所有的索引配置文件都是放在1号服务器上的。这个时候就很庆幸使用的Solr版本已经升级到了5.5.4。 Solr-5.5.4脚本有控制ZooKeeper的相关命令,可以上传或下载配置文件。
-bash-3.2$ bash ./bin/solr zk
Zookeeper operation (one of '-upconfig' or '-downconfig') is required!
Usage: solr zk [-upconfig|-downconfig] [-d confdir] [-n configName] [-z zkHost]
-upconfig to move a configset from the local machine to Zookeeper.
-downconfig to move a configset from Zookeeper to the local machine.
-n configName Name of the configset in Zookeeper that will be the destinatino of
'upconfig' and the source for 'downconfig'.
-d confdir The local directory the configuration will be uploaded from for
'upconfig' or downloaded to for 'downconfig'. For 'upconfig', this
can be one of the example configsets, basic_configs, data_driven_schema_configs or
sample_techproducts_configs or an arbitrary directory.
-z zkHost Zookeeper connection string.
NOTE: Solr must have been started least once (or have it running) before using this command.
This initialized Zookeeper for Solr
-bash-3.2$ bash ./bin/solr zk -downconfig -d server/solr/configsets/my_configs -n my_configs -z 192.168.0.2:2181
zk 表示ZooKeeper操作;
<-downconfig 下载配置文件>
<-d 保存路径> (这里要注意不能只写配置文件夹名,而是要加上server/solr/configsets/)
<-n 配置文件名>
<-z ZooKeeper地址> (zkHost:2181)
现在,就等换了硬盘修复数据了。
终于换了硬盘,服务器可以使用,不过全部数据没有备份,只能一步步来了。
先配置Java环境;复制solr-5.5.4和zookeeper-3.4.6两个文件夹过来;修改zookeeper的配置;创建solr home文件夹,复制solr.xml和zoo.cfg进去;启动zookeeper;
这里遇到了问题,zookeeper启动不起来,查看zookeeper.out文件,有一堆Have smaller server identifier, so dropping the connection: (2, 1)这样的log。telnet一下,发现端口不通。后来发现是防火墙没有关。关掉后zookeeper就连接成功了。
然后启动solr。
由于solr home里面空空如也,原来的索引文件和配置都没了,所以在Admin UI上看几个Collection上1号服务器的状态都是down,无法恢复备份。这时需要手动删除原来1号服务器的replica,再添加replica,就可以了。
先切换到new UI, 点击左侧Collection项,点击某一个Collection,在右侧shard中选择状态为down的1号服务器节点,点击“红×”,点击“Delete Replica”按钮。成功后按钮会变绿色。这时再点击“add replica”,选择服务器地址,添加备份。索引比较多,需要一个个去点击。全部成功后在Cloud可以看到颜色回复绿色或浅黄色(正在备份)。