修改DNS(为了连接外网,使用wget)
vi /etc/resolv.conf
nameserver 114.114.114.114
安装wget
curl [http://mirrors.aliyun.com/repo/Centos-7.repo](http://mirrors.aliyun.com/repo/Centos-7.repo) >> /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
yum install wget
下载oracle
mkdir -p /home/soft/oracle
cd /home/soft
下载地址去官网点下载后查看, 因为AuthParam的值会失效, 得用最新的链接
wget -b -c --http-user=[767070765@qq.com](mailto:767070765@qq.com) --http-password=Zxc12345 --output-document=linux.x64_11gR2_database_1of2.zip "[https://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip?AuthParam=1564022768_ea88d208bc292327a1218af0de65371a](https://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip?AuthParam=1564022768_ea88d208bc292327a1218af0de65371a)"
wget -b -c --http-user=[767070765@qq.com](mailto:767070765@qq.com) --http-password=Zxc12345 --output-document=linux.x64_11gR2_database_2of2.zip "[http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip?AuthParam=1564016926_ab61e9a6581154e7c522f0c89affb295](http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip?AuthParam=1564016926_ab61e9a6581154e7c522f0c89affb295)"
安装依赖
yum -y install elfutils-libelf expat glibc glibc-common glibc-devel glibc-headers libgcc libstdc++ libstdc++-devel pdksh gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel
修改hosts
vi /etc/hosts
添加本地ip
10.226.107.33 centos-oracle
关闭防火墙及SELinux
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
新建oracle用户
groupadd oinstall;groupadd dba;useradd -g oinstall -G dba oracle
passwd oracle
修改内核参数
vi /etc/sysctl.conf
添加
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
执行
sysctl -p
修改用户限制文件
vi /etc/security/limits.conf
添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
修改登陆验证配置文件
vi /etc/pam.d/login
添加
session required /lib64/security/pam_limits.so
session required pam_limits.so
修改profile
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
创建安装目录
mkdir -p /home/soft/app/oracle/product/11.2.0
mkdir /home/soft/app/oracle/oradata
mkdir /home/soft/app/oracle/inventory
mkdir /home/soft/app/oracle/fast_recovery_area
chown -R oracle:oinstall /home/soft/app/oracle
chmod -R 775 /home/soft/app/oracle
设置oracle用户环境变量
su - oracle
vi .bash_profile
添加
ORACLE_BASE=/home/soft/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
执行
source .bash_profile
解压安装包
su - root
cd /home/soft
unzip linux.x64_11gR2_database_1of2.zip -d /home/soft/oracle/
unzip linux.x64_11gR2_database_2of2.zip -d /home/soft/oracle/
编辑安装响应文件
cd /home/soft/oracle/database/response/
cp -a db_install.rsp db_install.rsp.bak
vi db_install.rsp
修改相应位置配置
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=centos-oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/soft/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/soft/app/oracle/product/11.2.0
ORACLE_BASE=/home/soft/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
静默安装
su - oracle
cd /home/soft/oracle/database
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/soft/oracle/database/response/db_install.rsp
tail -f /home/soft/app/oracle/inventory/logs/installActions2019-07-25_12-04-19PM.log
安装完成,提示Successfully Setup Software.
su - root
sh /home/soft/app/oracle/inventory/orainstRoot.sh
sh /home/soft/app/oracle/product/11.2.0/root.sh
配置监听
su - oracle
export DISPLAY=localhost:0.0
netca -silent -responseFile /home/soft/oracle/database/response/netca.rsp
netstat -tnulp | grep 1521
静默创建数据库
su - root
vi /home/soft/oracle/database/response/dbca.rsp
修改相应位置配置
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/home/soft/app/oracle/oradata
RECOVERYAREADESTINATION=/home/soft/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"
su - oracle
dbca -silent -sysPassword oracle -systemPassword oracle -responseFile /home/soft/oracle/database/response/dbca.rsp
检查安装情况
lsnrctl status
sqlplus / as sysdba
select * from v$database;
设置开机自启
su - root
vi /home/soft/app/oracle/product/11.2.0/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /home/soft/app/oracle/product/11.2.0/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /etc/oratab
orcl:/home/soft/app/oracle/product/11.2.0:Y
vi /etc/rc.d/init.d/oracle
新增
#! /bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/home/soft/app/oracle/product/11.2.0
ORACLE_USER=oracle
case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0
cd /home/soft/app/oracle/product/11.2.0/bin/
chmod 6751 oracle
cd /var/tmp
chown -R oracle:oinstall .oracle
systemctl enable oracle
手动启动
su - oracle
cd $ORACLE_HOME/bin
./lsnrctl
start
ctrl+c
sqlplus / as sysdba
startup
出现错误
oracle ORA-12514:TNS:listener does not currently know of service requested in connect descriptor
问题原因:数据库实例没注册到listener
解决方法一:
su - oracle
cd $ORACLE_HOME/network/admin
在listener.ora里面添加了一行
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
网友评论