暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Virtualbox+Centos7+Oracle 19c

DB小榴莲 2021-07-14
850

创建虚拟Linux操作系统

第一步,在virtualbox首页新建一个虚拟机,虚拟机名称随机;文件夹选项是存放这台虚拟机文件的,将来要是需要迁移,可以直接拷贝这个目录即可;类型选项是你即将要创建的虚拟系统类型,比如Linux,Windows等等;版本是系统的不同分支,根据自己的要求选择。

第二步,为你的虚拟机分配内存,即你的虚拟机可以使用宿主机上的内存大小。

第三步,创建虚拟机的硬盘,你将来使用这台虚拟机产生的文件,日志存放的地方。

第四步,选择虚拟硬盘的类型,这里选VHD

  • VDI是VirtualBox独家的格式,其他虚拟化软件通常不支持VDI。

  • VMDK由VMWare开发,但VirtualBox和QEMU(另一种常见的虚拟化软件)也支持它。

  • VHD是Microsoft Virtual PC的本机格式。

第五步,为创建的虚拟硬盘分配大小或者选择大小分配方式,一般用固定大小

第六步,配置虚拟机,选择系统镜像文件,安装对应的操作系统。

第七步,选择Host-Only
网络连接模式。

第八步,启动虚拟机,读取系统镜像文件,开始安装Linux操作系统

第九步,选择系统语言

第十步,安装图上的标号,顺序完成系统时区
系统镜像校验
安装选项
磁盘分区
网络
的配置

修补操作系统

因为上面选择的最小化安装Linux操作系统,所以系统的很多功能缺失,需要手动安装一部分软件包来实现需要的功能。

这里选择从安装镜像文件里获取安装包,所以先配置本地yum源。

[root@localhost ~]# mount dev/cdrom mntmount: dev/sr0 is write-protected, mounting read-only
复制

配置本地yum源:编辑/etc/yum.repos.d/CentOS-Base.repo
文件,用如下的内容替换原文件中原来的配置。

[root@localhost ~]# cd etc/yum.repos.d/[root@bms-sql-new01 yum.repos.d]# vi CentOS-Base.repo[base]name=Red Hat Enterprise Linuxbaseurl=file:///mntenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
复制

[root@localhost yum.repos.d]# yum makecacheLoaded plugins: fastestmirrorDetermining fastest mirrorsbase                                                                            | 3.6 kB  00:00:00     (1/4): base/group_gz                                                            | 153 kB  00:00:00     (2/4): base/filelists_db                                                        | 3.3 MB  00:00:00     (3/4): base/primary_db                                                          | 3.3 MB  00:00:00     (4/4): base/other_db                                                            | 1.3 MB  00:00:00     Metadata Cache Created
复制

安装网络工具

# yum -y install net-tools# yum -y install unzip
复制

安装Oracle所需的依赖包

yum -y install bcyum -y install binutilsyum -y install compat-libcap1yum -y install compat-libstdc++-33yum -y install elfutils-libelfyum -y install elfutils-libelf-develyum -y install fontconfig-develyum -y install glibcyum -y install glibc-develyum -y install kshyum -y install libaioyum -y install libaio-develyum -y install libX11yum -y install libXauyum -y install libXiyum -y install libXtstyum -y install libXrenderyum -y install libXrender-develyum -y install libgccyum -y install libstdc++yum -y install libstdc++-develyum -y install libxcbyum -y install makeyum -y install smartmontoolsyum -y install sysstat
复制

新增磁盘(Oracle 19c对存储的需求相较于之前版本大了不少,建议20Gb)

[root@localhost ~]# fdisk -lDisk dev/sda: 12.9 GB, 12884901888 bytes, 25165824 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk label type: dosDisk identifier: 0x000f28fa   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    25151487    12062720   8e  Linux LVMDisk dev/sdb: 12.9 GB, 12884901888 bytes, 25165824 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk dev/mapper/centos-root: 8598 MB, 8598323200 bytes, 16793600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk dev/mapper/centos-home: 524 MB, 524288000 bytes, 1024000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytes[root@localhost ~]# fdisk dev/sdbWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0xb8c3262e.Command (m for help): n       Partition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-25165823, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-25165823, default 25165823): Using default value 25165823Partition 1 of type Linux and of size 12 GiB is setCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
复制

