注意:本文档配置的为root用户集群操作脚本,如果要配置其他用户请修改相关配置。
SolrCloud启动脚本(start-solr-cloud)
sudo su
cd /bin
vi start-solr-cloud
脚本内容如下:
#!/bin/bash
SOLR_HOME=/home/vagrant/datas/solrcloud/solr-7.7.2
# 启动SolrCloud
echo "start SolrCloud-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr start -cloud -force"
done
sleep 3s
echo "start done..."
# 检查SolrCloud状态
echo "SolrCloud status------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr status"
done
exit 0
设置脚本执行权限:
chmod +x start-solr-cloud
SolrCloud(HDFS)启动脚本(_start-solr-hdfscloud)_
sudo su
cd /bin
vi start-solr-hdfscloud
脚本内容如下:
#!/bin/bash
SOLR_HOME=/home/vagrant/datas/solrcloud/solr-7.7.2
# 启动SolrCloud
echo "start SolrCloud(HDFS)-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr start -c -Dsolr.directoryFactory=HdfsDirectoryFactory -Dsolr.lock.type=hdfs -Dsolr.hdfs.home=hdfs://bigdata-node1:9000/solr -force"
done
sleep 3s
echo "start done..."
# 检查SolrCloud状态
echo "SolrCloud status------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr status"
done
exit 0
设置脚本执行权限:
chmod +x start-solr-hdfscloud
SolrCloud重启脚本(restart-solr-cloud)
sudo su
cd /bin
vi restart-solr-cloud
脚本内容如下:
#!/bin/bash
SOLR_HOME=/home/vagrant/datas/solrcloud/solr-7.7.2
# 重新启动SolrCloud
echo "restart SolrCloud-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr restart -cloud -force"
done
sleep 3s
echo "start done..."
# 检查SolrCloud状态
echo "SolrCloud status------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr status"
done
exit 0
设置脚本执行权限:
chmod +x restart-solr-cloud
SolrCloud状态查看脚本(status-solr-cloud)
sudo su
cd /bin
vi status-solr-cloud
脚本内容如下:
#!/bin/bash
SOLR_HOME=/home/vagrant/datas/solrcloud/solr-7.7.2
# 检查SolrCloud状态
echo "SolrCloud status------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr status"
done
exit 0
设置脚本执行权限:
chmod +x status-solr-cloud
SolrCloud停止脚本(stop-solr-cloud)
sudo su
cd /bin
vi stop-solr-cloud
脚本内容如下:
#!/bin/bash
SOLR_HOME=/home/vagrant/datas/solrcloud/solr-7.7.2
# 启动SolrCloud
echo "stop SolrCloud-------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr stop -V"
done
sleep 3s
echo "stop done..."
# 检查SolrCloud状态
echo "SolrCloud status------------------------------------------------"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
echo ------------------- $i --------------
ssh $i "source /etc/profile;${SOLR_HOME}/bin/solr status"
done
exit 0
设置脚本执行权限:
chmod +x stop-solr-cloud
分发(选做):
# 使用root账户分发至其他节点
scp -r /bin/*-solr-*cloud root@bigdata-node2:/bin/
scp -r /bin/*-solr-*cloud root@bigdata-node3:/bin/