1.准备工作
1.1.修改 DNS
vi /etc/resolv.conf
nameserver 114.114.114.114
1.2.安装 wget
curl http://mirrors.aliyun.com/repo/Centos-7.repo >> /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
yum install wget
1.3.下载 oracle
mkdir -p /home/soft/oracle
cd /home/soft
下载文件到这
下载地址去官网点下载后查看, 因为 AuthParam 的值会失效, 得用最新的链接
wget -b -c --http-user=XXX --http-password=XXX --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=XXX --http-password=XXX --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)"
2.安装依赖
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 libXext.i686 libXext
3.修改 hosts
vi /etc/hosts
添加本地 ip(XXX.XXX.XXX.XXX 改为你服务器的 ip)
XXX.XXX.XXX.XXX centos-oracle
4.关闭防火墙及 SELinux
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
5.新建 oracle 用户
groupadd oinstall;groupadd dba;useradd -g oinstall -G dba oracle
passwd oracle
6.修改内核参数
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
7.修改用户限制文件
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
8.修改登陆验证配置文件
vi /etc/pam.d/login
添加
session required /lib64/security/pam_limits.so
session required pam_limits.so
9.修改 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
保存后执行
source /etc/profile
10.创建安装目录
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
11.设置 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
12.解压安装包
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/
13.编辑安装响应文件
cd /home/soft/oracle/database/response/
cp -a db_install.rsp db_install.rsp.bak
vi db_install.rsp
14.修改相应位置配置
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
15.静默安装
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
16.配置监听
su - oracle
export DISPLAY=localhost:0.0
netca -silent -responseFile /home/soft/oracle/database/response/netca.rsp
netstat -tnulp | grep 1521
17.静默创建数据库
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
18.检查安装情况
lsnrctl status
sqlplus / as sysdba
select * from v$database;
19.手动启动
su - oracle
cd $ORACLE_HOME/bin
./lsnrctl
start
ctrl+c
sqlplus / as sysdba
startup
20.常见错误
oracle ORA-12514:TNS:listener does not currently know of service requested in connect descriptor
问题原因:数据库实例没注册到 listener
解决方法:
su - oracle
cd $ORACLE_HOME/network/admin
vim listener.ora
在 listener.ora 里面添加了一行
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于