一、安装前环境准备
下载linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip,上传到对应的文件夹中,此处放在/home下。
二、操作系统工作
1.使用root用户登录操作系统。
2.yum安装unzip软件,解压oracle的安装文件
yum install -y unzip
unzip linux.x64_11gR2_database_1for2.zip&&linux.x64_11gR2_database_2for2.zip
3.编辑/et/hosts文件,在其中添加主机名
echo "127.0.0.1 localhost" >> /etc/hosts
4.关闭selinux
sed -i "7cSELINUX=disabled" /etc/selinux/config
setenforce 0
5.关闭防火墙
service iptables stop
6.用yum方式安装Oracle的依赖包
yum install yum install 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 –y
7.添加安装用户和用户组并设置密码
groupadd oinstall;
groupadd dba;
groupadd oper;
useradd -g oinstall -G dba,oper oracle;
passwd oracle;
8.修改内核参数
sed -i "34c#" /etc/sysctl.conf
sed -i "37c#" /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
sysctl -p;
其中kernel.shmmax =2147483648为本机物理内存的一半。
9.修改用户的限制文件
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "oracle soft stack 10240" >> /etc/security/limits.conf
修改/etc/pam.d/login文件
echo "session required pam_limits.so" >> /etc/pam.d/login
修改/etc/profile文件
echo "if [ $USER = "oracle" ]; then" >> /etc/profile
echo "if [ $SHELL = "/bin/ksh" ]; then" >> /etc/profile
echo "ulimit -p 16384" >> /etc/profile
echo "ulimit -n 65536" >> /etc/profile
echo "else" >> /etc/profile
echo "ulimit -u 16384 -n 65536" >> /etc/profile
echo "fi" >> /etc/profile
echo "fi" >> /etc/profile
10.创建安装目录和设置文件权限
mkdir /home/oracledb;
chown oracle:oinstall /home/oracledb;
chmod 755 /home/oracledb;
mkdir /home/oraInventory;
chown oracle:oinstall /home/oraInventory;
chmod 755 /home/oraInventory;
11.设置oracle用户的环境变量
echo "ORACLE_BASE=/home/oracledb; #安装目录" >> /home/oracle/.bash_profile
echo 'ORACLE_HOME=$ORACLE_BASE/11g; #oracle家目录 '>> /home/oracle/.bash_profile
echo "ORACLE_SID=orcl; #实例名 " >> /home/oracle/.bash_profile
echo 'LD_LIBRARY_PATH=$ORACLE_HOME/lib; ' >> /home/oracle/.bash_profile
echo 'PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin; ' >> /home/oracle/.bash_profile
echo "export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH;" >> /home/oracle/.bash_profile
source /home/oracle/.bash_profile #使之前的配置生效
12.把解压出的database文件夹移动到/home/oracle文件夹下,赋权限。
cd /home
mv database /home/oracle
chmod -R 700 ./database;
chown -R oracle:oinstall ./database;
13.编辑静默安装响应文件
cd /home/oracle/database/response
vim db_install.rsp
需要设置的参数为
29 oracle.install.option=INSTALL_DB_SWONLY
37 ORACLE_HOSTNAME=CentOS
42 UNIX_GROUP_NAME=oinstall
47 INVENTORY_LOCATION=/home/oraInventory
78 SELECTED_LANGUAGES=en,zh_CN
83 ORACLE_HOME=/home/oracledb/11g
88 ORACLE_BASE=/home/oracledb
99 oracle.install.db.InstallEdition=EE
142 oracle.install.db.DBA_GROUP=dba
147 oracle.install.db.OPER_GROUP=dba
385 DECLINE_SECURITY_UPDATES=true
三、根据响应文件静默安装Oracl 11gR2
su oracle
cd /home/oracle/database
unset DISPLAY
./runInstaller -force -silent -noconfig -responseFile /home/oracle/database/response/db_install.rsp -ignorePrereq
切换到root用户下,执行
/home/oraInventory/orainstRoot.sh
/home/oracledb/11g/root.sh
四、以静默方式配置监听
$ORACLE_HOME/bin/netca /silent /responsefile /home/oracle/database/response/netca.rsp
如果报错
/home/oracledb/11g/bin/netca: line 178: 26734 Aborted (core dumped) $JRE $JRE_OPTIONS -classpath $CLASSPATH oracle.net.ca.NetCA $*
需要修改默认主机名
/etc/sysconfig/network
/etc/hosts
之后在root用户下执行
hostname 【修改后主机名】
重新切换到oracle用户下,执行命令即可
五、以静默方式建库,同时建立一个对应的实例
vim /home/oracle/database/response/dbca.rsp
设置参数
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "tgram123"
SYSTEMPASSWORD = "tgram123"
SYSMANPASSWORD = "tgram123"
DBSNMPPASSWORD = "tgram123"
DATAFILEDESTINATION =/home/oracledb/11g/oradata
RECOVERYAREADESTINATION=/home/oracledb/11g/fast_recovery_area
CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "AL32UTF8"
TOTALMEMORY = "1638"
其中TOTALMEMORY = "1638" 为1638MB,物理内存2G*80%。
dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
建库后进行实例进程检查:
ps -ef | grep ora_ | grep -v grep
查看监听状态:
lsnrctl status
登陆查看实例状态
sqlplus / as sysdba
SQL> select status from v$instance;