[root@localhost ~]# fdisk -lDisk dev/sda: 12.9 GB, 12884901888 bytes, 25165824 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk label type: dosDisk identifier: 0x000f28fa   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048     1026047      512000   83  Linux/dev/sda2         1026048    25151487    12062720   8e  Linux LVMDisk dev/sdb: 12.9 GB, 12884901888 bytes, 25165824 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk label type: dosDisk identifier: 0xb8c3262e   Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048    25165823    12581888   83  LinuxDisk dev/mapper/centos-root: 8598 MB, 8598323200 bytes, 16793600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytesDisk dev/mapper/centos-home: 524 MB, 524288000 bytes, 1024000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes  512 bytesI/O size (minimum/optimal): 512 bytes  512 bytes[root@localhost ~]# pvcreate dev/sdb1  Physical volume "/dev/sdb1" successfully created.[root@localhost ~]# pvscan  PV dev/sda2   VG centos          lvm2 [11.50 GiB  4.00 MiB free]  PV dev/sdb1                      lvm2 [<12.00 GiB]  Total: 2 [<23.50 GiB]  in use: 1 [11.50 GiB]  in no VG: 1 [<12.00 GiB][root@localhost ~]# [root@localhost ~]# vgcreate vg_oracle dev/sdb1  Volume group "vg_oracle" successfully created[root@localhost ~]# vgscan  Reading volume groups from cache.  Found volume group "vg_oracle" using metadata type lvm2  Found volume group "centos" using metadata type lvm2[root@localhost ~]# vgdisplay  --- Volume group ---  VG Name               vg_oracle  System ID               Format                lvm2  Metadata Areas        1  Metadata Sequence No  1  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                0  Open LV               0  Max PV                0  Cur PV                1  Act PV                1  VG Size               <12.00 GiB  PE Size               4.00 MiB  Total PE              3071  Alloc PE  Size       0  0     Free  PE  Size       3071  <12.00 GiB  VG UUID               1xnIL6-r3jv-4Ib4-GTmZ-W622-MSye-OCZB1g     --- Volume group ---  VG Name               centos  System ID               Format                lvm2  Metadata Areas        1  Metadata Sequence No  4  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                3  Open LV               3  Max PV                0  Cur PV                1  Act PV                1  VG Size               11.50 GiB  PE Size               4.00 MiB  Total PE              2944  Alloc PE  Size       2943  <11.50 GiB  Free  PE  Size       1  4.00 MiB  VG UUID               BtTCGk-trHf-cbMT-WEXe-BFpK-lCAd-bqT3yE   [root@localhost ~]# lvcreate -L 12000M -n lv_oracle vg_oracle  Logical volume "lv_oracle" created.[root@localhost ~]# lvdisplay  --- Logical volume ---  LV Path                dev/vg_oracle/lv_oracle  LV Name                lv_oracle  VG Name                vg_oracle  LV UUID                yE5V1r-bDmJ-2Ex9-fpCd-T2b3-NShD-3ZYEeK  LV Write Access        read/write  LV Creation host, time localhost.localdomain, 2021-07-13 14:00:05 +0800  LV Status              available  # open                 0  LV Size                <11.72 GiB  Current LE             3000  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:3     --- Logical volume ---  LV Path                dev/centos/home  LV Name                home  VG Name                centos  LV UUID                n4oaqJ-6OT4-XxAw-fO00-z7z3-rU7t-SEzZfW  LV Write Access        read/write  LV Creation host, time localhost.localdomain, 2021-07-13 13:14:49 +0800  LV Status              available  # open                 1  LV Size                500.00 MiB  Current LE             125  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:2     --- Logical volume ---  LV Path                dev/centos/swap  LV Name                swap  VG Name                centos  LV UUID                PNHBiM-hCVJ-8KUG-UI6T-U33v-h2Q2-uqmZTm  LV Write Access        read/write  LV Creation host, time localhost.localdomain, 2021-07-13 13:14:49 +0800  LV Status              available  # open                 2  LV Size                3.00 GiB  Current LE             768  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:1     --- Logical volume ---  LV Path                dev/centos/root  LV Name                root  VG Name                centos  LV UUID                Me1heg-Umwz-JtJK-tgxq-UGf8-qKXE-P8VMDN  LV Write Access        read/write  LV Creation host, time localhost.localdomain, 2021-07-13 13:14:49 +0800  LV Status              available  # open                 1  LV Size                <8.01 GiB  Current LE             2050  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           253:0
复制

