一. 安装部署
zookeeper集群部署:
节点:
10.1.12.51:2181 node1
10.1.12.52:2181 node2
10.1.12.53:2181 node3
最新稳定版下载地址(当前3.4.6):
http://mirrors.cnnic.cn/apache/zookeeper/stable/zookeeper-3.4.6.tar.gz
各节点上解压zookeeper到/usr/local
tar xf /usr/local/src/zookeeper-3.4.6.tar.gz -C /usr/local cd /usr/local ln -s zookeeper-3.4.6.tar.gz zookeeper
创建如下数据目录结构:
/data/zookeeper/
├── data
└── log
mkdir -p /data/zookeeper/{data,log}
各节点配置zookeeper:
cd /usr/local/zookeeper/conf cp zoo_sample.cfg zoo.cfg vim zoo.cfg修改如下: tickTime=2000 initLimit=10 syncLimit=5 dataDir=/data/zookeeper/data clientPort=2181 server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
各节点的数据目录下添加唯一的node id标识
node1: echo 1>/data/zookeeper/data/myid node2: echo 2>/data/zookeeper/data/myid node3: echo 3>/data/zookeeper/data/myid
各节点修改ZOO_LOG_DIR环境变量:
echo -e "\nZOO_LOG_DIR=/data/zookeeper/log" >> /usr/local/zookeeper/bin/zkEnv.sh
各节点上启动zookeeper:
/usr/local/zookeeper/bin/zkServer.sh start 添加zookeeper的sysv服务脚本 vim /etc/init.d/zookeeper #!/bin/bash # # chkconfig: 345 30 70 # description: Starts/Stops Apache Zookeeper export ZOO_HOME=/usr/local/zookeeper export ZOO_BIN=$ZOO_HOME/bin export ZOO_SER_BIN=$ZOO_BIN/zkServer.sh $ZOO_SER_BIN $1
#------finish-------
chmod +x /etc/init.d/zookeeper chkconfig -add zookeeper chkconfig zookeeper on
solrcloud部署(3分片2复制集):
节点:
10.1.12.51:8983 shard1-repl1 shard2-repl2
10.1.12.52:8983 shard2-repl1 shard3-repl2
10.1.12.53:8983 shard3-repl1 shard1-repl2
最新稳定版下载地址(当前5.3.1)
http://mirrors.cnnic.cn/apache/lucene/solr/5.3.1/solr-5.3.1.tgz
各节点解压安装操作:
cd /usr/local/src tar xzf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2 ./install_solr_service.sh solr-5.3.1.tgz -i /usr/local -d /data/solrcloud -u solr -s solr -p 8983
各节点solr服务配置修改:
1.调整jvm堆内存大小
echo ‘SOLR_JAVA_MEM="-Xms10g -Xmx10g"‘ >> /data/solrcloud/solr.in.sh
2.添加zookeeper
echo ‘ZK_HOST=10.1.12.51:2181,10.1.12.52:2181,10.1.12.53:2181‘ >> /data/solrcloud/solr.in.sh
3.添加solr依赖jar包
cp ~/ik-analyzer-solr5-5.x.jar /usr/local/solr/server/solr-webapp/webapp/WEB-INF/lib cp -n /usr/local/solr/dist/*.jar /usr/local/solr/server/solr-webapp/webapp/WEB-INF/lib cp ~/mysql-connector-java-5.1.35.jar /usr/local/solr/server/lib
4.重启solr服务
/etc/init.d/solr restart
创建colletion(其中一个节点下操作即可)
su -c ‘/usr/local/solr/bin/solr create -c core_bingdu -d /opt/core_bingdu_conf -n core_bingdu -s 3 -rf 2 -port 8983‘ - solr su -c ‘/usr/local/solr/bin/solr create -c core_bingdu_user -d /opt/core_bingdu_user_conf -n core_bingdu_user -s 3 -rf 2 -port 8983‘ - solr
二. 集群操作
创建全量索引
/usr/bin/curl -G "http://10.1.12.51:8983/solr/core_bingdu/dataimport?command=full-import&clean=true&commit=true" 2&> /dev/null
创建增量索引
/usr/bin/curl -G "http://10.1.12.51:8983/solr/core_bingdu_user/dataimport?command=full-import&clean=true&commit=true" 2&> /dev/null
修改solr的collection配置后上传到zookeeper:
当前solr的collection配置副本存放在opt目录下
[root@mongo-shard1-1 opt]# tree . . ├── core_bingdu_conf │ ├── admin-extra.html │ ├── admin-extra.menu-bottom.html │ ├── admin-extra.menu-top.html │ ├── data-config.xml │ ├── dataimport.properties │ ├── _rest_managed.json │ ├── schema.xml │ └── solrconfig.xml └── core_bingdu_user_conf ├── admin-extra.html ├── admin-extra.menu-bottom.html ├── admin-extra.menu-top.html ├── data-config.xml ├── dataimport.properties ├── _rest_managed.json ├── schema.xml └── solrconfig.xml
对以上配置文件进行修改后需要手动上传到zookeeper:
1)整个配置目录上传
cd /usr/local/solr/server/scripts/cloud-scripts ./zkcli.sh -zkhost 10.1.12.51:2181 -cmd upconfig -confdir /opt/core_bingdu_conf -confname core_bingdu ./zkcli.sh -zkhost 10.1.12.51:2181 -cmd upconfig -confdir /opt/core_bingdu_user_conf -confname core_bingdu_user
2)单文件上传
zkcli.sh -zkhost 10.1.12.51:2181 -cmd putfile /configs/core_bingdu/solrconfig.xml /opt/core_bingdu_conf/solrconfig.xml zkcli.sh -zkhost 10.1.12.51:2181 -cmd putfile /configs/core_bingdu_user/solrconfig.xml /opt/core_bingdu_user_conf/solrconfig.xml
更多请参阅官方文档:
http://mirrors.cnnic.cn/apache/lucene/solr/ref-guide/apache-solr-ref-guide-5.3.pdf
来自: http://www.bubuko.com/infodetail-1183992.html