天天看点

【oracle12c数据库的安装】

一、oracle database 12c(cloud云)

应用领域:大数据、集成系统、云计算

优点:提高整合度(可插拔数据库),多租户架构,节省硬件资源,管理共享资源(优先级),简化升级(提供数据库灵活的打补丁),将多个数据库作为一个管理(统一备份多个数据库-在可插拔式数据库,支持全部备份,也支持选择性的备份)

云分类:公有云(阿里云等)、私有云(局域网里的云服务)、混合云(公有云和私有云)

二、oracle数据库的安装

1.安装os(我们这里在VMware里安装OracleLinux操作系统)

首先新建一个虚拟机,安装教程与下面这个链接相似;不过要根据自己电脑的配置和操作系统的版本进行选择。https://blog.csdn.net/qq_40003309/article/details/105441901

这个操作系统主要是为学习oracle数据库,我们应该将磁盘大小设置的大一点(100G),虚拟机的内存大小设置为4G以上。

2.安装oracle软件的前期环境准备

a.配置网卡信息

[[email protected] ~]# vim /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.168.131.200
PREFIX=24
GATEWAY=192.168.131.2
DNS1=114.114.114.114
           

b.关闭防火墙和selinux.

[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# vim /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 
           

c.添加主机名

[[email protected] ~]# hostnamectl  set-hostname  o12c #之后可以重启服务器就可以看到主机名已发生变化
           

d.配置本地yum源

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mkdir bak
[[email protected] yum.repos.d]# cp public-yum-ol7.repo  bak/
[[email protected] yum.repos.d]# vim public-yum-ol7.repo 
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=file:///mnt
gpgcheck=0
enabled=1
[[email protected] ~]# mount /dev/sr0  /mnt
#测试yum源是否正常
[[email protected] ~]# 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
           

e.一键安装oracle环境:安装成功后配置文件要补充的内容和oracle用户就自动生成

[[email protected] ~]# yum search oracle
[[email protected] ~]# yum install -y oracle-database-server-12cR2-preinstall.x86_64
[[email protected] ~]cat /etc/sysctl.conf  #配置文件要补充的内容自动生成
[[email protected] ~]# id oracle  #oracle用户也自动生成
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
#设置Oracle用户密码
[[email protected] ~]# passwd oracle
           

f.在oracle用户下配置环境变量:vim .bash_profile

[[email protected] ~]#su - oracle
[[email protected] ~]$ vim .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
[[email protected] ~]$ source .bash_profile  #加载环境变量
#接下来去创建环境变量里设置的安装目录
[[email protected] ~]# mkdir /u01/app/oracle/12c/db_1 -p
[[email protected] ~]# chown oracle:oinstall -R /u01
[[email protected] ~]# chmod 777 -R /u01

           

3.安装Oracle软件:使用xmanager里面的xftp上传oracle软件,进行加权限解压,接下来安装oracle软件

[[email protected] ~]# su - oracle
[[email protected] ~]$ rz -E 
[[email protected] ~]$ll
-rw-r--r-- 1 oracle oinstall 3453696911 Apr 16 19:00 linuxx64_12201_database.zip
[[email protected] ~]$ chmod +x linuxx64_12201_database.zip #给文件加执行权限
[[email protected] ~]$ unzip linuxx64_12201_database.zip   #加压
[[email protected] ~]$ ll
total 0
drwxr-xr-x 7 oracle oinstall 117 Jan 27  2017 database
[[email protected] ~]$ cd database/
[[email protected] 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
#接下来就是安装oracle软件有两种方法:
 第一种在虚拟机安装oracle软件(本地服务器):
 [[email protected] database]$./runinstaller
 第二种将虚拟机安装界面投射到windows界面进行安装(远程):使用xmanager开启一个客户机端口为0.0,并且获取到windows的ip地址(ipconfig)。
 [[email protected] ~]# xhost +    #图形界面清理
 [[email protected] ~]# su – oracle 
 [[email protected] ~]# export DISPLAY=192.168.56.1:0.0
 [[email protected] database]$ ./runInstaller  #接下来会出现安装oracle数据库的图形化界面
           
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
#会出现让执行脚本的窗口:root用户,两个脚本有顺序
[[email protected] ~]# /u01/oraInventory/orainstRoot.sh 
[[email protected] ~]# /u01/app/oracle/12c/db_1/root.sh 
           
【oracle12c数据库的安装】

4.安装数据库监听:用于连接

[[email protected] ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.131.200  o12c
[[email protected] ~]#ping o12c    #监听时解析的是主机名
[[email protected] ~]$ netca    #接下来就是安装数据库监听界面
           
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
#查看监听状态
[[email protected] ~]$ lsnrctl status
           

5.安装oracle数据库。

[[email protected] ~]$ dbca  #接下来就是oracle数据库安装界面
           
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
#创建数据文件目录
[[email protected] ~]$ cd /u01/app/
[[email protected] app]$ mkdir oradata
           
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】
【oracle12c数据库的安装】

安装完成,进行数据库使用。

【oracle12c数据库的安装】

补充:

1.swap分区可以在内存不足时,则用这个swap分区

2.添加环回网卡:在windows搜索输入hdwwiz根据提示一步来,好了之后打开网络与共享中心,就可以为环回设置ip地址。