修改主机名:
vi /etc/hostname
修改hosts:
vi /etc/hosts
添加 192.168.2.130 ORCL
修改network网络文件:
vi /etc/sysconfig/network
添加 NETWORKING=yes
添加与hosts对应的主机名 HOSTNAME=ORCL
cat>>/etc/sysconfig/network<<EOF
NETWORKING=yes
HOSTNAME=ORCL
EOF
修改ifcfg-ens33网卡配置文件:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
修改: BOOTPROTO="dhcp" =>BOOTPROTO="static"
添加: IPADDR="192.168.2.130"
添加:GATEWAY="192.168.2.1"
添加: NETMASK="255.255.255.0"
重启网络服务:
service network restart
挂载新目录:
查看机器所挂硬盘个数及分区情况:fdisk -l (只有/dev/sda,没有/dev/sdb)
添加硬盘(默认):内存自选(刚学习时老师选择了80G)。
重启:reboot
查看机器所挂硬盘个数及分区情况:fdisk -l (有/dev/sdb)
挂载光盘:(未选择光盘时查看/dev/cdrom也存在sr0,但是不能挂载,暂时不理解)
(1)虚拟机=>设置=>CD/DVD(SATA)
i.勾选上已连接
ii. 选择使用ISO映像文件=>选定iso文件
(2)df -h查看磁盘占用情况(没有这一行 /dev/sr0 3.6G 3.6G 0 100% /mnt)
(3)手动挂载光盘:
mount /dev/cdrom /mnt/
(4)df -h查看磁盘占用情况(此时显示有 /dev/sr0 3.6G 3.6G 0 100% /mnt)
格式化磁盘(/dev/sdb):
(1)fdisk /dev/sdb (m查看帮助)
i.n (add a new partiton)
ii.回车 select(default p)
iii.回车 Partition number(1-4,default 1)
iv.回车 First sector(2048-167772159,default 2048)
v.回车 Last sector...
(2)写入磁盘并退出
i.w (write table to disk and exit)
(3)查看机器所挂硬盘个数及分区情况 fdisk -l (显示出/dev/sdb1 这行)
(4)将物理硬盘分区初始化为物理卷
pvcreate /dev/sdb1
(5)创建vg
vgcreate u01_vg /dev/sdb1
(6)分配卷组
lvcreate -l +100%FREE -n u01_lv u01_vg
(7)格式化逻辑卷
mkfs.ext4 /dev/u01_vg/u01_lv
(8)挂载磁盘(不明白这个挂载是干嘛的)
mkdir /u01
mount /dev/u01_vg/u01_lv /u01/
df -h (此时可以看到/dev/mapper/u01_vg-u01_lv 79G 57M 75G 1% /u01)
(此时重启不会自动挂载)
(9)设置分区在系统重启后自动挂载
vi /etc/fstab
添加 /dev/u01_vg/u01_lv /u01 ext4 defaults 0 0
(10)重启查看是否自动挂载
reboot
df -h
此时可以看到(8)的显示了,但是光盘的(4)没有显示,这是因为磁盘自动挂载了,光盘没有。
再次手动挂载一下光盘。
mount /dev/cdrom /mnt/
df -h查看磁盘占用情况(此时显示有 /dev/sr0 3.6G 3.6G 0 100% /mnt)
配置本地yum源
(1)创建yum目录:mkdir -p /u01/soft/yum
(2)切换工作目录:cd /u01/soft/yum
(3)拷贝/mnt/下的所有文件到此目录下:cp -R /mnt/* ./
另:开启另一终端可以用du -sh查看当时内存占用,判断拷贝进度。
(4)配置相关文件:vi /etc/yum.repos.d/local.repo
i.写入以下信息:
cat>>/etc/yum.repos.d/local.repo<<EOF
[base] name=linux 7 baseurl=file:///u01/soft/yum gpgcheck=0 enable=1
EOF
(5)修改yum源地址
vi /usr/lib/python2.7/site-packages/yum/yumRepo.py
修改:remote = url + '/' + relative => remote = url + '/u01/soft/yum' + relative
(6)清除原有缓存:yum clean all
(7)重建缓存:yum makecache
安装图形界面:
yum list (可列出所有可安装的包)
yum grouplist (列出程序组)
(1)安装图形界面程序组
yum -y groupinstall "Server with GUI"
(2)开启图形界面
startx
创建OS属主、用户:
(1)创建属主
groupadd -g 11001 oinstall groupadd -g 11002 dba groupadd -g 11003 oper groupadd -g 11004 backupdba groupadd -g 11005 dgdba groupadd -g 11006 kmdba groupadd -g 11007 asmdba groupadd -g 11008 asmoper groupadd -g 11009 asmadmin groupadd -g 11010 racdba
(2)创建用户
useradd -u 11011 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper oracle useradd -u 11012 -g oinstall -G asmadmin,asmdba,asmoper,dba,racdba grid #设置密码 passwd grid passwd oracle
(3)修改用户资源限制
vi /etc/security/limits.conf
添加以下内容
grid soft nproc 4096 grid hard nproc 16384 grid soft nofile 2047 grid hard nofile 65536 grid soft stack 10240 grid hard stack 32768 oracle soft nproc 4096 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768 grid soft memlock 1073741824 grid hard memlock 1073741824 oracle soft memlock 1073741824 oracle hard memlock 1073741824
(4)创建相关目录
mkdir -p /u01/app/db/19.3 mkdir -p /u01/app/grid/crs mkdir -p /u01/app/grid/19.3 chown -R grid:oinstall /u01 chmod -R 775 /u01/app chown -R grid:oinstall /u01/app/grid chown -R oracle:oinstall /u01/app/db chmod -R 775 /u01/app/db chmod -R 775 /u01/app/grid
(5)设置环境变量
grid用户 (env |grep ORA)
i.切换到grid用户:su - grid
ii.编辑环境变量:
cat>>~/.bash_profile<<EOF
ORACLE_SID=+ASM; export ORACLE_SID #ORACLE_TERM=xterm; export ORACLE_TERM ORACLE_BASE=/u01/app/grid/crs; export ORACLE_BASE ORACLE_HOME=/u01/app/grid/19.3; export ORACLE_HOME NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
EOF
iii.更新环境变量:source ~/.bash_profile
oracle用户
i.切换到oracle用户:su - oracle
ii.创建软件目录
mkdir -p /u01/app/db mkdir -p /u01/app/db/product/19.3/db_1 chown -R oracle:oinstall /u01/app/db
iii.编辑环境变更:
cat>>~/.bash_profile<<EOF
ORACLE_BASE=/u01/app/db; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/19.3/db_1; export ORACLE_HOME ORACLE_SID=TESTDB; export ORACLE_SID PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin; export PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib if [ $USER = "oracle" ] || [ $USER = "grid" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi
EOF
iv.更新环境变量:source ~/.bash_profile
解压安装介质:
(1)拷贝LINUX.X64_193000_grid_home.zip,LINUX.X64_193000_db_home.zip到虚拟机中。
(2)查找介质文件:find / -name LINUX.X64_193000_grid_home.zip
(3)移动介质文件到 /u01/soft/:mv ./* /u01/soft
(4)给予grid、oracle用户解压安装的权限:
chown -R grid:oinstall LINUX.X64_193000_grid_home.zip
chown -R oracle:oinstall LINUX.X64_193000_db_home.zip
(5)切换到grid用户并移动到解压目录:
su - grid
cd /u01/app/grid/19.3
(6)将LINUX.X64_193000_grid_home.zip拷贝到解压目录:cp /u01/soft/LINUX.X64_193000_grid_home.zip ./
(7)解压:unzip LINUX.X64_193000_grid_home.zip
GRID安装:检查校验环境
su - grid
cd $ORACLE_HOME
./runcluvfy.sh stage -pre crsinst -n tjy -verbose > /home/grid/pre.log
{root用户
tail -20f /home/grid/pre.log
}
(root)系统参数文件配置:
i. 添加以下内容
cat>>/etc/sysctl.conf<<EOF
vm.swappiness = 1 vm.dirty_background_ratio = 3 vm.dirty_ratio = 80 vm.dirty_expire_centisecs = 500 vm.dirty_writeback_centisecs = 100 kernel.shmmni = 4096 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 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 = 1048576 fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.panic_on_oops = 1 # net.ipv4.conf.ens33.rp_filter = 2 # net.ipv4.conf.ens34.rp_filter = 2
EOF
ii.修改生效:sysctl -p /etc/sysctl.conf
(root)文件限制:
添加以下内容:
cat>>/etc/security/limits.d/99-grid-oracle-limits.conf<<EOF
oracle soft nproc 16384 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768 grid soft nproc 16384 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile 65536 grid soft stack 10240 grid hard stack 32768
EOF
停止avahi-daemon服务
systemctl disable avahi-daemon.socket
systemctl disable avahi-daemon.service
检验补丁包:
rpm -q gcc-c++ bc binutils compat-libcap1 compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat bc-1.06.95-13.el7.x86_64
将 is not installed的补丁包安装:
yum install targetcli(关联包选择y,一起安装)
yum install libstdc++-devel
yum install libXrender-devel
yum install libaio-devel
yum install fontconfig-devel
yum install elfutils-libelf-devel
# yum install compat-libstdc++-33 (这个包没有,下一步补全)
yum install compat-libcap1
yum install gcc-c++
yum install ksh
补全上一步
拷贝compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm,compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm到虚拟机中。
{
(root用户)
cd /root/Downloads
# rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
cd /u01/app/grid/19.3/cv/rpm
rpm -ivh cvuqdisk-1.0.10-1.rpm
}
创建共享存储(创建ASM磁盘)
虚拟机=>设置=>添加=>硬盘添加 全默认{文件名:asm_01.vmdk、asm_02.vmdk、asm_03.vmdk}
init 0 (关机)
修改虚拟机在主机的配置文件:
路径(安装路径):G:\Virtual Machines\Red Hat Enterprise Linux 7 64 位.vmx
添加以下内容
disk.locking = "FALSE" disk.EnableUUID = "TRUE" scsi1.sharedBus = "VIRTUAL" diskLib.dataCacheMaxSize = "0" //diskLib.dataCacheMaxReadAheadSize = "0" //diskLib.dataCacheMinReadAheadSize = "0" //diskLib.dataCachePageSize = "4096" //diskLib.maxUnsyncedWrites = "0" scsi0:2.deviceType = "disk" scsi0:3.deviceType = "disk" scsi0:4.deviceType = "disk"
//老师讲课时有四行没有添加上,暂时保存下来
保存后打开虚拟机:
检验添加的三个磁盘:
/usr/lib/udev/scsi_id -g -u -d /dev/sdc
/usr/lib/udev/scsi_id -g -u -d /dev/sdd
/usr/lib/udev/scsi_id -g -u -d /dev/sde
自动挂载ASM存储设备:
for i in c d e ; do echo "KERNEL==\"sd$i\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/\$name\", RESULT==\"`/usr/lib/udev/scsi_id -g -u -d /dev/sd\$i`\", SYMLINK+=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" done
执行后输出信息:
KERNEL=="sdc", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$name", RESULT=="36000c29a4d2c41378ffa17ba124b964f", SYMLINK+="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sdd", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$name", RESULT=="36000c299bd83f11a666056e3845e0ba4", SYMLINK+="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sde", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$name", RESULT=="36000c293e55d1e0976ee481f5d72236f", SYMLINK+="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"
编辑相关文件
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
拷贝上面输出的信息到该文件中。
重启udev前不能看到asm存储设备:ls -l /dev/asm* (没有东西)
重启udev
systemctl restart systemd-udev-trigger.service
udevadm control --reload-rules
udevadm trigger
重启后能看到asm存储设备:ls -l /dev/asm*
关闭chrony服务:
systemctl stop chronyd
systemctl disable chronyd
mv /etc/chrony.conf /etc/chrony.conf.bak
systemctl status chronyd
禁用NTP模式(单机,没有配置,出错很正常的啦):
systemctl disable ntpd.service
systemctl stop ntpd.service
mv /etc/ntp.conf /etc/ntp.conf.bak
systemctl status ntpd
修改Selinux
getenforce //查看Selinux状态
setenforce 0 //临时关闭Selinux
vi /etc/sysconfig/selinux //编辑文件设置disabled
修改:SELINUX=enforcing => SELINUX=disabled
停止avahi-daemon服务:
systemctl disable avahi-daemon.socket
systemctl disable avahi-daemon.service
{
root用户
xhost +
}
{
grid用户
export DISPLAY=:0.0
cd $ORACLE_HOME
./gridSetup.sh
}
安装oracle 19c:
Configuration Oprion选择 Configure Oracle Grid Infrastructure for a Standalone Server (Oracle Restart)
Create ASM Disk Group的Redundancy选择External Disks全选
ASM Password 看自己,个人选择使用相同口令
Management Options 直接下一步
Operating System Groups 默认就ok了
Installation Location 下一步
Create Inventory 下一步
Root script execution 下一步
Prerequisite Checks 勾选Ignore All 然后下一步
{
此时个人出来可修补包Warning状态:
Package:cvuqdisk-1.0.10-1 Warning Yes
和不可修补的Warning状态:
Physical Memory Warning No
Swap Size Warning No
Package:kmod-20-21(x86_64) Warning No
Package:kmod-libs-20-21(x86_64) Warning No
}
Summary Install
Install Product
{
进度11%时,会弹窗授权的指示根据指示执行脚本
}
Finish Close
{
root用户:
cd /u01/app/grid/19.3/bin
./crsctl stat res -t
ps -ef |grep asm
}
{
grid用户
sqlplus / as sysdba
show parameter asm
select name,total_mb,free_mb from v$asm_diskgroup;
select inst_id,instance_name,status from gv$instance;
select name,total_mb,free_mb,path from v$asm_disk;
}
{
oracle用户
cd $ORACLE_HOME
cp /u01/soft/LINUX.X64_193000_db_home.zip ./
unzip LINUX.X64_193000_db_home.zip
{
安装前先检查一下tempfs大小
root用户
df -h
如果tmpfs小于2G (此处据说最低2g,个人测试时直接修改为4G了)
mount -o size=4G -o nr_inodes=1000000 -o noatime,nodiratime -o remount /dev/shm
vi /etc/fstab
添加:
tmpfs /dev/shm tmpfs default, size=64G 0 0
参考:https://www.cnblogs.com/halberd-lee/p/11645260.html
}
env |grep ORA
./runInstaller
Configuraion Option: Create and configure a instance database.
This option creates a starter database.
System Class: Server class
Database Edition: Enterprise Edition
Installation Location: Oracle base: /u01/app/db
Configuration Type: General Purpose / Transaction Processing
Database Identifiers: 此命名与env |grep GID相同,暂时不勾选Create as Container database
Configuration Options:
i.Memory不动
ii.Character sets: Choose from the following list of character sets 选择 ZHS16GBK - GBK 16-bit Simplified Chinese
iii.Sample schemas不动
Database Storage: Oracle Automatic Storage Management
Management Options: 下一步
Recovery Options: 下一步
·· ASM Disk Group: 下一步
Schema Passwords: 个人指定共用密码
Operationg System Groups:
{
dba
oper
backupdba
dgdba
kmdba
racdba
}
Root script execution: 下一步
Prerequisite Checks: Ignore All
Summary: Install
{
12%时会要求在root下执行/u01/app/db/product/19.3/db_1/root.sh
}
Install Product:
Finsh:
}
{
grid用户
asmca
Disk Grouops External(None)
}
{
oracle用户
netca //添加监听1522 newlistener
lsnrctl status newlistener
数据库:
create tablespace TJY_DATA datafile '+TJYDG/TESTDB/DATAFILE/TJY_DATA' size 8192M extent management local segment space management manual uniform size 1M /
--查询所拥有的表空间 select file_name,AUTOEXTENSIBLE,status,bytes/1024/1024 M from dba_data_files;
--修改system的表空间的大小并关闭自增 alter database datafile '+TJYDG/TESTDB/DATAFILE/system.257.1104134943' resize 4096M;
alter database datafile '+TJYDG/TESTDB/DATAFILE/system.257.1104134943' autoextend off;
--修改sysaux表空间的大小并关闭自增
alter database datafile '+TJYDG/TESTDB/DATAFILE/sysaux.258.1104134997' resize 4096M;
alter database datafile '+TJYDG/TESTDB/DATAFILE/sysaux.258.1104134997' autoextend off;
--修改undo表空间的大小并关闭自增
alter database datafile '+TJYDG/TESTDB/DATAFILE/undotbs1.259.1104135025' resize 4096M;
alter database datafile '+TJYDG/TESTDB/DATAFILE/undotbs1.259.1104135025' autoextend off;
--修改users表空间的大小并关闭自增
alter database datafile '+TJYDG/TESTDB/DATAFILE/users.260.1104135031' resize 4096M;
alter database datafile '+TJYDG/TESTDB/DATAFILE/users.260.1104135031' autoextend off;
--查询临时表空间 select * from dba_temp_files;
--修改临时表空间的大小并关闭自增 alter database tempfile '+TJYDG/TESTDB/TEMPFILE/temp.265.1104135161' resize 4096M; alter database tempfile '+TJYDG/TESTDB/TEMPFILE/temp.265.1104135161' autoextend off;
--查看undo表空间 show parameter undo_retention; show paramter undo;
--修改undo表空间保留时间 alter system set undo_retention=28800;
--查看表空间大小及其使用率
select tablespace_name,to_char(nvl(used_space*8192/1024/1024/1024,2),'999.00') as sum_gb,to_char(nvl(tablespace_size*8192/1024/1024/1024,2),'999.00') AS sum_gb,TO_CHAR(NVL(used_percent, 2), '9999.00') "Used %" from dba_tablespace_usage_metrics order by 4 desc;
--查看文件路径及其是否自动扩展
select file_name,AUTOEXTENSIBLE from dba_data_files;
--查询重做日志文件 select * from v$log; select * from v$logfile;
col member for a50; select v$logfile.group#,v$logfile.member,v$log.status,v$log.bytes/1024/1024 from v$logfile right join v$log on v$logfile.group#=v$log.group# order by v$log.group#; --添加重做日志文件组,并为重做日志文件组添加成员
alter database add logfile group 3 ('+TJYDG/TESTDB/ONLINELOG/group_3_1.log') size 300M; alter database add logfile member '+TJYDG/TESTDB/ONLINELOG/group_3_2.log' to group 3; --删除重做日志文件组
alter database drop logfile group 3; --切换重做日志文件组
alter system switch logfile;
alter system checkpoint;--全局检查点,写入脏数据
create user C##tjy identified by root default tablespace TJY_DATA account unlock; alter user C##tjy quota 100M on TJY_DATA; grant create session to C##tjy;
grant create table to C##tjy;
grant read,write on directory data_pump_dir to C##tjy; create table tjy_test( 考区 varchar2(255), 单位编号 varchar2(255), 岗位代码 varchar2(255), 招聘单位 varchar2(255), 岗位名称 varchar2(255), 岗位简介 varchar2(255), 岗位等级 varchar2(255), 聘用人数 varchar2(255), 考生类别 varchar2(255), 政治面貌 varchar2(255), 学历要求 varchar2(255), 学位要求 varchar2(255), 专业要求大专 varchar2(255), 专业要求本科 varchar2(255), 专业要求研究生 varchar2(255), 职称等级 varchar2(255), 职称系列 varchar2(255), 年龄 varchar2(255), 硕士研究生年龄要求 varchar2(255), 博士研究生副高以上职称年龄要求 varchar2(255), 是否需要工作经历 varchar2(255), 是否实行执业准入管理 varchar2(255), 准入类专业技术职业资格 varchar2(255), 准入类技能人员职业资格 varchar2(255) ); host sqlldr userid=C##tjy/root control=/u01/app/db/product/19.3/db_1/job.ctl cd /u01/app/db/product/19.3/db_1 mv ./job.* /u01/app/db/product/19.3/db_1 chmod 777 job.csv
}