- 安装JVM环境
- 略
- 安装相关数据包:
- 在redhat下要oracle时要使用的包:
- binutils-2.17.50.0.6-2.el5
- compat-libstdc++-33-3.2.3-61
- elfutils-libelf-0.125-3.el5
- elfutils-libelf-devel-0.125
- glibc-2.5-12
- glibc-common-2.5-12
- glibc-devel-2.5-12
- glibc-headers-2.5-12
- gcc-4.1.1-52
- gcc-c++-4.1.1-52
- libaio-0.3.106
- libaio-devel-0.3.106
- libgcc-4.1.1-52
- libstdc++-4.1.1
- libstdc++-devel-4.1.1-52.e15
- make-3.81-1.1
- sysstat-7.0.0
- 经过测试本ubuntu环境要安装的包:
- Binutils
- gcc-4.4
- lesstif2
- Libaio1
- gawk
- alien
- Ksp
- Sysstat
- 可用以下命令安装:
#apt-get install binutils gcc-4.4 libaio1 gawk alien ksh sysstat build-essential libmotif3 alien libtool lsb-rpm
- 在安装时最好用dpkg –l 包名来确定是否安装
- 改变ubuntu的环境
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /usr/bin/basename /bin/basename
#ln -sf /bin/bash /bin/sh
- 11g针对的linux系统基本就是redhat,所以还要作一些工作
# mkdir /etc/rc.d
# ln -s /etc/rc0.d /etc/rc.d/rc0.d
# ln -s /etc/rc2.d /etc/rc.d/rc2.d
# ln -s /etc/rc3.d /etc/rc.d/rc3.d
# ln -s /etc/rc4.d /etc/rc.d/rc4.d
# ln -s /etc/rc5.d /etc/rc.d/rc5.d
# ln -s /etc/rc6.d /etc/rc.d/rc6.d
# ln -s /etc/init.d /etc/rc.d/init.d
- 创建连接时也可以用
- echo "Red Hat Linux release 4" > /etc/redhat-release
#for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
#ln -s /etc/init.d /etc/rc.d/init.d
- 加入下面这个文件来模拟redhat.
#echo “Red Hat Linux release 4″ > /etc/redhat-release
# addgroup oinstall
# addgroup dba
# addgroup nobody
# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash -m oracle
# usermod -g nobody nobody
# mkdir -p /u01/app/oracle
#chown -R oracle:dba /u01
- 编辑/etc/sysctl.conf,加入以下内容
#vi /etc/sysctl.conf
kernel.shmmax = 3147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
- 编辑/etc/security/limits.conf,255)">#vi /etc/security/limits.conf
- 安装oracle
- 没有网络监听器,客户端就无法通过网络连接Oralce服务器。要在命令行安装网络监听器。编辑/u01/database/response/netca.rsp文件
- 创建临时表空间
- 要测试数据安装是否成功,可按顺序执行以下两个步骤:
- 测试步骤 : 请执行操作系统级的命令:tnsping sid
- 上述命令假定全局数据库名是 sid。以下是命令执行后的示例:
- 如果没有看到此结果,不要继续进行下一步。请检查:
- 使用 Oracle Net Configuration Assistant 检查网络配置(netca 命令)
- 使用 Database Configuration Assistant 检查数据库配置(dbca 命令)
- 测试步骤:
- Oracle的关闭
$ps –ef | grep ora_
- 查看oracle内存:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 65530
oracle hard nofile 65536
- 编辑/etc/pam.d/login,255)">#vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
- 然后通过命令:sysctl -p 让刚才增加的东西生效
#Sysctl -p
- 设置环境变量(注意:JAVA的变量也要设好;如果版本更变,要适当调整。)
#vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#vi /home/oracle/.profile
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=jinting
export ORACLE_HOME=/u01/app/oracle/product/11.2
export PATH=$PATH:$ORACLE_HOME/bin
#su - oracle
- 验证环境变量是否设置成功
#echo $ORACLE_HOME
- 如反回数据为之前所设,即为正常
# Vi /u01/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=hostname
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
- 用以下命令安装:
#chown -R oracle:dba /u01
#./runInstaller -ignorePrereq -ignoreSysPrereqs -noconfig -silent -responseFile /u01/database/response/db_install.rsp
- 各安装参数的含义如下
- 安装网络监听器
#vi /u01/database/response/netca.rsp
SHOW_GUI=false
LOG_FILE="/oracle11gHome/network/tools/log/netca.log"
- 用下列命令安装监听器:
/u01/app/oracle/product/11.2/bin/netca /silent /responseFile /u01/database/response/netca.rsp
vi /u01/database/response/dbca.rsp
SID = "jinting"
SYSPASSWORD = "password"
SYSTEMPASSWORD = "password"
SYSMANPASSWORD = "password"
DBSNMPPASSWORD = "password"
DATAFILEDESTINATION ="/u01/app/oracle/flash_recovery_area"
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "6000"
SCRIPTDESTINATION ="/u01/app/oracle/product/11.2/sysman/admin/scripts"
- 然后运行
/u01/app/oracle/product/11.2/bin/dbca -silent -responseFile /u01/database/response/dbca.rsp
- 最后执行两个脚本
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2/root.sh
- oracle数据导入导出
create temporary tablespace jt_temp_1
tempfile '/home/oracle/jinting/jt_temp1.dbf'
size 5120m
autoextend on
next 64m maxsize 20480m
extent management local;
- 创建数据表空间
create tablespace jt_data
logging
datafile '/home/oracle/jinting/jt_data1.dbf'
创建用户并指定表空间
create user jinting identified by 1111
default tablespace jt_data
temporary tablespace jt_temp_1;
- 给用户授予权限
grant connect,resource,dba to jinting;
- 数据导入
imp userid=jinting/1111 full=y file=*.dmp ignore=y
- 数据导出
exp jinting/1111 file=dbname.dmp full=y
- oracle的测试
oracle@hipi-desktop:~$ tnsping jinting
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-JUL-2010 10:57:52
Copyright (c) 1997,2009,Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2/network/admin/sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
OK (30 msec)
- 其中,结果 OK 至关重要。 上述结果如果正确,表明侦听器配置无误。
oracle@hipi-desktop:~$ sqlplus user/password@jinting
sql*Plus: Release 11.2.0.1.0 Production on Thu Jul 8 11:01:21 2010
Copyright (c) 1982,255)">ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning,OLAP,Data Mining and Real Application Testing options
sql> SELECT 1+2+3+4 FROM DUAL;
1+2+3+4
----------
$sqlplus /nolog
sql>connect /as sysdba
sql>startup
- 验证:
$sqlplus system/manager
sql>select count(*) from tab;
$lsnrctl start
- 或者使用
$lsnrctl
LSNRCTL> start
- 验证与检查:
$lsnrctl status
- 查看监听器状态报告是否启动。(查看当前服务器提供的监听服务也使用该命令)
$ipcs