hl10502的博客

CentOS7.2安装Oracle 12c

在CentOS7.2上安装Oracle数据库12c。

环境

  • CentOS Linux release 7.2.1511 (Core) Mini版
  • 本地 Win7

安装软件包

安装所需软件包(可以先执行 yum update -y 更新系统,也可以不更新)

1
[root@localhost ~]# yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64 smartmontools net-tools zip unzip

配置桌面

安装X Window系统

1
[root@localhost ~]# yum groupinstall -y "X Window System"

Oracle配置

创建用户及群组

1
2
3
4
5
6
7
8
9
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -G dba oracle
[root@localhost ~]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

修改/etc/sysctl.conf文件,增加以下内核参数配置

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1987162112
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 = 1048586

应用新的内核参数值,并显示所有内核参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1987162112
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 = 1048586
[root@localhost ~]# sysctl -a
....
....

修改 /etc/security/limits.conf,增加以下配置为oracle设置上限

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

创建/stage目录,并更改用户和组

1
2
[root@localhost ~]# mkdir /stage/
[root@localhost ~]# chown -R oracle:oinstall /stage/

为Oracle安装文件和Oracle数据库文件创建新目录,并赋权

1
2
3
4
[root@localhost ~]# mkdir -p /u01 /u02
[root@localhost ~]# chown -R oracle:oinstall /u01 /u02
[root@localhost ~]# chmod -R 775 /u01 /u02
[root@localhost ~]# chmod g+s /u01 /u02

下载&解压Oracle

下载Oracle Database 12c Release 2的Linux x86-64版本:
linuxx64_12201_database.zip

解压oracle安装文件

1
[root@localhost ~]# unzip linuxx64_12201_database.zip -d /stage/

GUI安装Oracle

运行Xming

下载Xming http://sourceforge.net/projects/xming/files/latest/download,安装并运行Xming

SSH连接

打开PuTTY, 在PuTTY的设置窗口,选择 Connection –> SSH –> X11,勾选“Enable X11 forwarding”选项

putty-1.png

点击Session,输入连接的主机名称或IP地址
putty-2.png

使用oracle用户登录
putty-3.png

安装Oracle

切换到/stage/database/目录,执行runInstaller脚本安装Oracle

1
2
3
4
5
6
7
8
[oracle@localhost ~]$ cd /stage/database/
[oracle@localhost database]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 39203 MB Passed
Checking swap space: must be greater than 150 MB. Actual 7807 MB Passed
Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-11-29_03-01-59AM. Please wait ...[oracle@localhost database]$

图形化安装过程

上面执行runInstaller脚本之后,弹出Oracle图形化安装界面,点击“Next>”
orc-1.png

在“Installation Option”中,选择“Create and configure a database”,然后点击“Next>”
orc-2.png

在“System Class”中,选择“Desktop class”,然后点击“Next>”
orc-3.png

在“Typical Installation”中,设置:
Oracle base:/u01/app/oracle
Software location: /u01/app/oracle/product/12.2.0/dbhome_1
Database file location: /u02
OSDBA group: dba
Global database name:输入名称
Password:输入密码
Confirm password:再次输入
取消选中“Create as Container database”

orc-4.png

这里告警提示管理密码:[INS-30011]输入的 ADMIN 口令不符合 Oracle 建议的标准,可以直接忽略点击“Next>”。
输入密码遵循“小写字母+数字+大写字母”的方式就可以消除告警,然后点击“Next>”
orc-4-1.png

在“Create Inventory”中,设置:
Inventory Directory: /u01/app/oraInventory
oraInventory Group Name:使用’ oinstall ‘组

然后点击“Next>”
orc-5.png

在“Prerequisite Checks”中,勾选“Ignore All”(这里如果有其他的check比如smartmontools、net-tools包没装,需要先安装好),然后点击“Next>”
orc-6.png

在“Summary”中,如果有修改的可以在这里编辑相应配置,点击“Next>”
orc-7.png

安装进度
orc-8.png

需要以root用户执行以下两个sh脚本
orc-9.png

执行orainstRoot.sh脚本

1
2
3
4
5
6
7
[root@localhost ~]# sh /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.sh脚本,然后回车键设置local bin directory,选择安装Oracle Trace File Analyzer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost ~]# sh /u01/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= /u01/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
Installing Oracle Trace File Analyzer (TFA).
Log File: /u01/app/oracle/product/12.2.0/dbhome_1/install/root_localhost.localdomain_2017-11-29_05-16-20-360969054.log
Finished installing Oracle Trace File Analyzer (TFA)

安装完成
orc-10.png

测试

sqlplus登录

使用oracle用户登录数据库服务器,设置oracle环境,使用sqlplus登录orcl,可以执行SQL语句来查看“select * from v$instance”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@localhost ~]# su oracle
[oracle@localhost root]$ export ORACLE_SID=orcl
[oracle@localhost root]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/
[oracle@localhost root]$ export PATH=$PATH:$ORACLE_HOME/bin
[oracle@localhost root]$ sqlplus system@orcl
SQL*Plus: Release 12.2.0.1.0 Production on Thu Nov 30 03:09:17 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select * from v$instance;

Web登录

先关闭防火墙

1
[root@localhost ~]# systemctl stop firewalld.service

浏览器访问 https://[oracle ip]:5500/em/,使用system用户,在“Typical Installation”中设置的密码登录
orcl-web.png

登录之后
orcl-web-2.png

参考

https://wiki.centos.org/HowTos/Oracle12onCentos7

https://wiki.centos.org/zh/HowTos/Xming

问题

安装“X Window System”之后,启动进不了系统

请参考CentOS7.2安装“X Window System”之后,启动进不了系统