2013-12-22 23:44:26 -05:00
#!/bin/bash
2015-04-28 10:32:55 -04:00
# These scripts are best effort developer scripts. No promises.
2014-08-06 12:46:31 -04:00
# To run on hdfs, try something along the lines of:
# export JAVA_OPTS="-Dsolr.directoryFactory=solr.HdfsDirectoryFactory -Dsolr.lock.type=hdfs -Dsolr.hdfs.home=hdfs://localhost:8020/solr -Dsolr.hdfs.confdir=/etc/hadoop_conf/conf"
2014-08-29 08:30:53 -04:00
# To use ZooKeeper security, try:
# export JAVA_OPTS="-DzkACLProvider=org.apache.solr.common.cloud.VMParamsAllAndReadonlyDigestZkACLProvider -DzkCredentialsProvider=org.apache.solr.common.cloud.VMParamsSingleSetCredentialsDigestZkCredentialsProvider -DzkDigestUsername=admin-user -DzkDigestPassword=admin-password -DzkDigestReadonlyUsername=readonly-user -DzkDigestReadonlyPassword=readonly-password"
2015-04-29 10:59:33 -04:00
#
# To create a collection, curl "localhost:8901/solr/admin/collections?action=CREATE&name=collection1&numShards=2&replicationFactor=1&maxShardsPerNode=10"
# To add a document, curl http://localhost:8901/solr/collection1/update -H 'Content-type:application/json' -d '[{"id" : "book1"}]'
2014-08-29 08:30:53 -04:00
2013-12-22 23:44:26 -05:00
numServers = $1
numShards = $2
2014-08-06 12:46:31 -04:00
baseJettyPort = 8900
baseStopPort = 9900
2013-12-22 23:44:26 -05:00
2014-08-29 08:30:53 -04:00
zkAddress = localhost:9900/solr
2013-12-22 23:44:26 -05:00
die ( ) {
echo >& 2 " $@ "
exit 1
}
2015-04-29 10:59:33 -04:00
[ " $# " -eq 1 ] || die " 1 argument required, $# provided, usage: solrcloud-start.sh [numServers] "
2012-01-25 14:49:26 -05:00
cd ..
2013-12-22 23:44:26 -05:00
for ( ( i = 1; i <= $numServers ; i++ ) )
do
2014-12-02 12:41:30 -05:00
echo " try to remove existing directory: server $i "
rm -r -f server$i
2013-12-22 23:44:26 -05:00
done
2012-01-25 14:49:26 -05:00
rm -r -f dist
rm -r -f build
2014-12-02 12:41:30 -05:00
rm -r -f server/solr/zoo_data
rm -f server/server.log
2012-01-25 14:49:26 -05:00
2015-04-28 10:56:26 -04:00
ant -f ../build.xml clean
ant server dist
2012-01-25 14:49:26 -05:00
2014-12-02 12:41:30 -05:00
rm -r server/solr-webapp/*
unzip server/webapps/solr.war -d server/solr-webapp/webapp
2013-03-02 20:29:48 -05:00
2013-12-22 23:44:26 -05:00
for ( ( i = 1; i <= $numServers ; i++ ) )
do
2014-12-02 12:41:30 -05:00
echo " create server $i "
cp -r -f server server$i
2013-12-22 23:44:26 -05:00
done
2014-08-29 08:30:53 -04:00
2014-12-02 12:41:30 -05:00
rm -r -f serverzk
cp -r -f server serverzk
cp core/src/test-files/solr/solr-no-core.xml serverzk/solr/solr.xml
rm -r -f serverzk/solr/collection1/core.properties
cd serverzk
2014-08-06 12:46:31 -04:00
stopPort = 1313
jettyPort = 8900
2015-04-28 10:32:55 -04:00
exec -a jettyzk java -Xmx512m $JAVA_OPTS -Djetty.port= $jettyPort -DhostPort= $jettyPort -DzkRun= localhost:9900/solr -DzkHost= $zkAddress -DzkRunOnly= true -jar start.jar --module= http STOP.PORT= $stopPort STOP.KEY= key jetty.base= . 1>serverzk.log 2>& 1 &
2014-08-06 12:46:31 -04:00
cd ..
2013-12-22 23:44:26 -05:00
2014-08-06 12:46:31 -04:00
# upload config files
2015-04-29 10:59:33 -04:00
java -classpath "server/solr-webapp/webapp/WEB-INF/lib/*:server/lib/ext/*" $JAVA_OPTS org.apache.solr.cloud.ZkCLI -zkhost $zkAddress -cmd upconfig --confdir server/solr/configsets/basic_configs/conf --confname basic_configs
2014-08-06 12:46:31 -04:00
2014-12-02 12:41:30 -05:00
cd server
2012-01-25 14:49:26 -05:00
2014-08-06 12:46:31 -04:00
for ( ( i = 1; i <= $numServers ; i++ ) )
2013-12-22 23:44:26 -05:00
do
2014-12-02 12:41:30 -05:00
echo " starting server $i "
cd ../server$i
2013-12-22 23:44:26 -05:00
stopPort = ` expr $baseStopPort + $i `
jettyPort = ` expr $baseJettyPort + $i `
2015-04-29 10:59:33 -04:00
exec -a jetty java -Xmx1g $JAVA_OPTS -Djetty.port= $jettyPort -DzkHost= $zkAddress -jar start.jar --module= http STOP.PORT= $stopPort STOP.KEY= key jetty.base= . 1>server$i .log 2>& 1 &
2013-12-22 23:44:26 -05:00
done