What is Solr?
Most search engines use must have some sort of search function , the search function is often huge consumption of resources , which are due to the heavy database load and bankrupt our application performance , we generally put it all in to do a search when the transfer alone among external search to a server perform.
Apache Solr is a popular open source search server for building search applications. Is an independent enterprise search application servers that provide external similar to the Web-service API interface. It is built on top of Lucene (full-text search engine). Solr is an enterprise-class, is fast and highly scalable. Users can http request, submit the XML file format to a certain search engine server generates an index; can also be made to find a request by Http Get operation, and get back the results in XML format.
Why use Solr?
① lack of highlights from the SQL database on the performance. Basically, we need to use our query JOIN operation .
② natural characteristic data of the document: loose text files, such queries are required to use the LIKE . However joins and likes are performance killers in the current database engine is inconvenient.
solr bottom uses an inverted index , and this data structure is similar to beautify dictionary.
Solr Key Features
1. The standards-based open interfaces: Solr search server support via XML, JSON and HTTP queries and get results .
2. Easy Management: Solr through HTML pages management, Solr configuration through XML completed.
3. Scalability: can be efficiently copied into another Solr search server.
4. A flexible plug-in architecture: the new features in the form of plug-ins can easily add to the Solr server.
The powerful data import functions: database and other structured data source can now be introduced, mapping and transformation.
Solr installation
First, the installation of the package shown in the figure uploaded to the server, here put in the position I is / usr / local / solr
Second, unzip Tomcat, Solr (.tar) and IKAnalyzer (.zip)
1. Unzip Tomcat command
① decompression: tar -zxvf apache-tomcat-8.5.32.tar.gz
② renamed tomcat: mv apache-tomcat-8.5.32 tomcat
③ random number generation tool (some environment already installed):
Installation rngd Service: yum install mgd tools
Start Service: systemctl start rngd
④ open tomcat: ./ startup.sh - here just to enter the ip address command to test whether Tomcat has started
⑤ stopped tomcat: ./ shutdown.sh - due to open in the previous step, this step is closed, behind need to unpack war package
2. Extract solr
tar -zxvf solr-4.10.3.tar
3. Extract IK
unzip IKAnalyzer.zip
Third, to copy solr.war / under tomcat webapp
①cd /usr/local/solr/solr-4.10.3/example/webapps/
②cp solr.war /usr/local/solr/tomcat/webapps/
Fourth, let solr.war tomcat start automatically extract
①启动Tomcat:/usr/local/solr/tomcat/bin/startup.sh
② into the war package location: cd / usr / local / solr / tomcat / webapps /
③ Check war package is unpacked: ls
④ If you want to delete solr.war, need to be stopped tomcat, delete: /usr/local/solr/tomcat/bin/shutdown.sh
⑤ into the webapps delete solr.war package (first stopped tomcat go delete solr.war, otherwise solr folder disappears):
cd /usr/local/solr/tomcat/webapps/
rm -rf solr.war
Fourth, the packets in all the jar solr-4.10.3 / example / lib / ext / catalog copy / usr / local / solr / tomcat / webapps / solr / WEB-INF / lib directory
① to copy the jar package: cd /usr/local/solr/solr-4.10.3/example/lib/ext
② Copy all: cp * / usr / local / solr / tomcat / webapps / solr / WEB-INF / lib
Fifth, the solr documents in solr-4.10.3 / example / directory folder to / usr / local / solr / directory and rename solrhome
① This is the place solr stored data (inventory data to Solr in place)
② enter example directory: cd /usr/local/solr/solr-4.10.3/example/
③ solr copy the folder to another location: cp -r solr / usr / local / solr /
④ solr will be renamed solrhome:
cd /usr/local/solr
mv solr solrhome
Sixth, configure tomcat / webapps / solr / WEB-INF / web.xml location
① into the WEB-INF: cd / usr / local / solr / tomcat / webapps / solr / WEB-INF /
② modify web.xml: vim web.xml
③ Open comments, add solrhome: / usr / local / solr / solrhome
④停止tomcat:/usr/local/solr/tomcat/bin/shutdown.sh
⑤ start tomcat (long waiting time): / usr / local / solr / tomcat / bin / startup.sh
⑥测试是否安装成功:浏览器打开,输入你的solr安装地址:如10.30.35.33:8080/solr
七、解决遗留问题,删除3个压缩包
①进入solr文件夹下:cd /usr/local/solr/
②删除命令:
rm -rf apache-tomcat-8.5.32.tar.gz
rm -rf IKAnalyzer.zip
rm -rf solr-4.10.3.tar
注:IK Analyzer是中文分词器,将在另外一篇博文对其进行介绍。