01、solr学习-安装前准备

1.创建solr用户和秘密

useradd -m solr
passwd solr

2.tar -cvf solr.tar zip

3.CentOS下安装SecureCRT的sz/rz工具包

lrzsz是在Linux/Unix平台上同Windows进行ZModem文件上传下载,非常有好用命令行工具,相比FTP工具方便很多。

  • sz:将选定的文件发送(send)到本地机器;
  • rz:运行该命令会弹出一个文件选择窗口, 从本地选择文件上传到服务器(receive)。

新安装的CentOS5.5系统,在secureCRT下使用rz sz 上传下载文件时出现如下提示:

\[root@webslave2 etc\]\# sz hosts  
\-bash: sz: command not found  
\[root@webslave2 etc\]\#  

由上述现象可知,很可能没有安装相应的软件包;sz rz 命令所需要的软件包是lrzsz
下面检查软件包是否安装?

\[root@webslave2 etc\]\# yum list installed lrzsz  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
\* addons: mirror.neu.edu.cn  
\* base: mirror.neu.edu.cn  
\* extras: mirror.neu.edu.cn  
\* updates: mirror.neu.edu.cn  
Error: No matching Packages to list 由此可知没有安装此包  
\[root@webslave2 etc\]\#  

下面安装lrzsz软件包,可通过yum安装,比较方便!
先查看下载源中的软件包


\[root@webslave2 etc\]\# yum search lrzsz  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
\* addons: mirror.neu.edu.cn  
\* base: mirror.neu.edu.cn  
\* extras: mirror.neu.edu.cn  
\* updates: mirror.neu.edu.cn  
===================== Matched: lrzsz ==========================  
lrzsz.x86\_64 : The lrz and lsz modem communications programs.  

安装软件包(使用yum自动安装:)


\[root@webslave2 etc\]\# yum -y install lrzsz  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
\* addons: mirror.neu.edu.cn  
\* base: mirror.neu.edu.cn  
\* extras: mirror.neu.edu.cn  
\* updates: mirror.neu.edu.cn  
Setting up Install Process  
Resolving Dependencies  
\--> Running transaction check  
\---> Package lrzsz.x86\_64 0:0.12.20-22.1 set to be updated  
\--> Finished Dependency Resolution

Dependencies Resolved
=======================================================================  
Package Arch Version Repository Size
======================================================================  
Installing:  
lrzsz x86\_64 0.12.20-22.1 base 88 k  
Transaction Summary  
=======================================================================  
Install 1 Package(s)  
Upgrade 0 Package(s)

Total download size: 88 k  
Downloading Packages:  
lrzsz-0.12.20-22.1.x86\_64.rpm | 88 kB 00:00  
Running rpm\_check\_debug  
Running Transaction Test  
Finished Transaction Test  
Transaction Test Succeeded  
Running Transaction  
Installing : lrzsz 1/1  
Installed:  
lrzsz.x86\_64 0:0.12.20-22.1  
Complete!

来自: http://www.cnblogs.com/zhangdsh/archive/2011/08/03/2126694.html

4.CentOS 卸载自带OpenJdk


\[root@demoserver ~\]\# rpm -qa | grep java  
java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86\_64  
tzdata-java-2011l-4.el6.noarch  
\[root@demoserver ~\]\# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86\_64  
\[root@demoserver ~\]\# rpm -qa | grep java  
tzdata-java-2011l-4.el6.noarch  

安装好的CentOS会自带OpenJdk,用命令 java -version ,会有下面的信息:

java version "1.6.0"  
OpenJDK Runtime Environment (build 1.6.0-b09)  
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)  

最好还是先卸载掉openjdk,在安装sun公司的jdk.
先查看rpm -qa | grep java
显示如下信息:

java-1.4.2-gcj-compat-1.4.2.0-40jpp.115  
java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5  

卸载:

rpm-e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115  
rpm-e --nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5  

还有一些其他的命令:

  • rpm-qa | grep gcj
  • rpm-qa | grep jdk

如果出现找不到openjdk source的话,那么还可以这样卸载

yum-y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115  
yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5 

5.CentOS 安装jdk1.6.0

第一、JDK1.6安装准备
从sun公司网站www.sun.com下载linux版本的jdk,我下载的版本是JDK 6 ,
地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html
   http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

打开终端,用cd命令进入jdk所在目录

给JDK文件授予执行权限:

chmod +x jdk-6u35-linux-x64-rpm.bin  

执行安装命令:

./jdk-6u7-linux-i586.bin  

如遇错误,可先切换至root用户下,su root,再执行安装命令
安装成功会在/usr/java目录下生成jdk1.6.0_35目录,就是jdk的安装目录
打开终端,输入java -version
如若有显示java的版本信息,则表示安装成功,

第二步、具体操作安装过程


