赞
踩
本安装指南说明如何在Centos7中安装Oracle12c
Reference System:
[root@yuan ~]# hostnamectl
Static hostname: yuan
Icon name: computer-laptop
Chassis: laptop
Machine ID: 28ea7433e24341a892abab3fd175abc8
Boot ID: 7f9eb0c180e14bd99d6db7b5ae6d1416
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.10.1.el7.x86_64
Architecture: x86-64
成功安装操作系统后,请验证主机名并将其注册到DNS中。或者将主机名/IP添加到/etc/hosts。
[root@yuan ~]# cat /etc/hostname
yuan
使SELinux处于强制模式,并启用防火墙
[root@yuan ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
[root@yuan ~]# firewall-cmd --state
running
Update the CentOS system with the latest packages
使用最新的软件包更新CentOS系统
[root@yuan ~]# yum update -y
官网下载地址:https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
Create required OS users and groups for Oracle Database.
为Oracle数据库创建所需的操作系统用户和组
[root@yuan ~]# groupadd oinstall
[root@yuan ~]# groupadd dba
[root@yuan ~]# useradd -g oinstall -G dba oracle
[root@yuan ~]# passd oracle #回车后输入Oracle用户的密码,如myoracle
Add the following kernel parameters to the */etc/sysctl.conf
将以下内核参数添加到/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
[root@yuan ~]# sysctl -p
Specify limits for oracle user in the /etc/security/limits.conf
在/etc/security/limits.conf中指定Oracle用户的限制
[root@yuan ~]# vim /etc/security/limits.conf 然后在文件末尾添加如下代码
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
[root@yuan ~]# yum install -y zip unzip # 最新版本已经内置安装了zip与unzip,这句可以不执行
# 解压
[root@yuan ~]# unzip linuxx64_12201_database.zip -d /stage/
[root@yuan ~]# chown -R oracle:oinstall /stage/
Create /u01 directory for Oracle software and /u02 for database files.
为Oracle软件创建/u01目录,为数据库文件创建/u02目录。
[root@yuan ~]# mkdir /u01
[root@yuan ~]# mkdir /u02
[root@yuan ~]# chown -R oracle:oinstall /u01
[root@yuan ~]# chown -R oracle:oinstall /u02
[root@yuan ~]# chmod -R 775 /u01
[root@yuan ~]# chmod -R 775 /u02
[root@yuan ~]# chmod g+s /u01
[root@yuan ~]# chmod g+s /u02
[root@yuan ~]# 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
[oracle@yuan ~]$ /stage/database/runInstaller
Starting Oracle Universal Installer...
让你填写邮件信息的,直接点击下一步
Installation Option(安装选项)
创建和配置数据库©(默认选中的是此项)
System Class(系统类)
桌面类(D),默认此项即可
Typical Installation(典型安装)
On the Typical Install Configuration screen, specify the key features.
Oracle base | /u01/app/oracle |
---|---|
Software location | /u01/app/oracle/product/12.2.0/dbhome_1 |
Database file location | /u02 |
Global database name | orcl |
Create Inventory(创建产品清单)
Accept the default /u01/app/oraInventory and click Next.
Prerequisite Checks(先决条件检查)
The Installer automatically verifies all required OS packages and OS kernel settings.
Summary(概要)
Final chance to edit any installation features. Click Install.
Execute Configuration Scripts(执行配置脚本)
When a request window appears, login as root and execute two scripts:
[root@yuan ~]# /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@yuan ~]# /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.1.0/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: <PRESS ENTER> 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. You can follow the installation in a separated window.
Installation progress(安装进度)
Another window opens to show you the installation progress. Do not close this window.
Installation completed successfully
The last screen inform that the installation is done and displays the Oracle Enterprise Manager URL.
Click OK to close the Installer.
Login as root and verify the active zones
以root用户登录并验证活动区域
[root@yuan ~]# firewall-cmd --get-active-zones
public
interfaces: wlp2s0
Open the related ports(打开相关端口)
[root@yuan ~]# firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
success
[root@yuan ~]# firewall-cmd --reload
success
[root@yuan ~]# firewall-cmd --list-ports
1521/tcp 5500/tcp 5520/tcp 3938/tcp
[root@yuan ~]#
Login as oracle user and add the following values to the /home/oracle/.bash_profile
#切换至Oracle用户
[root@yuan product]# su oracle
#编辑/home/oracle/.bash_profile文件
[oracle@yuan product]$ vim /home/oracle/.bash_profile
#在文件末尾添加下面信息
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
Reload the bash_profile to apply the new settings:
[oracle@yuan ~]$ cd /home/oracle
[oracle@yuan ~]$ . .bash_profile
[oracle@yuan ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 26 23:09:29 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
???:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
查看实例状态
SQL> select status from v$instance;
STATUS
------------
OPEN
关闭数据库
SQL> shutdown immediate;
如果不配监听:连接时会报:ora-12541:tns:无监听程序
oracle@yuan ~]$ lsnrctl status
#如果输出的倒数第二行有“The listener supports no service”则表示无监听,
#原因是:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)中的
#HSOT=localhost,将其改为Oracle宿主机自身的IP地址即可,如下:
#(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.126)
netmgr
命令启动Net Manager图形管理界面,在listener中将localhost改为对应的IP地址即可。[oracle@yuan ~]$ vim /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/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))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.126)(PORT = 1521))#这里改为IP即可
)
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@yuan ~]$ lsnrctl stop
[oracle@yuan ~]$ lsnrctl start
这里采用的是不安装Oracle客户端的情况下连接Oracle数据库服务器
instantclient-basic-windows.x64-12.2.0.1.0.zip
文件解压到指定位置,如D盘tnsnames.ora
文件,内容如下:ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.126)(PORT = 1521))#数据库服务器IP配置
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)#sid
)
)
在系统变量中新建TNS_ADMIN=D:\instantclient_12_2\NETWORK\ADMIN 环境变量
在系统变量中新建NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK 环境变量
D:\instantclient_12_2
D:\instantclient_12_2\oci.dll
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。