linux 静默安装 oracle 11
linux 版本
[root@oracle ~]# cat /etc/issueCentOS release 6.5 (Final)Kernel \r on an \m
环境检查
top - 16:05:23 up 8:34, 2 users, load average: 0.00, 0.00, 0.00Tasks: 152 total, 1 running, 151 sleeping, 0 stopped, 0 zombieCpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stMem: 1906556k total, 1094320k used, 812236k free, 58280k buffersSwap: 2097144k total, 0k used, 2097144k free, 839620k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1654 oracle -2 0 1185m 14m 13m S 0.7 0.8 1:52.05 oracle 1799 oracle 20 0 1190m 49m 44m S 0.3 2.7 0:05.11 oracle 16699 root 20 0 15036 1268 948 R 0.3 0.1 0:00.02 top 1 root 20 0 19364 1540 1228 S 0.0 0.1 0:02.77 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root RT 0 0 0 0 S 0.0 0.0 0:00.30 migration/0 4 root 20 0 0 0 0 S 0.0 0.0 0:00.11 ksoftirqd/0 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 6 root RT 0 0 0 0 S 0.0 0.0 0:00.05 watchdog/0 7 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/1 8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1 9 root 20 0 0 0 0 S 0.0 0.0 0:00.11 ksoftirqd/1 10 root RT 0 0 0 0 S 0.0 0.0 0:00.05 watchdog/1 11 root RT 0 0 0 0 S 0.0 0.0 0:00.25 migration/2
df -h
检查 swap分区、内存、磁盘大小
安装 jdk
下载 jdk-8u73-linux-x64.rpm
安装
rpm -ivh jdk-8u91-linux-x64.rpm
配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_91
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
测试
source /etc/profilejava -version
使用 root 用户配置环境变量
关闭 selinux
selinux 配置文件
[root@oracle ~]# cat /etc/sysconfig/selinux# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted
临时关闭
setenforce 0
永久关闭
vim /etc/selinux/config
SELINUX=disabled
关闭防火墙
service iptables stopsystemctl stop firewalldsystemctl disable firewalld
修改主机名
hostname centos
在/etc/hosts文件中添加主机名
[root@centos ~]# vi /etc/hosts127.0.0.1 localhost localhost::1 localhost centos
ORA-00130: invalid listener address
添加与主机名与IP对应记录,不然在安装数据库时会报错
安装依赖包
yum install gccyum install gcc-c++yum install libaio-develyum install compat-gcc-34yum install compat-gcc-34-c++
建立用户和组
groupadd oinstallgroupadd dbagroupadd operuseradd -g oinstall -G dba,oper oracleecho "oracle" | passwd --stdin oracleid oracle
[root@oracle ~]# id oracleuid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba),502(oper)
建立安装目录、设置文件权限
mkdir -p /u01/app/oracle /product/11.2.0/db_1mkdir /u01/app/oracle/oradatamkdir /u01/app/oracle/oraInventorymkdir /u01/app/oracle/fast_recovery_areachown -R oracle:oinstall /u01/appchmod -R 775 /u01/app
修改参数
内核参数
vim /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
注:kernel.shmmax = 1073741824(byte)为本机物理内存的一半
修改系统资源限制
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
修改用户验证选项
vim /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
修改用户配置文件
vim /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
修改 oracle 用户环境变量
vim ~oracle/.bash_profile
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
ORACLE_SID=orcl
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
准备安装文件
上传安装包到 /tmp 目录下解压修改应答文件进行静默安装
oracle 安装文件名
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
修改权限
chown -R oracle:oinstall ./linux.x64_11gR2_database_1of2.zipchown -R oracle:oinstall ./linux.x64_11gR2_database_2of2.zip
切换 oracle 用户、使修改的环境变量生效
su - oraclesource .bash_profile
解压安装包、复制应答文件到 oracle 用户的目录下
cd /tmpunziap ./linux.x64_11gR2_database_1of2.zipunziap ./linux.x64_11gR2_database_2of2.zipcp -R /tmp/database/response/ /home/oracle/cd /home/oracle/response/
应答文件
db_install.rsp:安装应答
dbca.rsp:创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置的应答
Oracle 11g 静默安装-db_install.rsp详解
修改应答文件
vim ./db_install.rsp
oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME= localhost.localdomainUNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/u01/app/oraInventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1ORACLE_BASE=/u01/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=dbaDECLINE_SECURITY_UPDATES=true
部分参数含义
各参数含义如下:-silent 表示以静默方式安装,不会有任何提示-force 允许安装到一个非空目录-noconfig 表示不运行配置助手netca-responseFile 表示使用哪个响应文件,必需使用绝对路径oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改oracle.install.option 安装选项,本例只安装oracle软件,该参数不要更改DECLINE_SECURITY_UPDATES 是否需要在线安全更新,设置为false,该参数不要更改ORACLE_HOSTNAME 安装主机名UNIX_GROUP_NAME oracle用户用于安装软件的组名INVENTORY_LOCATION oracle产品清单目录SELECTED_LANGUAGES oracle运行语言环境,一般包括引文和简繁体中文ORACLE_HOME Oracle安装目录ORACLE_BASE oracle基础目录oracle.install.db.InstallEdition 安装版本类型,一般是企业版oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上了oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label Security和Database Vaultoracle.install.db.DBA_GROUP oracle用户用于授予OSDBA权限的组名oracle.install.db.OPER_GROUP oracle用户用于授予OSOPER权限的组名
静默安装
cd /tmp/database./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq...#Root scripts to run/u01/app/oracle/oraInventory/orainstRoot.sh/u01/app/oracle/product/11.2.0/db_1/root.shTo execute the configuration scripts: 1. Open a terminal window 2. Log in as "root" 3. Run the scripts 4. Return to this window and hit "Enter" key to continueSuccessfully Setup Software.
安装完毕后会提示上述的信息,按照要求使用 root 用户执行上面的两个脚本
静默配置监听程序
使用 oracle 用户
netca /silent /responsefile /home/oracle/response/netca.rsp
检验
1、在 /u01/app/oracle/product/11.2.0/db_1/network/admin/
中生成 listener.ora
和 sqlnet.ora
ll /u01/app/oracle/product/11.2.0/db_1/network/admin/
2、通过netstat命令可以查看1521端口正在监听
netstat -tnul | grep 1521
静默方式建库
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage 30 -emConfiguration LOCAL...85% complete96% complete100% completeLook at the log file "/opt/app/oracle/cfgtoollogs/dbca/ora11g/ora11g.log" for further details.
数据库成功安装之后默认是启动状态
检验
1、进行实例进程检查
ps -ef | grep ora_ | grep -v grep
2、查看监听状态
lsnrctl status
3、登录查看实例状态
sqlplus / as sysdba
设置Linux开机自启动七、 设置Linux开机自启动
修改ORACLE_HOME_LISTNER
将下面两个文件的ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /u01/app/oracle/product/11.2.0/db_1/bin/dbstartvim /u01/app/oracle/product/11.2.0/db_1/bin/dbshut
配置oratab
vi /etc/oratab
找到testsid:/opt/oracle/102:N,改为testsid:/opt/oracle/102:Y
配置rc.local
vi /etc/rc.d/rc.local
添加如下行
su oracle -lc "/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"su oracle -lc /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
增加权限
chmod +x /etc/rc.d/rc.local
开放1521端口允许网络连接
service iptables stopvi /etc/sysconfig/iptables# Generated by iptables-save v1.4.7 on Fri Dec 16 07:29:41 2016*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [10:892]-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT# Completed on Fri Dec 16 07:29:41 2016service iptables saveservice iptables restart