\[root@demoserver soft\]\# ll  
total 67268  
\-rw-r--r--. 1 root root 68881069 Feb 10 2014 jdk-6u45-linux-x64-rpm.bin  
\[root@demoserver soft\]\# chmod o+x jdk-6u45-linux-x64-rpm.bin  
\[root@demoserver soft\]\# ll  
total 67268  
\-rw-r--r-x. 1 root root 68881069 Feb 10 2014 jdk-6u45-linux-x64-rpm.bin  
\[root@demoserver soft\]\# ./jdk-6u45-linux-x64-rpm.bin  
Unpacking...  
Checksumming...  
Extracting...  
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([Zip-Bugs@lists.wku.edu][Zip-Bugs_lists.wku.edu]).  
inflating: jdk-6u45-linux-amd64.rpm  
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm  
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm  
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm  
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm  
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm  
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm  
Preparing... \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[100%\]  
1:jdk \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[100%\]  
Unpacking JAR files...  
rt.jar...  
jsse.jar...  
charsets.jar...  
tools.jar...  
localedata.jar...  
plugin.jar...  
javaws.jar...  
deploy.jar...  
Installing JavaDB  
Preparing... \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[100%\]  
1:sun-javadb-common \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[ 17%\]  
2:sun-javadb-core \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[ 33%\]  
3:sun-javadb-client \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[ 50%\]  
4:sun-javadb-demo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[ 67%\]  
5:sun-javadb-docs \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[ 83%\]  
6:sun-javadb-javadoc \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \[100%\]

Done.  
\[root@demoserver jdk1.6.0\_45\]\# java -version  
java version "1.6.0\_45"  
Java(TM) SE Runtime Environment (build 1.6.0\_45-b06)  
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

第三步:设置环境变量


\[root@demoserver local\]\# ln -s /usr/java/jdk1.6.0\_45 jdk  
\[root@demoserver local\]\# pwd  
/usr/local  
\[root@demoserver local\]\# ll  
total 40  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include  
lrwxrwxrwx. 1 root root 21 Jan 26 22:40 jdk -> /usr/java/jdk1.6.0\_45  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib  
drwxr-xr-x. 3 root root 4096 Nov 26 03:02 lib64  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin  
drwxr-xr-x. 6 root root 4096 Nov 26 03:02 share  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src

vi打开文件命令:

vi /etc/profile  

移至文件末尾插入一个空行:输入字母o
输入以下配置信息:(注:这里的分隔符是冒号不是分号)

JAVA\_HOME=/usr/local/jdk  
PATH=$JAVA\_HOME/bin:$PATH  
CLASSPATH=.:$JAVA\_HOME/lib/dt.jar:$JAVA\_HOME/lib/tools.jar  
export JAVA\_HOME  
export PATH  
export CLASSPATH

第四步:配置环境变量生效

\[root@demoserver etc\]\# echo `$`JAVA\_HOME  
\[root@demoserver etc\]\# source /etc/profile  
\[root@demoserver etc\]\# echo `$`JAVA\_HOME  
/usr/local/java  

6.CentOS 安装tomcat

第一步、下载apache-tomcat-6.0.35.tar.gz

第二步、解压apache-tomcat-6.0.35.tar.gz

\[root@demoserver soft\]\# tar -xvf apache-tomcat-6.0.20.tar.gz  

第三步、复制路径

\[root@demoserver soft\]\# cp -R apache-tomcat-6.0.20 /usr/local/tomcat  

第四步、创建对应的软链接

\[root@demoserver local\]\# ln -s /usr/tomcat6.0/ tomcat  
\[root@demoserver local\]\# ll  
total 40  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include  
lrwxrwxrwx. 1 root root 21 Jan 26 22:40 jdk -> /usr/java/jdk1.6.0\_45  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib  
drwxr-xr-x. 3 root root 4096 Nov 26 03:02 lib64  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin  
drwxr-xr-x. 6 root root 4096 Nov 26 03:02 share  
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src  
lrwxrwxrwx. 1 root root 15 Jan 27 01:36 tomcat -> /usr/tomcat6.0/  

第五步、vi打开文件命令:

vi /etc/profile  

移至文件末尾插入一个空行:输入字母o
输入以下配置信息:(注:这里的分隔符是冒号不是分号)

\# Tomcat environment  
CATALINA\_BASE=/usr/local/tomcat  
CATALINA\_HOME=/usr/local/tomcat  
export CATALINA\_BASE CATALINA\_HOME

第六步、CentOS安装完成Tomcat后,访问本地:http://localhost:8080/正确。但局域网http://192.168.12.128:8080/内无法访问
问题原因:执行/etc/init.d/iptables status命令会得到一系列信息,说明防火墙开着

\[root@demoserver init.d\]\# /etc/init.d/iptables status  
Table: filter  
Chain INPUT (policy ACCEPT)  
numtarget prot opt source destination  
1ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED  
2ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0  
3ACCEPT all -- 0.0.0.0/0 0.0.0.0/0  
4ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:21  
5ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22  
6ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:69  
7REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)  
numtarget prot opt source destination  
1REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)  
numtarget prot opt source destination  

解决方案:关闭防火墙

\[root@demoserver init.d\]\# /etc/init.d/iptables  
Usage: iptables \{start|stop|restart|condrestart|status|panic|save\}  
\[root@demoserver init.d\]\# /etc/init.d/iptables stop  
iptables: Flushing firewall rules: \[ OK \]  
iptables: Setting chains to policy ACCEPT: filter \[ OK \]  
iptables: Unloading modules: \[ OK \]  

如果永久关闭,需要执行:

chkconfig --level 35 iptables off

\[root@demoserver init.d\]\# /etc/init.d/iptables status  
iptables: Firewall is not running.

ok,通过以上问题立刻解决。