下载oracle 依赖
yum update
yum install -y unzip
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
检查依赖完整性
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
使用root
用户执行命令
cd /
mkdir oracle
mkdir /oracle/oracle11g
groupadd -g 502 oinstall
groupadd -g 503 dba
groupadd -g 504 oper
groupadd -g 505 asmadmin
useradd -u 501 -g oinstall -G oinstall,dba,asmadmin,oper -s /bin/bash -m orac
chown -R orac:oinstall /oracle
将oracle安装包上传到oracle
目录 安装包为两个文件linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
切换orac
用户 解压压缩包, 全部解压完成后, 会多出一个database目录
su - oral
cd /oracle
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
切换root
用户修改/etc/security/limits.conf
配置文件
su root
vim /etc/security/limits.conf
orac soft nproc 2047
orac hard nproc 16384
orac soft nofile 1024
orac hard nofile 65536
orac soft stack 10240
重新加载/etc/security/limits.conf
配置文件
source /etc/security/limits.conf
修改oracl
用户环境变量
su - orac
cd
vim .bash_profile
在配置文件最下面加上
export ORACLE_BASE=/oracle/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/dbhome_1
export ORACLE_SID=prod
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin:$ORACLE_HOME/lib64
重新加载.bash_profile
配置文件
source .bash_profile
修改oracle
安装配置
cp /oracle/database/response/db_install.rsp /oracle
编辑 db_install.rsp
文件
cd /oracle
vi db_install.rsp
根据以下配置修改db_install.rsp 文件
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=服务器ip
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/oracle11g/oraInventory
ORACLE_HOME=/oracle/oracle11g/product/11.2.0.3/dbhome_1
ORACLE_BASE=/oracle/oracle11g
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=prod
oracle.install.db.config.starterdb.SID=prod
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1024
oracle.install.db.config.starterdb.password.ALL=Test1234
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oracle/oracle11g/data
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/oracle/oracle11g/fast_recovery_area
DECLINE_SECURITY_UPDATES=true
安装oracle
cd database
./runInstaller -silent -ignoreSysPrereqs -responseFile /oracle/db_install.rsp -ignorePrereq
安装完成后 切换root
用户执行/oracle/oracle11g/oraInventory/orainstRoot.sh /oracle/oracle11g/product/11.2.0.3/dbhome_1/root.sh
脚本
su root
/oracle/oracle11g/oraInventory/orainstRoot.sh
/oracle/oracle11g/product/11.2.0.3/dbhome_1/root.sh
修改/etc/profile
环境变量
vim /etc/profile
export PATH
export ORACLE_BASE=/oracle/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/dbhome_1
export ORACLE_SID=prod
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin:$ORACLE_HOME/lib64
source /etc/profile
切换orcl
配置oracle 监听
su - orcl
lsnrctl status
lsnrctl start
测试连接数据库 密码为Test1234
sqlplus / as sysdba
connect system@prod
password:Test1234
连接客户端连接数据库可能出现的问题
ORA-12514: TNS: listener does not currently know of service requested in connect descriptor 解决方案
修改listener.ora
su -oracle
lsnrctl stop
#listener.ora位置
find / -name "listener.ora"
#根据实际地址编辑listener.ora文件
vi /oracle/oracle11g/product/11.2.0.3/dbhome_1/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod)
(ORACLE_HOME = /oracle/oracle11g/product/11.2.0.3/dbhome_1)
(SID_NAME = prod)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /oracle/oracle11g
修改tnsnames.ora tnsnames.ora 与listener.ora在同一目录下
PROD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = prod)
)
)
LISTENER_PROD =(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1529))
重启oracle监听
lsnrctl start
lsnrctl status
重启oracle数据库
sqlplus / as sysdba
shutdown
startup
alter system register;