准备工作:打开虚拟机端的Oracle Linux Server 6.9的系统,然后使用root用户登录。打开终端界面,输入ifconfig -a查看IP地址。
然后在本地打开XShell软件使用以下命令进入虚拟机的终端。
ssh root@192.168.91.129
192.168.91.129为自己的IP地址。
查看硬盘分区
[root@ambition ~]# fdisk -l
得到以下内容:其中/dev/sdb用来挂载oracle,/dev/sdc用来挂载ogg。
Disk /dev/sdc: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
第一步:创建物理空间,分别运行以下命令
1 [root@ambition ~]# pvcreate /dev/sdb 2 [root@ambition ~]# pvcreate /dev/sdc
运行pvdisplay查看创建是否成功
--- Physical volume --- PV Name /dev/sdc VG Name PV Size 80.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 20479 Free PE 0 Allocated PE 20479 PV UUID 68xjYx-EhLY-1W9m-2XJ9-FXJI-CnnM-5218YP --- Physical volume --- PV Name /dev/sdb VG Name PV Size 80.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 20479 Free PE 0 Allocated PE 20479 PV UUID ddjPX3-t9dE-Z0XW-2cnF-Zd9E-1M6Q-zNAmoe
第二步:创建卷组,分别运行以下命令
1 [root@ambition ~]# vgcreate vg_oracle /dev/sdb 2 [root@ambition ~]# vgcreate vg_ogg /dev/sdc
运行vgdisplay查看创建是否成功
--- Volume group --- VG Name vg_ogg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 80.00 GiB PE Size 4.00 MiB Total PE 20479 Alloc PE / Size 20479 / 80.00 GiB Free PE / Size 0 / 0 VG UUID bv7LMk-cOzr-Phzu-VDe3-6odo-82Fs-WupLgs --- Volume group --- VG Name vg_oracle System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 80.00 GiB PE Size 4.00 MiB Total PE 20479 Alloc PE / Size 20479 / 80.00 GiB Free PE / Size 0 / 0 VG UUID j4BdLM-Mdwf-D4m4-gKFD-rYi6-M5hD-Yc26SF
第三步:创建逻辑空间,运行以下命令
1 [root@ambition ~]# lvcreate -l 20479 vg_oracle -n lv_oracle 2 [root@ambition ~]# lvcreate -l 20479 vg_ogg -n lv_ogg
其中20479是vgdisplay查询下的Total PE的值,可以全部分配也可以部分分配。
运行lvdisplay查看是否创建成功
--- Logical volume --- LV Path /dev/vg_ogg/lv_ogg LV Name lv_ogg VG Name vg_ogg LV UUID du1GSY-44gc-3k2U-V7Ey-nk4p-GFqu-DbVSFx LV Write Access read/write LV Creation host, time ambition, 2019-03-18 09:31:31 +0800 LV Status available # open 1 LV Size 80.00 GiB Current LE 20479 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:2 --- Logical volume --- LV Path /dev/vg_oracle/lv_oracle LV Name lv_oracle VG Name vg_oracle LV UUID C2fO4y-AHhl-l7oI-MAo2-smXp-pmIw-kzhGA0 LV Write Access read/write LV Creation host, time ambition, 2019-03-18 09:37:24 +0800 LV Status available # open 1 LV Size 80.00 GiB Current LE 20479 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:3
第四步:格式化创建好的磁盘,依次运行下列命令
1 [root@ambition ~]# mkfs.ext4 /dev/vg_oracle/lv_oracle 2 [root@ambition ~]# mkfs.ext4 /dev/vg_ogg/lv_ogg
至此,oracle和ogg的创建就完成了,下面开始挂载
第五步:创建/u01和/ogg空间,依次运行以下命令,在根目录下创建这两个文件夹。
1 [root@ambition ~]# mkdir /u01 2 [root@ambition ~]# mkdir /ogg
第六步:添加挂载信息并挂载lv,vi编辑fstab文件
[root@ambition ~]# vi /etc/fstab
在fstab文件中的最底部添加挂载信息
/dev/vg_oracle/lv_oracle /u01 ext4 defaults 1 3 /dev/vg_ogg/lv_ogg /ogg ext4 defaults 1 4
添加完后可以运行以下命令查看
[root@ambition ~]# cat /etc/fstab
会出现下列内容
# # /etc/fstab # Created by anaconda on Mon Mar 18 17:00:20 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_ambition-lv_root / ext4 defaults 1 1 UUID=af3104ec-a4cb-4c90-b406-70de3f6a2260 /boot ext4 defaults 1 2 /dev/mapper/vg_ambition-lv_home /home ext4 defaults 1 2 /dev/mapper/vg_ambition-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/vg_oracle/lv_oracle /u01 ext4 defaults 1 3 /dev/vg_ogg/lv_ogg /ogg ext4 defaults 1 4
然后开始挂载lv,运行下列命令,运行完后不会出现任何信息,代表挂载成功。
[root@ambition ~]# mount -a
查看挂载信息。
[root@ambition ~]# df -h
出现下列内容中含有oracle和ogg表示挂载成功
Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_ambition-lv_root 50G 3.3G 44G 7% / tmpfs 1.9G 76K 1.9G 1% /dev/shm /dev/sda1 477M 85M 363M 19% /boot /dev/mapper/vg_ambition-lv_home 26G 9.8G 15G 42% /home /dev/mapper/vg_oracle-lv_oracle 79G 11G 64G 15% /u01 /dev/mapper/vg_ogg-lv_ogg 79G 285M 75G 1% /ogg /dev/sr0 3.8G 3.8G 0 100% /media/OL6.9 x86_64 Disc 1 20170324
OK,Oracle和ogg挂载完毕!
第七步:修改hosts文件、系统及限制参数
hosts文件修改
vi /etc/hosts
添加系统的IP地址和用户名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.91.111 ambition
系统参数修改
vi /etc/sysctl.conf
在文件末尾添加下列内容:
# Add for Oracle Database kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.aio-max-nr = 1048576 fs.file-max = 6815744 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.wmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_max = 1048576
保存后,运行下列命令查看。
/sbin/sysctl -p
限制参数修改
vi /etc/security/limits.conf
文件末尾添加下列内容:
oracle soft nproc 16384 oracle hard nproc 16384 oracle soft nofile 2048 oracle hard nofile 65536
第八步:创建用户及目录、检查rpm包、配置Oracle环境变量
创建用户及目录,依次运行下列命令:
1 groupadd oinstall && groupadd dba 2 useradd oracle -g oinstall -G dba 3 mkdir -p /u01/app/db/product/11.2 4 chown -R oracle:oinstall /u01 5 chmod -R 775 /u01
检查rpm包
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc libgcc libstdc++ libstdc++-devel libaio libaio-devel make ksh sysstat
若有包没有安装可以运行下列命令的形式安装
yum install 包名
配置Oracle环境变量,运行下面的命令打开Oracle环境变量文件
vi /home/oracle/.bash_profile
在文件尾部添加下列内容
export ORACLE_BASE=/u01/app/db export ORACLE_HOME=/u01/app/db/product/11.2 export ORACLE_SID=qdydks #export GRID_HOME=/u01/app/app/crs export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH export PS1='[$ORACLE_SID]@'`hostname`'[$PWD]$' #export ORA_NLS10=$GRID_HOME/nls/data #goldengate export PATH=/ogg:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/ogg:$LD_LIBRARY_PATH
OK!Oracle软件安装前的所有配置均已完成,下节将介绍Oracle的安装。