1 下载安装包
Oracle 11.2.0.4的安装包共7个压缩文件,可以分别解压每个压缩文件,安装数据库时需要解压前两个安装包。第三个包是grid安装包,在安装rac时首先安装这个包。
前两个包的名字是:
[oracle@my_ob tmp]$ ls-l p133* -rw-r--r--1 root root 1395582860 Sep 614:57 p13390677_112040_Linux-x86-64_1of7.zip -rw-r--r--1 root root 1151304589 Sep 709:57 p13390677_112040_Linux-x86-64_2of7.zip
用unzip命令解压这两个文件,默认这两个文件都会解压到当前目录的database目录下。要注意的是这两个包都要解压,如果直接压第一个包,Oracle软件的安装、监听器创建都会成功,创建数据库时会报找不到数据库模板错误。
2 创建Oracle数据库组和用户
以下脚本在root用户下执行
groupadd -g500 oinstall groupadd -g501 dba useradd -u500-g oinstall -G dba oracle
创建用户后,给这个用户创建一个密码
#passwd oracle
3 创建目录,更改目录属主和权限
mkdir-p /u01/app/oracle
这里可以只创建Oracle base目录,Oracle home目录和inventory目录在安装过程中会自动创建。
更改目录属主和权限
mkdir-p /u01/app/oracle chown-R oracle:oinstall /u01/ chmod-R755 /u01/
4 编辑用户环境变量
用vi编辑oracle 用户home目录下.bash_profile文件,在文件末尾加入以下内容。
exportORACLE_BASE=/u01/app/oracle exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 exportORACLE_SID=Oracle11g exportPATH=$PATH:$ORACLE_HOME/bin exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
5 编辑oracle用户资源限制
echo"oracle hard nproc 16384" >> /etc/security/limits.conf echo"oracle soft nofile 10240" >> /etc/security/limits.conf echo"oracle hard nofile 65536" >> /etc/security/limits.conf echo"oracle soft stack 10240" >> /etc/security/limits.conf echo"oracle hard stack 32768" >> /etc/security/limits.conf echo"* soft memlock 104857600" >> /etc/security/limits.conf echo"* hard memlock 104857600" >> /etc/security/limits.conf
6 编辑操作系统核心参数
echo"fs.aio-max-nr = 1048576" >> /etc/sysctl.conf #configure linux kernel aioecho"fs.file-max = 6815744" >> /etc/sysctl.conf echo"kernel.shmall = 2097152" >> /etc/sysctl.conf #total share memory segment in pagesecho"kernel.shmmax = 536870912" >> /etc/sysctl.conf #size in bytes recommend more than half of total memoryecho"kernel.shmmni = 4096" >> /etc/sysctl.conf echo"kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf echo"net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf echo"net.core.rmem_default=262144" >> /etc/sysctl.conf echo"net.core.rmem_max=262144" >> /etc/sysctl.conf echo"net.core.wmem_default=262144" >> /etc/sysctl.conf echo"net.core.wmem_max=262144" >> /etc/sysctl.conf
编辑完了使用sysctl -p 命令使参数生效。
7 编辑/etc/pam.d/login
64位操作系统需要编辑这个文件
echo"session required /lib/security/pam_limits.so" >> /etc/pam.d/login echo"session required pam_limits.so" >> /etc/pam.d/login
8 安装依赖包
yum install gcc gcc-c++make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel
安装完之后检验以下所需的依赖包是否都已安装
rpm -qgcc gcc-c++make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel | grep'not installed'
上面这个命令的输出结果应该是空的。
9 安装数据库软件
9.1 准备响应文件
在解压目录的response目录下有三个响应文件模板
[root@my_ob database]# ls -l response total 80-rwxrwxrwx1 root root 44533 Aug 272013 dbca.rsp -rwxr-xr-x1 oracle oinstall 25116 Sep 616:35 db_install.rsp -rwxrwxrwx1 root root 5871 Aug 272013 netca.rsp
db_install.rsp是数据库软件安装的响应文件模板,可以根据自己的需要编辑后用户数据库软件的静默安装。本次安装的用的响应文件如下:
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=my_ob UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.EEOptionsSelection=falseoracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba DECLINE_SECURITY_UPDATES=trueoracle.installer.autoupdates.option=SKIP_UPDATES
这个响应文件只安装软件,不创建数据库,(oracle.install.option=INSTALL_DB_SWONLY),不进行安全更新和自动更新。
9.2 运行runInstaller命令进行安装
以下命令如无提示,都在oracle用户下执行。
[oracle@my_ob database]$ ./runInstaller -silent-noconfig-ignorePrereq-responseFile /tmp/database/db_install.rsp Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 13838 MB Passed Checking swap space: must be greater than 150 MB. Actual 6143 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-09-06_04-52-51PM. Please wait ...[oracle@my_ob database]$ You can find the log of this install session at: /u01/app/oraInventory/logs/installActions2022-09-06_04-52-51PM.log The installation of Oracle Database 11g was successful. Please check '/u01/app/oraInventory/logs/silentInstall2022-09-06_04-52-51PM.log'for more details. As a root user, execute the following script(s): 1. /u01/app/oraInventory/orainstRoot.sh 2. /u01/app/oracle/product/11.2.0/db_1/root.sh Successfully Setup Software.
9.3 运行脚本
根据提示以root身份运行2个脚本。
[root@my_ob tmp]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete. [root@my_ob tmp]# /u01/app/oracle/product/11.2.0/db_1/root.sh Check /u01/app/oracle/product/11.2.0/db_1/install/root_my_ob_2022-09-06_16-55-45.log for the output of root script
10 创建监听
监听的创建使用监听响应文件模板即可,不用做任何修改,将创建一个名字为Listener的监听。
oracle@my_ob database]$ netca /silent -responsefile /tmp/database/netca.rsp Parsing command line arguments: Parameter "silent"=true Parameter "responsefile"= /tmp/database/netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Oracle Net Listener Startup: Running Listener Control: /u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully. Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
11 创建数据库
11.1 准备响应文件
拷贝编辑dbca.rsp,这个响应文件有非常详细的说明,大部分选项都是非强制的,都有默认值,本次安装的响应文件如下:
[GENERAL] RESPONSEFILE_VERSION ="11.2.0"OPERATION_TYPE ="createDatabase"[CREATEDATABASE] GDBNAME ="orcl11g.us.oracle.com"SID ="orcl11g"TEMPLATENAME ="General_Purpose.dbc"SYSPASSWORD = sys SYSTEMPASSWORD = system CHARACTERSET = ZHS16GBK NATIONALCHARACTERSET= AL16UTF16
11.2 创建数据库
[oracle@my_ob ~]$ dbca-silent-responseFile /tmp/database/dbca.rsp Copying database files 1% complete 3% complete 11% complete 18% complete 26% complete 37% complete Creating and starting Oracle instance 40% complete 45% complete 50% complete 55% complete 56% complete 60% complete 62% complete Completing Database Creation 66% complete 70% complete 73% complete 85% complete 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log"for further details.
11.3 登录数据库,检查数据文件位置
SQL> select file_name, tablespace_name from dba_data_files FILE_NAME TABLESPACE_NAME ------------------------------------------------------------------ /u01/app/oracle/oradata/orcl11g/users01.dbf USERS /u01/app/oracle/oradata/orcl11g/undotbs01.dbf UNDOTBS1 /u01/app/oracle/oradata/orcl11g/sysaux01.dbf SYSAUX /u01/app/oracle/oradata/orcl11g/system01.dbf SYSTEM
默认的数据文件建立在$ORACLE_BASE/oradata目录下。