redhat 6.5 安装solr
安装环境的准备:jdk,tomcat
# cat /etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m
vim /etc/profile.d/java.sh
PATH=${PATH}:/usr/local/jdk1.8.0_101/bin
# java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
# tar xvf apache-tomcat-7.0.55.tar.gz
配置solr.home环境变量:
vim catalina.sh
JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/home/solr"
配置solr端口:
vim server.xml
<Server port="8985" shutdown="SHUTDOWN">
<Connector port="8983" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8989" protocol="AJP/1.3" redirectPort="8443" />
mv solr-4.10.4/dist/solr-4.10.4.war /opt/app/apache-tomcat-7.0.55/webapps/solr.war
# cp solr-4.10.4/example/lib/ext/* /opt/app/apache-tomcat-7.0.55/lib/
mkdir /home/solr
cp solr-4.10.4/example/solr/* /home/solr/ -rf
/opt/app/apache-tomcat-7.0.55/bin/catalina.sh start
# tailf /opt/app/apache-tomcat-7.0.55/logs/catalina.out
http://172.26.5.142:8983/solr/#/
二、solr安装IK中文分词包
IKAnalyzer2012FF_u1.jar /opt/app/apache-tomcat-7.0.55/webapps/solr/WEB-INF/lib/
三、solr常用查询。
1、solr 范围查询 occurNum:[7 TO 13]
比如时间格式的查询:
firstOccurTime:["2017-07-17T08:55:10Z" TO "2017-07-17T10:55:10Z"]
firstOccurTime:["2017-07-17 08:55:10" TO "2017-07-17 10:55:10"]
2、solr 多条件查询:
id: A-2852 AND id:A-2853 OR id:A-2854
3、solr 过滤
通过fq 字段过滤
四、solr的热备份,主要是通过ip:port/solr/replication?command=backup来进行热备份
#!/bin/sh . /etc/profile ip=172.26.5.117 port=8983 bakdir=/home/solr/backup remotedir=/home/solr/backup remotehost=‘172.26.5.127‘ suffix=date "+%Y%m%d%H" copy=5 bakdata(){ /usr/bin/elinks --dump "http://${ip}:${port}/solr/replication?command=backup&location=${bakdir}" } remotebak(){ scp $bakdir/snapshot.${suffix}* $remotehost:$remotedir } clearbak(){ ssh $remotehost "find $remotedir -type d -maxdepth 1 -mtime +$copy -exec rm -rf {} \;" find $bakdir -type d -maxdepth 1 -mtime +$copy -exec rm -rf {} \; } echo "----------------------------------------" date +‘===DATA BACKUP BEGIN:%Y%m%d %T=====‘ bakdata date +‘===DATA BACKUP END:%Y%m%d %T=====‘ date +‘===SCP BEGIN:%Y%m%d %T=====‘ remotebak date +‘===SCP END:%Y%m%d %T=====‘ date +‘===CLS BEGIN:%Y%m%d %T=====‘ clearbak date +‘===CLS END:%Y%m%d %T=====‘ echo -e "\n" echo -e "\n"