线上有一套双节点的Solrcloud节点,因机器性能较老,环境搭建于2013年,原节点有数百个已经被unload的collections,考虑以后可能还会需要,所以搭建一套和原节点相同的solrcloud环境,因为目前只有一台新机器,所以在一台机器上搭建Solrcloud伪双节点集群,
软件版本
- JDK:jdk1.6.0_12 http://download.oracle.com/otn/java/jdk/6u12-b04/jdk-6u12-linux-x64.bin
- Tomcat:apache-tomcat-6.0.20 https://archive.apache.org/dist/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz
- Zookeeper:zookeeper-3.4.5 http://archive.apache.org/dist/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
- Solr:solr-4.2.1 https://archive.apache.org/dist/lucene/solr/4.2.1/solr-4.2.1.tgz
原节点环境信息
主机名(IP) | ec2d-cntprocdb-01(10.189.100.128) | ec2d-cntprocdb-02(10.189.100.128) |
User | tnuser | |
JDK | /usr/java/jdk1.6.0_12 | |
tomcat(port) | /usr/local/apache-tomcat-6.0.20 (8983) | /usr/local/apache-tomcat-6.0.20 (8983) |
zookeeper | /usr/local/contentplatform/zookeeper-3.4.5 | /usr/local/contentplatform/zookeeper-3.4.5 |
solr(port) | /usr/local/contentplatform/solr/solr | /usr/local/contentplatform/solr/solr |
新节点的安装路径
主机名(IP) | ec2d-newcntprocdb-01(10.189.100.75) | |
User | tnuser | |
JDK | /usr/java/jdk1.6.0_12 | |
tomcat(port) | /usr/local/apache-tomcat-6.0.20-8983 (8983) | /usr/local/apache-tomcat-6.0.20-8984 (8984) |
Zookeeper | /usr/local/contentplatform/zookeeper-3.4.5 | |
Solr(port) | /usr/local/contentplatform/solr8983/solr (8983) | /usr/local/contentplatform/solr8984/solr (8984) |
1. 系统参数修改
1.1 内核参数
$ tail -n 12 /etc/sysctl.conf vm.overcommit_memory=1 vm.overcommit_ratio=90 fs.aio-max-nr=1048576 fs.file-max= 7672460 net.ipv4.ip_local_port_range=9000 65500 net.core.rmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_default=262144 net.core.wmem_max=1048586 kernel.sem= 50100 64128000 50100 1280 kernel.shmall=5242880 kernel.shmmax=12884901888
1.2. 资源使用
$ tail -n 6 /etc/security/limits.conf tnuser soft nproc 8192 tnuser hard nproc 16384 tnuser soft nofile 4096 tnuser hard nofile 65536
1.3. 环境变量
$ cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs JAVA_HOME=/usr/java/jdk1.6.0_12 ZOOKEEPER_HOME=/usr/local/contentplatform/zookeeper-3.4.5 JRE_HOME=$JAVA_HOME/jre CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JRE_HOME/lib PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin export PATH
2. Zookeeper安装
$ mkdir /usr/local/contentplatform $ cd /usr/local/contentplatform $ wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz $ tar -zxf zookeeper-3.4.5.tar.gz $ mkdir zookeeper-3.4.5/data $ cat zookeeper-3.4.5/conf/zoo.cfg tickTime=2000 initLimit=10 syncLimit=5 dataDir=/usr/local/contentplatform/zookeeper-3.4.5/data clientPort=9983 $ zookeeper-3.4.5/bin/zkServer.sh start $ zookeeper-3.4.5/bin/zkServer.sh status JMX enabled by default Using config: /usr/local/contentplatform/zookeeper-3.4.5/bin/../conf/zoo.cfg Mode: standalone
3. solr安装
$ cd /usr/local/contentplatform $ wget https://archive.apache.org/dist/lucene/solr/4.2.1/solr-4.2.1.tgz $ tar -zxf solr-4.2.1.tgz $ mkdir {solr8983,solr8984} $ cp -r solr-4.2.1/example/* solr8983/ $ cat solr8983/solr/solr.xml
<?xml version="1.0" encoding="UTF-8" ?> <solr persistent="true"> <cores defaultCoreName="tnpoi" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:60000}" hostPort="8983" hostContext="solr"> <core loadOnStartup="true" shard="shard1" instanceDir="tifbase/" transient="false" name="tnpoi"/> </cores> </solr>
默认的collection为collection1,我将这里改成我实际的collection名tnpoi,注意hostPort的值一定要改成和第一个tomcat的端口号对应
$ cp -r solr8983/* solr8984/ $ cat solr8984/solr/solr.xml
<?xml version="1.0" encoding="UTF-8" ?> <solr persistent="true"> <cores defaultCoreName="tnpoi" adminPath="/admin/cores" zkClientTimeout="${zkClientTimeout:60000}" hostPort="8984" hostContext="solr"> <core loadOnStartup="true" shard="shard2" instanceDir="tifbase/" transient="false" name="tnpoi"/> </cores> </solr>
注意第二个solr的hostPort的值一定要改成和第二个tomcat的端口号对应
4. tomcat安装
$ cd /usr/local $ https://archive.apache.org/dist/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz $ tar -zxf apache-tomcat-6.0.20.tar.gz $ mkdir {apache-tomcat-6.0.20-8983,apache-tomcat-6.0.20-8984} $ rm -rf apache-tomcat-6.0.20-8983/webapps/* $ unzip contentplatform/solr-4.2.1/example/webapps/solr.war -d apache-tomcat-6.0.20-8983/webapps/solr $ cp -r /usr/local/contentplatform/solr-4.2.1/dist/*.jar /usr/local/apache-tomcat-6.0.20-8983/webapps/solr/WEB-INF/lib/ $ cp -r /usr/local/contentplatform/solr-4.2.1/contrib/velocity/lib/*.jar /usr/local/apache-tomcat-6.0.20-8983/webapps/solr/WEB-INF/lib/ $ cp -r /usr/local/contentplatform/solr-4.2.1/contrib/extraction/lib/*.jar /usr/local/apache-tomcat-6.0.20-8983/webapps/solr/WEB-INF/lib/ $ cp -r /usr/local/contentplatform/solr-4.2.1/example/lib/*.jar /usr/local/apache-tomcat-6.0.20-8983/webapps/solr/WEB-INF/lib/
修改bin/catalina.sh文件
sh /usr/local/apache-tomcat-6.0.20-8983/bin/createSymbolicConf.sh JAVA_HOME=/usr/java/jdk1.6.0_12/ JAVA_OPTS="$JAVA_OPTS -Xms8000M -Xmx8000M -Duser.language=en -Duser.country=US -Dsolr.solr.home=/usr/local/contentplatform/solr8983/solr -DhostContext=solr -Dbootstrap_conf=true -Dhostport=8983 -DzkHost=ec2d-newcntprocdb-01:9983 -DnumShards=2" echo "Java Options: $JAVA_OPTS"
createSymbolicConf.sh脚本为每次启动tomcat时添加成conf目录软连接到指定的collection下
$ cat apache-tomcat-6.0.20-8983/bin/createSymbolicConf.sh #!/bin/sh baseDir=/usr/local/contentplatform/solr8983/solr confDir=/usr/local/contentplatform/solr8983/solr/tifbase/conf for subDir in $baseDir/* do if [ ! -d $subDir/conf ] && [[ "$subDir" == *poi* ]] then echo "$subDir don't have conf dir, creating symbolic link" ln -sb $confDir $subDir/conf fi done
修改conf/server.xml文件
<?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <Service name="Catalina"> <Connector port="8983" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> </Service> </Server>
修改tomcat下的solr的web.xml文件
<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>/usr/local/contentplatform/solr8983/solr</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
将tomcat目录复制一份为第二个tomcat目录
$ cp -r apache-tomcat-6.0.20-8983/* apache-tomcat-6.0.20-8984/
修改第二个tomcat下的bin/catalina.sh文件
sh /usr/local/apache-tomcat-6.0.20-8984/bin/createSymbolicConf.sh JAVA_HOME=/usr/java/jdk1.6.0_12/ JAVA_OPTS="$JAVA_OPTS -Xms8000M -Xmx8000M -Duser.language=en -Duser.country=US -Dsolr.solr.home=/usr/local/contentplatform/solr8984/solr -DhostContext=solr -Dbootstrap_conf=true -Dhostport=8984 -DzkHost=ec2d-newcntprocdb-01:9983 -DnumShards=2" echo "Java Options: $JAVA_OPTS"
修改第二个tomcat的conf/server.xml文件
<?xml version='1.0' encoding='utf-8'?> <Server port="8006" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <Service name="Catalina"> <Connector port="8984" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> </Engine> </Service> </Server>
修改第二个tomcat下的solr的web.xml文件
<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>/usr/local/contentplatform/solr8984/solr</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
依次启动第一个和第二个tomcat
$ /usr/local/apache-tomcat-6.0.20-8983/bin/catalina.sh start $ /usr/local/apache-tomcat-6.0.20-8984/bin/catalina.sh start
查看
http://10.189.100.75:8983/solr/#/
http://10.189.100.75:8984/solr/#/
创建collection
http://10.189.100.75:8983/solr/admin/collections?action=CREATE&name=poi_EDBSTORE&numShards=2&collection.configName=tnpoi
===================来自一泽涟漪的博客,转载请标明出处 www.cnblogs.com/ilifeilong===================