您好,登錄后才能下訂單哦!
rpm包一般都有默認的安裝路徑,如何你要更改默認路徑,有沒有辦法呢?當然有。我們來看下面的例子。
比如在安裝JDK (Java Development Kit)或JRE (Java Runtime Environment)時,這個Redhat package文件的默認安裝路徑是/usr/java。如果你要安裝在其它路徑下,例如要放到/home/java目錄下,該如何做呢?
一、首先查看rpm包的詳細信息
[root@oracle ~]# rpm -qpi jdk-6u43-linux-amd64.rpm
Name : jdk Relocations: /usr/java
Version : 1.6.0_43 Vendor: Oracle and/or its affiliates.
Release : fcs Build Date: Fri 01 Mar 2013 09:03:27 PM CST
Install Date: (not installed) Build Host: jb6-lin-amd64.sfbay.sun.com
Group : Development/Tools Source RPM: jdk-1.6.0_43-fcs.src.rpm
Size : 127075557 License: Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. Also under other license(s) as shown at the Description field.
Signature : (none)
Packager : Java Software <jre-comments@java.sun.com>
URL : http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary : Java(TM) Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).
The JDK is a development environment for building applications, applets
and components that can be deployed with the Java Platform Standard
Edition Runtime Environment.
這個JDK是默認要裝在/usr/java 下的。
下面我們這樣來設置參數,就可以把JDK裝在你指定的目錄下。
[root@sharesan ~]# rpm -i --badreloc --relocate /usr/java=/home/java jdk-6u43-linux-amd64.rpm
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
ln: creating symbolic link `/usr/java/jdk1.6.0_43': No such file or directory
參數釋義:
badreloc是強制把文件安裝到你想要的地方。
relocate就是只把應該裝到oldpath下的文件安裝到newpath,實現將一部分文件安裝到其它的路徑,而不是把所有的這個包的文件都替換。
但是無論是prefix還是relocate都不見得可以真正可以用,因為有的包或者文件不允許裝到其他路徑,比如oracleasm-support-2.1.8-1.el6.x86_64.rpm
[root@oracle ~]# rpm -qpi oracleasm-support-2.1.8-1.el6.x86_64.rpm
warning: oracleasm-support-2.1.8-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Name : oracleasm-support Relocations: (not relocatable)
Version : 2.1.8 Vendor: Oracle Corporation
Release : 1.el6 Build Date: Sat 09 Feb 2013 06:46:49 AM CST
Install Date: (not installed) Build Host: ca-build44.us.oracle.com
Group : System Environment/Kernel Source RPM: oracleasm-support-2.1.8-1.el6.src.rpm
Size : 221696 License: GPL
Signature : RSA/8, Sat 09 Feb 2013 06:50:30 AM CST, Key ID 72f97b74ec551f03
Packager : Joel Becker <joel.becker@oracle.com>
URL : http://oss.oracle.com/projects/oracleasm/
Summary : The Oracle Automatic Storage Management support programs.
Description :
Tools to manage the Oracle Automatic Storage Management library driver
not relocatable不能重定位,是無法修改安裝目錄的,只有去掉 --prefix參數了。
[root@sharesan ~]# java -version
-bash: /usr/bin/java: No such file or directory
這時沒有顯示JAVA版本號,是因為環境變量還沒修改。
下面修改一下JAVA的環境變量
[root@sharesan jdk1.6.0_43]# vi /etc/profile
JAVA_HOME=/home/java/jdk1.6.0_43
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
"/etc/profile" 85L, 1961C written
[root@sharesan jdk1.6.0_43]# source /etc/profile
使環境變量生效。
再查看,就有JAVA版本號顯示了。
[root@sharesan jdk1.6.0_43]# java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
補充一下:
在安裝JDK時,需要查看一下原系統是否有其他的JAVA版本號,如果跟你要裝的不一致,請卸載后再裝。
[root@sharesan ~]# java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
進行查找
[root@sharesan ~]# rpm -aq |grep java
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
強制卸載
[root@sharesan ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@sharesan ~]# rpm -aq |grep java
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@sharesan ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
再檢查,發現已卸載干凈。
[root@sharesan ~]# java -version
-bash: /usr/bin/java: No such file or directory
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。