Deploy Solr search engine in Centos
I,Environment preparation:
System Environment: centos 6.5
Tomcat 7.0.47
Jdk-7u9
Solr-4.7.0
First, upload the package to the/tmp directory.
1. jdk Installation
[Root @ svn-server/] # cd/tmp/
[Root @ svn-server/] # tar zxvf jdk-7u9-linux-x64.tar.gz
[Root @ svn-server/] # mv jdk1.7.0 _ 09/usr/
[Root @ svn-server/] # vi/etc/profile
Copy the following code in the last line to add the following content:
JAVA_HOME =/usr/jdk1.7.0 _ 09/
CLASSPATH =.: $ JAVA_HOME/lib/tools. jar
PATH = $ JAVA_HOME/bin: $ PATH
Export JAVA_HOME CLASSPATH PATH
Save and exit (: wq !) Then, execute the following command to take effect:
Source/etc/profile
2. tomcat installation
Decompress the tomcat package to the tmp directory:
[Root @ svn-server tmp] tar zxvf apache-tomcat-7.0.47.tar.gz
Move the tomcat package to/usr/local/tomcat:
[Root @ svn-server tmp] mv apache-tomcat-7.0.47/usr/local/tomcat
Ii. Install solr
1. Decompress solr
[Root @ svn-server tmp] tar-zxvf solr-4.7.0.tgz
2. Move the solr package to the opt directory:
[Root @ svn-server tmp] mv/tmp/solr-4.7.0/opt/solr
3. Copy solr. war in exmaple/webapps to tomcat
[Root @ svn-server tmp] makdir-p/opt/tomcat/webapps
[Root @ svn-server tmp] cp/opt/solr/example/webapps/solr. war/opt/tomcat/webapps/
[Root @ svn-server tmp] vi/usr/local/tomcat/conf/server. xml
<Host name = "localhost" appBase = "/opt/tomcat/webapps"
UnpackWARs = "true" autoDeploy = "true">
Change webapps to/opt/tomcat/webapps;
4. Start tomcat, automatically decompress solr. war, and modify web. xml under the solr project.
[Root @ svn-server tmp] cd/usr/local/tomcat/bin/
[Root @ svn-server bin]./startup. sh
[Root @ svn-server bin] vi/opt/tomcat/webapps/solr/WEB-INF/web. xml
5. Modify the solr home configuration (Note: You need to remove the comments of this Section, otherwise it will not take effect ):
<Env-entry>
<Env-entry-name> solr/home </env-entry-name>
<Env-entry-value>/opt/solr/example/solr </env-entry-value>
<Env-entry-type> java. lang. String </env-entry-type>
</Env-entry>
6. Copy the jar package under solr/example/lib/ext to/tomcat/../solr/WEB-INF/lib:
[Root @ svn-server tmp] cp/opt/solr/example/lib/ext/*. jar/opt/tomcat/webapps/solr/WEB-INF/lib/
7. Create classpath under tomcat solr and copy example/resources/log4j. properties to classpath:
[Root @ svn-server tmp] mkdir-p/opt/tomcat/webapps/solr/classpath
[Root @ svnserver tmp] cp/opt/solr/example/resources/log4j. properties/opt/tomcat/webapps/solr/classpath/
8. Restart tomcat after configuration is complete.
/Usr/local/tomcat/bin/shutdown. sh
/Usr/local/tomcat/bin/startup. sh
9. Enter http: // 192.168.1.196: 8080/solr/in the browser to go to The solr admin screen.
4. simple installation is complete!
5. Install the word splitting tool: IK Analyzer 2012FF_hf1
1) Upload the downloaded IKAnalyzer2012FF_u1.jar to/opt/tomcat/webapps/solr/WEB-INF/lib
[Root @ localhost lib] # pwd
/Opt/tomcat/webapps/solr/WEB-INF/lib
2) settingsIKAnalyzer Chinese Word Segmentation
Modify schema. xml in/opt/solr/example/solr/collection1/conf and add the following content to <type> </types>:
<! -- IKAnalyzer Chinese Word Segmentation -->
<FieldType name = "text" class = "solr. TextField">
<Analyzer class = "org. wltea. analyzer. lucene. IKAnalyzer">
</Analyzer>
</FieldType>
6. Restart tomcat:
[Root @ localhost yuanxiaoku] #/usr/local/tomcat/bin/shutdown. sh
[Root @ localhost yuanxiaoku] #/usr/local/tomcat/bin/start. sh
Test the preceding content N times in person! No problem !!!! Welcome to comments
VII. New Core required by the company:
After you click Add Core, an error is returned.
The reason for this problem has been found for a long time. Through log analysis, it may be because the source path is not found and the path matching is incorrect. How can this problem be solved? The moderator has the following ideas to solve the problem:
[Root @ localhost solr] # pwd
/Opt/solr/example/solr
We can see that the above path copies the files in the collection1 directory to your new Core under solr (Note: you do not need to copy the data directory)
Take my yuanxiaoku as an example:
[Root @ localhost solr] # ll
Total 24
Drwxr-xr-x. 2 root 4096 Feb 18 2014 bin
Drwxr-xr-x. 4 root 4096 Nov 8 10: 55collection1
-Rw-r --. 1 root 2473 Feb 18 2014 README.txt
-Rw-r --. 1 root 1715 Feb 18 2014 solr. xml
Drwxr-xr-x. 2 root 4096 Nov 8 13: 28 yuanxiaoku
-Rw-r --. 1 root 501 Feb 18 2014 zoo. cfg
[Root @ localhost solr] # cd collection1/
[Root @ localhost collection1] # ll
Total 16
Drwxr-xr-x. 6 root 4096 Nov 8 conf
-Rw-r --. 1 root 16 Feb 18 2014 core. properties
Drwxr-xr-x. 4 root 4096 Nov 8 10: 55 data
-Rw-r --. 1 root 2146 Feb 18 2014 README.txt
[Root @ localhost collection1] # cp-r conf ../yuanxiaoku/
[Root @ localhost collection1] #
[Root @ localhost collection1] #
[Root @ localhost collection1] # cp-r README.txt ../yuanxiaoku/
Copy conf and README.txt to the yuanxiaoku directory;
[Root @ localhost solr] # cd yuanxiaoku/
[Root @ localhost yuanxiaoku] # ll
Total 24
Drwxr-xr-x. 6 root 4096 Nov 8 conf
-Rw-r --. 1 root 133 Nov 8 11: 00 core. properties
Drwxr-xr-x. 4 root 4096 Nov 8 13:33 data
-Rw-r --. 1 root 2146 Nov 8 13:32 README.txt
-Rw -------. 1 root 6447 Nov 8 10:51 server. xml
After seeing the above results, we can restart tomcat !! The exciting time has arrived.
[Root @ localhost yuanxiaoku] #/usr/local/tomcat/bin/shutdown. sh
[Root @ localhost yuanxiaoku] #/usr/local/tomcat/bin/start. sh
Now access: http: // 192.168.250.105: 8080/solr/
We can see that the Core of yuanxiaoku can call the database normally! Now, what we have done is successful!
Note: you must pay attention to the firewall !!! You can add the default allowed port, or directly disable the firewall on the Intranet.
[Root @ solr-server ~] # Service iptables stop