安装oracle12c 一般不会在root下安装,会专门建立一个账户来管理oracle软件
安装oracle软件
1.安装oracle软件不建议在windows系统,
建议在linux系统,oracle linux系统和红帽linux操作系统其实一样的,只多了一个东西,就是将自己要用的一些rpm包做到系统里面了,好处就是方便oracle软件安装配置,在其他类型的linux系统安装oracle软件是快捷方式少了,多了一些步骤而已,其他没有什么变化;
2.安装oracle软件的前期环境准备
达到要求后才能安装oracle软件;
Oracle 12C安装文档
1、修改网络信息
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=550bb435-cdd7-4c27-95f7-d90b298ce4ee
DEVICE=ens33
ONBOOT=yes
IPADDR=192.0.2.20
PREFIX=24
GATEWAY=192.0.2.13
2、关闭selinux开机自启
[root@localhost ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3、关闭开机自启firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
4、修改主机名
[root@localhost ~]# hostnamectl set-hostname o12c
[root@localhost ~]# exit
logout
Last login: Thu Apr 16 18:20:15 2020 from 192.0.2.41
[root@o12c ~]#
5、重启服务器
[root@o12c ~]# reboot
6、配置本地yum源
[root@o12c ~]# cd /etc/yum.repos.d/
[root@o12c yum.repos.d]# ll
total 8
-rw-r--r--. 1 root root 6282 Aug 2 2017 public-yum-ol7.repo
[root@o12c yum.repos.d]# mkdir bak
[root@o12c yum.repos.d]# ll
total 8
drwxr-xr-x 2 root root 6 Apr 16 18:23 bak
-rw-r--r--. 1 root root 6282 Aug 2 2017 public-yum-ol7.repo
[root@o12c yum.repos.d]# cp public-yum-ol7.repo bak/
[root@o12c yum.repos.d]# more public-yum-ol7.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=file:///mnt
gpgcheck=0
enabled=1
7、挂载镜像ISO到mnt目录
[root@o12c ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@o12c ~]# mount
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/42 type tmpfs (rw,nosuid,nodev,relatime,size=376500k,mode=700,uid=42,gid=42)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=376500k,mode=700)
/dev/sr0 on /mnt type iso9660 (ro,relatime)
[root@o12c ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 9.0M 1.8G 1% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/sda2 85G 3.3G 82G 4% /
/dev/sda1 197M 190M 7.5M 97% /boot
tmpfs 368M 12K 368M 1% /run/user/42
tmpfs 368M 0 368M 0% /run/user/0
/dev/sr0 4.6G 4.6G 0 100% /mnt
测试yum源是否正常
[root@o12c ~]# yum makecache
Loaded plugins: langpacks, ulninfo
ol7_latest | 3.6 kB 00:00:00
(1/4): ol7_latest/group_gz | 136 kB 00:00:00
(2/4): ol7_latest/filelists_db | 3.7 MB 00:00:00
(3/4): ol7_latest/primary_db | 4.7 MB 00:00:00
(4/4): ol7_latest/other_db | 1.5 MB 00:00:00
Metadata Cache Created
[root@o12c ~]#
8、一键修改Oracle环境参数
[root@o12c ~]# yum search oracle
Loaded plugins: langpacks, ulninfo
================================================= N/S matched: oracle =================================================
kmod-oracleasm.x86_64 : oracleasm kernel module(s)
oracle-database-server-12cR2-preinstall.x86_64 : Sets the system for Oracle Database single instance and Real
: Application Cluster install for Oracle Linux 7
oracle-logos.noarch : Oracle-related icons and pictures
oracleasm-support.x86_64 : The Oracle Automatic Storage Management support programs.
oraclelinux-release.x86_64 : Oracle Linux 7 release file
basesystem.noarch : The skeleton package which defines a simple Oracle Linux system
kabi-yum-plugins.noarch : The Oracle Linux kernel ABI yum plugin
ocfs2-tools.x86_64 : Tools for managing the Oracle Cluster Filesystem 2
redhat-bookmarks.noarch : Oracle Linux bookmarks
redhat-upgrade-tool.noarch : The Oracle Linux Upgrade tool
Name and summary matches only, use "search all" for everything
[root@o12c ~]# yum install -y oracle-database-server-12cR2-preinstall.x86_64
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package oracle-database-server-12cR2-preinstall.x86_64 0:1.0-3.el7 will be installed
--> Processing Dependency: libstdc++-devel for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: libaio-devel for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: ksh for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: glibc-devel for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: compat-libstdc++-33 for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Processing Dependency: compat-libcap1 for package: oracle-database-server-12cR2-preinstall-1.0-3.el7.x86_64
--> Running transaction check
Installed:
oracle-database-server-12cR2-preinstall.x86_64 0:1.0-3.el7
Dependency Installed:
compat-libcap1.x86_64 0:1.10-7.el7 compat-libstdc++-33.x86_64 0:3.2.3-72.el7 glibc-devel.x86_64 0:2.17-196.el7
glibc-headers.x86_64 0:2.17-196.el7 kernel-headers.x86_64 0:3.10.0-693.el7 ksh.x86_64 0:20120801-34.el7
libaio-devel.x86_64 0:0.3.109-13.el7 libstdc++-devel.x86_64 0:4.8.5-16.el7
Complete!
查看系统参数是否修改
[root@o12c ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
修改Oracle用户密码
[root@o12c ~]# 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.
9、修改Oracle环境变量
[oracle@o12c ~]$ more .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app
export ORACLE_HOME=$ORACLE_BASE/oracle/12c/db_1
export ORACLE_SID=test
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
10、创建安装目录
[root@o12c ~]# mkdir /u01/app/oracle/12c/db_1 -p
[root@o12c ~]# chown oracle:oinstall -R /u01
[root@o12c ~]# chmod 777 -R /u01
3.安装oracle软件
11、上传Oracle软件并安装
[root@o12c ~]# su - oracle
Last login: Thu Apr 16 18:52:18 CST 2020 on pts/0
[oracle@o12c ~]$ ll
total 3372752
-rw-r--r-- 1 oracle oinstall 3453696911 Apr 16 19:00 linuxx64_12201_database.zip
[oracle@o12c ~]$ chmod +x linuxx64_12201_database.zip
[oracle@o12c ~]$ unzip linuxx64_12201_database.zip
[oracle@o12c ~]$ ll
total 0
drwxr-xr-x 7 oracle oinstall 117 Jan 27 2017 database
[oracle@o12c ~]$ cd database/
[oracle@o12c database]$ ll
total 24
drwxr-xr-x 4 oracle oinstall 4096 Jan 26 2017 install
drwxrwxr-x 2 oracle oinstall 61 Jan 26 2017 response
drwxr-xr-x 2 oracle oinstall 35 Jan 26 2017 rpm
-rwxr-xr-x 1 oracle oinstall 8771 Jan 26 2017 runInstaller
drwxrwxr-x 2 oracle oinstall 29 Jan 26 2017 sshsetup
drwxr-xr-x 14 oracle oinstall 4096 Jan 26 2017 stage
-rwxr-xr-x 1 oracle oinstall 500 Feb 7 2013 welcome.html
[root@o12c ~]# xhost +
access control disabled, clients can connect from any host
[root@o12c ~]# su – oracle
[oracle@o12c ~]# export DISPLAY=192.0.2.41:0.0
[oracle@o12c database]$ ./runInstaller
[root@o12c ~]# /u01/oraInventory/orainstRoot.sh
Changing permissions of /u01/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/oraInventory to oinstall.
The execution of the script is complete.
[root@o12c ~]# /u01/app/oracle/12c/db_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/12c/db_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] :
Oracle Trace File Analyzer (TFA - User Mode) is available at :
/u01/app/oracle/12c/db_1/suptools/tfa/release/tfa_home/bin/tfactl
OR
Oracle Trace File Analyzer (TFA - Daemon Mode) can be installed by running this script :
/u01/app/oracle/12c/db_1/suptools/tfa/release/tfa_home/install/roottfa.sh
[root@o12c ~]# /u01/app/oracle/12c/db_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/12c/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.
Entries will be added to the /etc/oratab file as needed by
4.安装数据库监听(连接数据库软件时用的)
12、创建数据库监听
[root@o12c ~]# hostname
o12c
[root@o12c ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.0.2.20 o12c
~
[oracle@o12c ~]$ netca
查看监听状态
[oracle@o12c ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 16-APR-2020 19:38:22
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=o12c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 16-APR-2020 19:37:39
Uptime 0 days 0 hr. 0 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/12c/db_1/network/admin/listener.ora
Listener Log File /u01/app/diag/tnslsnr/o12c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=o12c)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
5.安装oracle数据库
[oracle@o12c ~]$ dbca
创建数据文件目录
[oracle@o12c ~]$ cd /u01/app/
[oracle@o12c app]$ mkdir oradata