[root@localhost ~]# mkfs -t ext4 dev/vg_oracle/lv_oraclemke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks768544 inodes, 3072000 blocks153600 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=215167795294 block groups32768 blocks per group, 32768 fragments per group8176 inodes per groupSuperblock backups stored on blocks:         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208Allocating group tables: done                            Writing inode tables: done                            Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done [root@localhost ~]# mkdir u01[root@localhost ~]# mount dev/vg_oracle/lv_oracle u01[root@localhost ~]# df -hFilesystem                       Size  Used Avail Use% Mounted ondevtmpfs                         1.4G     0  1.4G   0% devtmpfs                            1.4G     0  1.4G   0% dev/shmtmpfs                            1.4G  8.6M  1.4G   1% runtmpfs                            1.4G     0  1.4G   0% sys/fs/cgroup/dev/mapper/centos-root          8.0G  1.3G  6.8G  16% /dev/mapper/centos-home          497M   26M  472M   6% home/dev/sda1                        497M  143M  354M  29% boottmpfs                            278M     0  278M   0% run/user/0/dev/mapper/vg_oracle-lv_oracle   12G   41M   11G   1% u01
复制

安装Oracle前期准备

创建用户和属组

# usr/sbin/groupadd -g 54329 oinstall# usr/sbin/groupadd -g 54327 asmdba# usr/sbin/groupadd -g 54328 asmoper# usr/sbin/groupadd -g 54322 dba# usr/sbin/groupadd -g 54323 oper# usr/sbin/groupadd -g 54324 backupdba# usr/sbin/groupadd -g 54325 dgdba# usr/sbin/groupadd -g 54326 kmdba# usr/sbin/groupadd -g 54330 racdba# usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba oracle
复制

创建安装Oracle需要的目录

# mkdir -p u01/app/oracle# mkdir -p u01/app/oraInventory# chown -R oracle:oinstall u01/app/oracle# chown -R oracle:oinstall u01/app/oraInventory# chmod -R 775 u01/app
复制

上传软件包并校验安装包的完整性

$ cksum LINUX.X64_193000_db_home.zip 3680739943 3059705302 LINUX.X64_193000_db_home.zip
复制

创建OFA目录

$ mkdir -p u01/app/oracle/product/19.0.0/dbhome_1$ cd u01/app/oracle/product/19.0.0/dbhome_1$ unzip -q u01/software/LINUX.X64_193000_db_home.zip
复制

配置操作系统(root)

# vi etc/security/limits.conforacle              soft    nproc   2047oracle              hard    nproc   16384oracle              soft    nofile  1024oracle              hard    nofile  65536
复制

# vi etc/profileif [ $USER = "oracle" ]; then        if [ $SHELL = "/bin/ksh" ]; then              ulimit -p 16384              ulimit -n 65536        else              ulimit -u 16384 -n 65536
       fi
umask 022
fi
复制


# vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912000
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
net.ipv4.tcp_rmem = 4096        87380   4194304
net.ipv4.tcp_wmem = 4096        16384   4194304
复制


# sysctl -p
复制


[root@localhost dbhome_1]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.88 localhost.localdomain
复制


配置Oracle环境变量

$ vi .bash_profile
export PATH
export ORACLE_SID=ora19c
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export UMASK=022
export PATH=$ORACLE_HOME/bin:$PATH
stty erase '^H'
复制


安装VNCServer

# yum install tigervnc  tigervnc-server -y
# yum group install 'Server with GUI'
# systemctl set-default graphical.target
复制


关闭防火墙

[root@localhost data]# systemctl stop firewalld
[root@localhost data]# systemctl status firewalld
复制


设置VNC密码

$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)?
A view-only password is not used
xauth: file /home/oracle/.Xauthority does not exist

New 'localhost.localdomain:1 (oracle)' desktop is localhost.localdomain:1

Creating default startup script /home/oracle/.vnc/xstartup
Creating default config /home/oracle/.vnc/config
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/localhost.localdomain:1.log
复制


安装Oracle软件

[oracle@localhost dbhome_1]$ export DISPLAY=192.168.56.88:1
[oracle@localhost dbhome_1]$ ./runInstaller
复制

root用户执行这两个脚本

[root@localhost ~]# /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@localhost ~]# /u01/app/oracle/product/19.0.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/19.0.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.
Oracle Trace File Analyzer (TFA - Standalone Mode) is available at :
  /u01/app/oracle/product/19.0.0/dbhome_1/bin/tfactl

Note :
1. tfactl will use TFA Service if that service is running and user has been granted access
2. tfactl will configure TFA Standalone Mode only if user has no access to TFA Service or TFA is not installed
复制


[oracle@localhost ~]$ dbca
复制


----------------------------
长按下图二维码关注我,每篇涨点小知识!


文章转载自DB小榴莲,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论