现有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
<?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>
<?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>
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
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
curl 'http://192.168.91.128:8080/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=1'
zkcli Parameters
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
java -classpath example/solr-webapp/WEB-INF/lib/* org.apache.solr.cloud.ZkCLI -zkhost 127.0.0.1:9983 -put /data.txt 'some data'
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
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
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
sh zkcli.sh -cmd linkconfig -zkhost 127.0.0.1:9983 -collection collection1 -confname conf1 -solrhome example/solr
http://localhost:8983/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=4
http://localhost:8983/solr/admin/collections?action=DELETE&name=mycollection
http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection
http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=<collection_name>&shard=shardId
curl 'http://localhost:8983/solr/admin/cores?action=CREATE&name=mycore&collection=collection1&shard=shard2'
——————————-
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
curl 'http://10.200.51.194:2223/solr/admin/collections?action=CREATE&name=fox4&numShards=1&replicationFactor=5&collection.configName=foxconf'
未经允许不得转载:李阳的藏宝阁 » solrCloud 4.9 分布式集群部署及注意事项