1创建虚拟机
2修改静态ip 192.168.6.134
3用Xshell打开
4创建java和solr文件夹
Connecting to 192.168.6.134:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Fri Dec 14 19:07:20 2018 from 192.168.6.1
[root@bogon ~]# cd /usr/local/src
[root@bogon src]# pwd
/usr/local/src
[root@bogon src]# mkdir java solr
[root@bogon src]# ls
java solr
5进入java目录,上传jdk安装包 https://pan.baidu.com/s/1oe6qMK0ZdXmovml-FfLO-w
[root@bogon src]# cd java
[root@bogon java]# pwd
/usr/local/src/java
[root@bogon java]# rz -E
rz waiting to receive.
You have new mail in /var/spool/mail/root
[root@bogon java]# ls
jdk-8u65-linux-x64.tar.gz
6解压jdk
[root@bogon java]# tar -xvf jdk-8u65-linux-x64.tar.gz
7解压完成后查看jdk安装根目录
[root@bogon java]# cd jdk1.8.0_65/
[root@bogon jdk1.8.0_65]# pwd
/usr/local/src/java/jdk1.8.0_65
8配置jdk
[root@bogon jdk1.8.0_65]# vim /etc/profile
9点击键盘的下,滚动到profile末尾,添加
#set java env
JAVA_HOME=/usr/local/src/java/jdk1.8.0_65
JAVA_BIN=/usr/local/src/java/jdk1.8.0_65/bin
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
10安下esc,敲击如下命令保存退出
:wq
11让环境变量立即生效
[root@bogon jdk1.8.0_65]# source /etc/profile
12查看一下
[root@bogon jdk1.8.0_65]# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
13拍摄快照
14进入solr目录
[root@bogon jdk1.8.0_65]# cd ..
[root@bogon java]# cd ..
[root@bogon src]# ls
java solr
[root@bogon src]# cd solr/
[root@bogon solr]# pwd
/usr/local/src/solr
15导入solr安装包 https://pan.baidu.com/s/1pCah6ZYRaGGLsfkFyGSUcQ
[root@bogon solr]# rz -E
rz waiting to receive.
[root@bogon solr]# ls
solr-5.2.1.tgz
16解压solr
[root@bogon solr]# tar -xzvf solr-5.2.1.tgz
17进入bin目录
[root@bogon solr]# ls
solr-5.2.1 solr-5.2.1.tgz
[root@bogon solr]# cd solr-5.2.1
[root@bogon solr-5.2.1]# ls
bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server
[root@bogon solr-5.2.1]# cd bin
[root@bogon bin]# ls
init.d install_solr_service.sh oom_solr.sh post solr solr.cmd solr.in.cmd solr.in.sh
18关闭防火墙
[root@bogon bin]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
19启动solr
[root@bogon bin]# sh solr start
Waiting to see Solr listening on port 8983 [\]
Started Solr server on port 8983 (pid=5110). Happy searching!
20在网页输入虚拟机ip:8983查看如
192.168.6.134:8393
21拍摄快照
22添加core-内核
Core是多个document(相当于mysql的表)数据的集合。
如果报错先忽略
/usr/local/src/solr/solr-5.2.1/server/solr/baogao/conf其实下一步我们要开始solr的配置
23准备mysql数据,并配置授权
grant [权限] on [数据库名].[表名] to ['用户名']@['web服务器的ip地址'] identified by ['密码'];
GRANT ALL PRIVILEGES ON *.* TO 'root' @'%' IDENTIFIED BY 'g';
FLUSH PRIVILEGES;
权限还有问题尝试下图,用SQLyog链接工具手动赋予权限
24进入server目录,创建文件夹
bogon bin]# pwd
/usr/local/src/solr/solr-5.2.1/bin
[root@bogon bin]# cd ../
[root@bogon solr-5.2.1]# ls
bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server
[root@bogon solr-5.2.1]# cd server/solr
[root@bogon solr]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr
[root@bogon solr]# ls
configsets README.txt solr.xml zoo.cfg
[root@bogon solr]# mkdir baogao
[root@bogon solr]# ls
baogao configsets README.txt solr.xml zoo.cfg
25再创建子文件夹conf和data
[root@bogon solr]# cd baogao
[root@bogon baogao]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr/baogao
[root@bogon baogao]# mkdir conf data
[root@bogon baogao]# ls
conf data
[root@bogon baogao]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr/baogao
26准备配置文件
https://pan.baidu.com/s/1-Q9YJaRR2Wdyqte3RBYyTw
注意到ip:192.168.6.1,这个是自己真实电脑的VMnet8的IPV4地址
dih-config.xml
id
27上传这些配置文件
[root@bogon baogao]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr/baogao
[root@bogon baogao]# ls
conf data
[root@bogon baogao]# cd conf
[root@bogon conf]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr/baogao/conf
[root@bogon conf]# rz -E
rz waiting to receive.
[root@bogon conf]# ls
admin-extra.html admin-extra.menu-bottom.html admin-extra.menu-top.html dih-config.xml schema.xml solrconfig.xml
28进入dist目录
[root@bogon conf]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr/baogao/conf
[root@bogon conf]# cd ../../../../
[root@bogon solr-5.2.1]# ls
bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server
[root@bogon solr-5.2.1]# cd dist
[root@bogon dist]# pwd
/usr/local/src/solr/solr-5.2.1/dist
[root@bogon dist]# ls
solr-analysis-extras-5.2.1.jar solr-core-5.2.1.jar solr-langid-5.2.1.jar solr-solrj-5.2.1.jar test-framework
solr-analytics-5.2.1.jar solr-dataimporthandler-5.2.1.jar solr-map-reduce-5.2.1.jar solr-test-framework-5.2.1.jar
solr-cell-5.2.1.jar solr-dataimporthandler-extras-5.2.1.jar solr-morphlines-cell-5.2.1.jar solr-uima-5.2.1.jar
solr-clustering-5.2.1.jar solrj-lib
29使用fz下载solr-dataimporthandler-5.2.1.jar和 solr-dataimporthandler-extras-5.2.1.jar,自己找
或者直接从网盘下载,这四个文件https://pan.baidu.com/s/14aIb8ZgkWUgnTSCj7gUvTA
30进入lib目录
[root@bogon dist]# pwd
/usr/local/src/solr/solr-5.2.1/dist
[root@bogon dist]# cd ..
[root@bogon solr-5.2.1]# ls
bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server
[root@bogon solr-5.2.1]# cd server/solr-webapp/webapp/WEB-INF/lib/
[root@bogon lib]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr-webapp/webapp/WEB-INF/lib
[root@bogon lib]# ls
antlr-runtime-3.5.jar dom4j-1.6.1.jar httpcore-4.4.1.jar lucene-highlighter-5.2.1.jar protobuf-java-2.5.0.jar
asm-4.1.jar fastutil-6.5.11.jar httpmime-4.4.1.jar lucene-join-5.2.1.jar solr-core-5.2.1.jar
asm-commons-4.1.jar guava-14.0.1.jar joda-time-2.2.jar lucene-memory-5.2.1.jar solr-solrj-5.2.1.jar
commons-cli-1.2.jar hadoop-annotations-2.6.0.jar lucene-analyzers-common-5.2.1.jar lucene-misc-5.2.1.jar spatial4j-0.4.1.jar
commons-codec-1.10.jar hadoop-auth-2.6.0.jar lucene-analyzers-kuromoji-5.2.1.jar lucene-queries-5.2.1.jar stax2-api-3.1.4.jar
commons-collections-3.2.1.jar hadoop-common-2.6.0.jar lucene-analyzers-phonetic-5.2.1.jar lucene-queryparser-5.2.1.jar t-digest-3.1.jar
commons-configuration-1.6.jar hadoop-hdfs-2.6.0.jar lucene-backward-codecs-5.2.1.jar lucene-spatial-5.2.1.jar woodstox-core-asl-4.4.1.jar
commons-fileupload-1.2.1.jar hll-1.6.0.jar lucene-codecs-5.2.1.jar lucene-suggest-5.2.1.jar zookeeper-3.4.6.jar
commons-io-2.4.jar hppc-0.5.2.jar lucene-core-5.2.1.jar noggit-0.6.jar
commons-lang-2.6.jar htrace-core-3.0.4.jar lucene-expressions-5.2.1.jar org.restlet-2.3.0.jar
concurrentlinkedhashmap-lru-1.2.jar httpclient-4.4.1.jar lucene-grouping-5.2.1.jar org.restlet.ext.servlet-2.3.0.jar
31导入第29步四个jar包
[root@bogon lib]# rz -E
rz waiting to receive.
[root@bogon lib]# ls
antlr-runtime-3.5.jar hadoop-annotations-2.6.0.jar lucene-analyzers-phonetic-5.2.1.jar mysql-connector-java-5.1.28-bin.jar
asm-4.1.jar hadoop-auth-2.6.0.jar lucene-backward-codecs-5.2.1.jar noggit-0.6.jar
asm-commons-4.1.jar hadoop-common-2.6.0.jar lucene-codecs-5.2.1.jar org.restlet-2.3.0.jar
commons-cli-1.2.jar hadoop-hdfs-2.6.0.jar lucene-core-5.2.1.jar org.restlet.ext.servlet-2.3.0.jar
commons-codec-1.10.jar hll-1.6.0.jar lucene-expressions-5.2.1.jar protobuf-java-2.5.0.jar
commons-collections-3.2.1.jar hppc-0.5.2.jar lucene-grouping-5.2.1.jar solr-core-5.2.1.jar
commons-configuration-1.6.jar htrace-core-3.0.4.jar lucene-highlighter-5.2.1.jar solr-dataimporthandler-5.2.1.jar
commons-fileupload-1.2.1.jar httpclient-4.4.1.jar lucene-join-5.2.1.jar solr-dataimporthandler-extras-5.2.1.jar
commons-io-2.4.jar httpcore-4.4.1.jar lucene-memory-5.2.1.jar solr-solrj-5.2.1.jar
commons-lang-2.6.jar httpmime-4.4.1.jar lucene-misc-5.2.1.jar spatial4j-0.4.1.jar
concurrentlinkedhashmap-lru-1.2.jar ik-analyzer-5.3.0.jar lucene-queries-5.2.1.jar stax2-api-3.1.4.jar
dom4j-1.6.1.jar joda-time-2.2.jar lucene-queryparser-5.2.1.jar t-digest-3.1.jar
fastutil-6.5.11.jar lucene-analyzers-common-5.2.1.jar lucene-spatial-5.2.1.jar woodstox-core-asl-4.4.1.jar
guava-14.0.1.jar lucene-analyzers-kuromoji-5.2.1.jar lucene-suggest-5.2.1.jar zookeeper-3.4.6.jar
32进入web-inf创建classes文件夹
[root@bogon lib]# cd ..
[root@bogon WEB-INF]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr-webapp/webapp/WEB-INF
[root@bogon WEB-INF]# ls
lib weblogic.xml web.xml
[root@bogon WEB-INF]# mkdir classes
33进入classes文件夹
[root@bogon WEB-INF]# ls
classes lib weblogic.xml web.xml
[root@bogon WEB-INF]# cd classes
34准备如下配置文件(如果不对关键词进行黑白名单过滤可不必添加)
https://pan.baidu.com/s/1bDK8-hjlhPMaPEW0TwRezQ
ik_ext.dic为关键词白名单
航空
报告
飞机
ik_stopwords.dic为关键词黑名单
a
an
and
are
as
at
be
but
by
for
if
in
into
is
it
no
not
of
on
or
such
that
the
their
then
there
these
they
this
to
was
will
with
35上传这些文件到classes
[root@bogon WEB-INF]# cd classes
[root@bogon classes]# ls
[root@bogon classes]# rz -E
rz waiting to receive.
[root@bogon classes]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr-webapp/webapp/WEB-INF/classes
[root@bogon classes]# ls
IKAnalyzer.cfg.xml ik_ext.dic ik_stopwords.dic
36进入bin重启solr
[root@bogon classes]# pwd
/usr/local/src/solr/solr-5.2.1/server/solr-webapp/webapp/WEB-INF/classes
[root@bogon classes]# cd ../../../../../
[root@bogon solr-5.2.1]# ls
bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server
[root@bogon solr-5.2.1]# cd bin
[root@bogon bin]# ls
init.d install_solr_service.sh oom_solr.sh post solr solr-8983.pid solr.cmd solr.in.cmd solr.in.sh
[root@bogon bin]# sh solr restart
Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 5110 to stop gracefully.
Waiting to see Solr listening on port 8983 [\]
Started Solr server on port 8983 (pid=6127). Happy searching!
37重新导入数据库文件,在网页点击add Core
38点击core selector
39再点击baogao
40如果Command下是full-import,点击Execute
41注意关闭windows防火墙,如果只想打开3306可按如下做法
42如果成功会显示更新了多少Documents