本文介绍如何在CentOS7.6上安装Oracle Database 12c Release 2
Oracle安装过程中需要将服务器(192.168.1.14)的图形界面显示到本地(192.168.1.1),本地需要启动Xserver用于显示服务器传过来的图形界面,MobaXterm提供了简单易用的Xserver启动方式
下载途径地址官方下载https://mobaxterm.mobatek.net/download-home-edition.html百度云盘https://pan.baidu.com/s/1r9jpp5IYmxXpKfC71B7Q3Q官方下载介绍
浏览其中打开官方下载地址,点击左边的便携包进行下载,如下图所示
使用oracle用户操作 将下载的oracle安装包linuxx64_12201_database.zip上传到虚拟机192.168.1.14的/home/oracle目录下
# 上传完成后,查看软件包 [oracle@localhost ~]$ pwd /home/oracle [oracle@localhost ~]$ ll 总用量 3372752 -rw-r--r--. 1 oracle oinstall 3453696911 10月 31 23:28 linuxx64_12201_database.zip # 验证软件包是否完整 [oracle@localhost ~]$ cksum linuxx64_12201_database.zip 4170261901 3453696911 linuxx64_12201_database.zip # 返回信息中第一个值为cksum,第二个值为文件大小 # 与从官方下载时,页面上的cksum和bytes进行比较,一致则说明软件包没问题安装oracle依赖的linux软件包,下面的命令不一定全,不过不用担心安装oracle的时候有检查,到时候检查出来的单独安装即可
# oracle安装需要 yum install -y compat-libcap1 libstdc++-devel sysstat gcc-c++ ksh libaio-devel smartmontools net-tools # 解压用 yum install -y unzip # 显示到本地用 yum install -y xdpyinfo创建文件/etc/sysctl.d/97-oracledatabase-sysctl.conf
vim /etc/sysctl.d/97-oracledatabase-sysctl.conf97-oracledatabase-sysctl.conf内容如下
fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 4294967295 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执行下面命令使配置生效
# 应用配置 /sbin/sysctl --system # 使用以下命令确认 /sbin/sysctl -a安装用户oracle资源限制官方建议范围
资源中文描述资源Soft LimitHard Limit文件描述符nofileat least 1024at least 65536进程nprocat least 2047at least 16384进程堆栈段的大小stackat least 10240 KBat least 10240 KB, and at most 32768 KB使用root操作
# 编辑limits.conf文件 vim /etc/security/limits.conf # 添加如下内容,对oracle用户资源限制进行配置 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft stack 10240 oracle hard stack 32768使用oracle用户操作
# 检查 soft nofile,soft nproc,soft stack [oracle@localhost ~]$ ulimit -Sn -Su -Ss open files (-n) 1024 max user processes (-u) 2047 stack size (kbytes, -s) 10240 # 检查 hard nofile,hard nproc,hard stack [oracle@localhost ~]$ ulimit -Hn -Hu -Hs open files (-n) 65536 max user processes (-u) 16384 stack size (kbytes, -s) 32768解压我们下载MobaXterm_Portable_v12.3.zip,进入解压后文件双击MobaXterm_Personal_12.3.exe进行启动,启动后界面如下图
依次点击Settings->X11,将X11 remote access改为full,最后点击OK,如下图所示 点击右上角的Xserver进行启动 启动后Xserver图标会出现彩虹颜色
使用oracle账号登入或者通过su - oracle切换到oracle账号下,我是通过oracle账号直接登入操作的,
去除I wish ...勾选状态(不接收安全更新提醒邮件),然后点击next 在弹出的提示框中选择Yes 保持默认(创建并配置一个数据库),点击Next 选择server版本,点击Next 保持默认的单实例数据库安装,点击Next 保持默认的标准安装,点击Next 为所有用户设置默认密码(我设置密码的为oracle),去除Create as Container database(12C开始提供一个实例多db的支持,此处是用于做测试,不使用此新特性。如果勾选此选项,创建出来的数据库在创建用户时需以c##开头。),点击Next 在弹出的提示框选择Yes 保持默认,点击Next 如过检查出了Swap没有通过,可以直接忽略掉,点击Next 在弹出的提示框选择Yes 点击Install开始安装 安装过程中会提示需要用root执行两个脚本, 另起一个root账号登入的终端,执行上面两个脚本
# 执行第一个脚本 [root@localhost ~]# /home/oracle/app/oraInventory/orainstRoot.sh Changing permissions of /home/oracle/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /home/oracle/app/oraInventory to oinstall. The execution of the script is complete. # 执行第二个脚本 [root@localhost ~]# /home/oracle/app/oracle/product/12.2.0/dbhome_1/root.sh Performing root user operation. The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /home/oracle/app/oracle/product/12.2.0/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: # 保持默认回车 Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root script. Now product-specific root actions will be performed. Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : # 输入yes yes Installing Oracle Trace File Analyzer (TFA). Log File: /home/oracle/app/oracle/product/12.2.0/dbhome_1/install/root_localhost.localdomain_2019-11-01_00-04-37-956550738.log Finished installing Oracle Trace File Analyzer (TFA)执行完两个脚本后,点击OK即可 经过十几分钟的安装,最终出现以下界面提示安装成功,然后点击关闭即可
配置ORACLE_HOME,并将ORACLE_HOME/bin添加到PATH中 oracle用户操作
# 编辑.bash_profile [oracle@localhost ~]$ vim .bash_profile在.bash_profile结尾添加如下配置
ORACLE_HOME=/home/oracle/app/oracle/product/12.2.0/dbhome_1 ORACLE_SID=orcl PATH=$PATH:$ORACLE_HOME/bin export PATH ORACLE_HOME ORACLE_SID执行下面命令使配置生效
[oracle@localhost ~]$ source .bash_profile配置listener.ora,默认安装完成后listener.ora内容如下
# listener.ora Network Configuration File: /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) )没有我们安装数据库实例orcl的监听需要添加以下内容
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (SID_NAME = orcl) ) )添加完成后截图如下
启动监听 [oracle@localhost ~]$ lsnrctl start LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-NOV-2019 22:31:20 Copyright (c) 1991, 2016, Oracle. All rights reserved. Starting /home/oracle/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 12.2.0.1.0 - Production System parameter file is /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora Log messages written to /home/oracle/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production Start Date 01-NOV-2019 22:31:20 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora Listener Log File /home/oracle/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully 启动数据库 # 使用sys以sysdba角色登入 [oracle@localhost ~]$ sqlplus sys/oracle@orcl as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Fri Nov 1 22:32:18 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to an idle instance. # 启动数据库 SQL> startup ORACLE instance started. Total System Global Area 763363328 bytes Fixed Size 8797440 bytes Variable Size 620757760 bytes Database Buffers 125829120 bytes Redo Buffers 7979008 bytes Database mounted. Database opened. # 退出 SQL> quit Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production参照CentOS7.6设置Oracle12cRelease2开机启动
参考列表
官方安装文档html版:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/ladbi/index.html 官方安装文档pdf版:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/ladbi/database-installation-guide-linux.pdf Oracle关闭/启动:https://www.cnblogs.com/muhehe/p/7944887.html