虚拟机系统安装以及oracle数据库系统备份、恢复

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

虚拟机及数据库系统安装步骤
第一步:选择虚拟机安装文件包安装虚拟机
通过从网上下载安装包VMware-workstation-6.0.3-80004,经过解压缩,鼠标双击VMware-workstation-6.0.3-80004.exe安装文件进行安装(按照系统提示)即可。

如果是在linux上安装,需要下载虚拟机与linux系统对应的安装版本,通过ftp或者scp 到linux操作系统,解压缩后执行安装包的安装文件即可。

第二步:安装操作系统
虚拟机安装好后,启动虚拟机,单击新虚拟机安装,如下图:选择第一项
随后弹出选择安装方式窗口,选择Typcal方式
单击下一步,选择安装操作系统的类型,我安装的是linux系统,选择linux系统后继续选择具体的linux系统类型,如下图:
单击下一步,对系统进行命名,如下图:
打击下一步,选择虚拟机的网络连接类型,选择桥连接,如下图:
单击下一步,指定虚拟机的虚磁盘容量,如下图:
然后单击完成,此时虚拟机的设置完成,随后将对应的操作系统安装盘插入光驱,鼠标单击菜单的启动按钮,启动虚拟机,虚拟机首先检查是否存在操作系统,没有操作系统则自动读取光驱进行系统安装。

如下图:
启动后,如下图:
选择图形安装,直接回车即可。

然后弹出选择安装语言的窗口,如下图
根据需要选择简体中文或者英文都可。

然后单击下一步选择键盘类型,
直接默认,继续下一步,随后确定磁盘分区方式,可根据需要自行添加分区和挂载点
单击继续,下一步配置引导程序,默认即可。

如下图:
下一步进行网络配置时,可以先暂时默认继续,等系统安装后再通过界面修改网络设置,如下图
随后,系统会让用户设定root的口令,输入两遍。

然后,系统开始收集安装信息,进行安装。

安装完毕后,系统重启,退出光盘即可。

第三步:安装数据库
在linux系统下安装Oracle9i数据库的时候,准备工作很重要,需要分以下几步进行。

1.创建用户和组
# su –
# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba oracle
# passwd oracle
2.创建目录
我们将把所有东西都安装到在 /oracle 目录下:
# mkdir /oracle
# chown -R oracle.oinstall / oracle
3.系统配置
a)设置内核参数
编辑/etc/sysctl.conf
kernel.shmmax = 536870912 这里设置为物理内存的一半 1G内存的话为:512×1024×1024 kernel.shmmni = 4096 2G 内存的话为:1024×1024×1024
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128 其他的值都不用动
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
执行sysctl以反映修改使内核参数立刻生效,重启也可以
# sysctl –p
b)设置oracle对文件的要求
修改文件:/etc/security/limits.conf
#echo oracle soft nofile 65536 >> /etc/security/limits.conf
#echo oracle hard nofile 65536 >> /etc/security/limits.conf
#echo oracle soft nproc 16384 >> /etc/security/limits.conf
#echo oracle hard nproc 16384 >> /etc/security/limits.conf
c)设置环境变量
在/home/oracle/.bash_profile 中添加如下行:
export ORACLE_SID=orcl
export ORACLE_BASE= /oracle
export ORACLE_HOME= /oracle/product/9.2.0
d)安装补丁包
打p3006854_9204_LINUX.zip
# unzip p3006854_9204_LINUX.zip
# chmod +x 3006854/rhel3_pre_install.sh
# 3006854/rhel3_pre_install.sh
安装 compat-libcwait-2.1-1.i386.rpm
# rpm -ivh compat-libcwait-2.1-1.i386.rpm
安装compat-libstdc++-296-2.96-138.i386、compat-libstdc++-33-3.2.3-61.i386
# rpm –ivh compat-libstdc++-296-2.96-138.i386
# rpm –ivh compat-libstdc++-33-3.2.3-61.i386
一些需要的包,这些包可以从系统盘中找到
# rpm -ivh compat-db-4.2.52-5.1.i386.rpm
# rpm -ivh libXp-1.0.0-8.i386.rpm
# rpm -ivh libXp-devel-1.0.0-8.i386.rpm
# rpm -ivh openmotif-2.3.0-0.3.el5.i386.rpm
# rpm -ivh openmotif-devel-2.3.0-0.3.el5.i386.rpm
gnome-libs-1.4.2-7.rhel5.i386.rpm 和一些依赖包
这些包网上都可以找到,也可以从 /download.zip 下载
# rpm -ivh giflib-4.1.3-8.i386.rpm
# rpm -ivh glib-1.2.10-26.fc7.i386.rpm
# rpm -ivh libpng10-1.0.18-2.i386.rpm
# rpm -ivh ORBit-0.5.17-22.rhel5.i386.rpm
# rpm -ivh gtk+-1.2.10-57.fc7.i386.rpm
# rpm -ivh imlib-1.9.15-2.fc7.i386.rpm
# rpm -ivh gnome-libs-1.4.2-7.rhel5.i386.rpm
创建链接
# ln -s /usr/lib/libstdc++-libc6.2-2.so.3 /usr/lib/libstdc++-libc6.1-1.so.2
e)在root下启动xhost + ,随后直接在虚拟机上安装数据库。

# Disk1/runInstaller
没有特别说明的均按默认设置,根据界面提示,然后点 Next 或 OK即可.
这个过程中还会出现两次提示,让你运行指定目录下的脚本,根据提示做就可以了。

安装过程中可以暂时只安装数据库产品,安装完毕后再通过dbca 创建数据库;也可以随着
安装过程安装数据库。

在oracle9i上执行热备份和恢复
准备工作:
创建表空间
SQL> create tablespace oratbs datafile '/oracle/oradata/oradbs/oratbs01.dat' size 60M; Tablespace created.
SQL> create user oradb identified by oradb;
User created.
SQL> grant dba to oradb;
Grant succeeded.
SQL> commit;
Commit complete.
SQL>CREATE TABLE oradb.APPRUNPARAM
(
PARAMNAME V ARCHAR2(40 BYTE),
PARAMCODE V ARCHAR2(4 BYTE),
PARAMV ALUE V ARCHAR2(32 BYTE)
)
TABLESPACE oratbs
NOLOGGING
NOCACHE
NOPARALLEL;
COMMENT ON COLUMN oradb.APPRUNPARAM.PARAMNAME IS '参数名称'; COMMENT ON COLUMN oradb.APPRUNPARAM.PARAMCODE IS '参数代码'; COMMENT ON COLUMN oradb.APPRUNPARAM.PARAMV ALUE IS '参数值'; DROP TABLE oradb.APPRUNPARAM CASCADE CONSTRAINTS
*
SQL> 2 3 4 5 6 7 8 9 10
Table created.
SQL> SQL>
Comment created.
SQL>
Comment created.
SQL>
Comment created.
SQL> insert into apprunparam values('123456789','abcd','open');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into apprunparam values('987654321','xyzt','curr');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into apprunparam values('987654321','xyzt','curr');
1 row created.
SQL> commit;
Commit complete.
一、数据文件受损情况
1:
SQL> archive log list;
Database log mode No Archive Mode Automatic archival Disabled
Archive destination /oracle/9.2.0/dbs/arch Oldest online log sequence 1
Current log sequence 3
2:
SQL> alter system set log_archive_start=true scope=spfile; System altered.
3:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
4:
SQL> startup mount;
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
5:
SQL> alter database archivelog;
Database altered.
6:
SQL> archive log list;
Database log mode Archive Mode Automatic archival Enabled
Archive destination /oracle/9.2.0/dbs/arch Oldest online log sequence 1
Next log sequence to archive 3
Current log sequence 3
7:
SQL> alter database open;
Database altered.
8:开始备份表空间
SQL> alter tablespace oratbs begin backup; Tablespace altered.
9:然后对数据文件进行备份
结束表空间备份
SQL> alter tablespace oratbs end backup;
Tablespace altered.
SQL> alter system archive log current;
System altered.
SQL> alter system archive log current;
System altered.
10:多次切换日志,进行归档备份
SQL> alter system switch logfile ;
System altered.
SQL> alter system switch logfile ;
System altered.
SQL> alter system switch logfile ;
System altered.
11:切换完成后停掉数据库,删除数据文件*。

DBF
SQL> startup mount
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes Variable Size 201326592 bytes Database Buffers 33554432 bytes
Redo Buffers 667648 bytes Database mounted.
12:开始恢复过程的步骤
SQL> select * from v$recover_file;
结果集省略了
SQL> alter database datafile 1 offline drop; Database altered.
SQL> alter database datafile 2 offline drop; Database altered.
SQL> alter database datafile 3 offline drop; Database altered.
SQL> alter database datafile 4 offline drop; Database altered.
SQL> alter database datafile 5 offline drop; Database altered.
SQL> alter database datafile 6 offline drop; Database altered.
SQL> alter database datafile 7 offline drop;
Database altered.
SQL> alter database datafile 8 offline drop;
Database altered.
SQL> alter database datafile 9 offline drop;
Database altered.
13:开始恢复数据文件;
recover datafile 1;
ORA-00279: change 209860 generated at 07/21/2008 01:57:37 needed for thread 1 ORA-00289: suggestion : /oracle/9.2.0/dbs/arch1_9.dbf
ORA-00280: change 209860 for thread 1 is in sequence #9
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Auto 采用自动
ORA-00279: change 213277 generated at 07/21/2008 02:20:28 needed for thread 1 ORA-00289: suggestion : /oracle/9.2.0/dbs/arch1_10.dbf
ORA-00280: change 213277 for thread 1 is in sequence #10
ORA-00278: log file '/oracle/9.2.0/dbs/arch1_9.dbf' no longer needed for this recovery
ORA-00279: change 213666 generated at 07/21/2008 02:22:39 needed for thread 1 ORA-00289: suggestion : /oracle/9.2.0/dbs/arch1_11.dbf
ORA-00280: change 213666 for thread 1 is in sequence #11
ORA-00278: log file '/oracle/9.2.0/dbs/arch1_10.dbf' no longer needed for this recovery
ORA-00279: change 213674 generated at 07/21/2008 02:22:54 needed for thread 1 ORA-00289: suggestion : /oracle/9.2.0/dbs/arch1_12.dbf
ORA-00280: change 213674 for thread 1 is in sequence #12
ORA-00278: log file '/oracle/9.2.0/dbs/arch1_11.dbf' no longer needed for this recovery
Log applied.
Media recovery complete.
其他几个数据文件的恢复同上
14:设定数据文件联机,并最终打开数据库
SQL> alter database datafile 1 online;
Database altered.
其他数据文件同上
SQL> alter database open;
Database altered.
SQL> select * from oradb.apprunparam;
PARAMNAME PARA PARAMV ALUE ---------------------------------------- ---- --------------------------------
123456789 abcd open
987654321 xyzt close
987654321 xyzt curr
二,控制文件受损
首先对控制文件做备份
然后执行
SQL> alter database backup controlfile to trace;
Database altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@localhost ora9i]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Jul 21 03:04:03 2008 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> @/tmp/control.sql
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Control file created.
SP2-0734: unknown command beginning "Recovery i..." - rest of line ignored. SP2-0734: unknown command beginning "or if the ..." - rest of line ignored. ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required
由此控制文件全部被重建
SQL> select * from oradb.apprunparam;
PARAMNAME PARA PARAMV ALUE ---------------------------------------- ---- --------------------------------
123456789 abcd open
987654321 xyzt close
987654321 xyzt curr
三、日志文件丢失的情况
关闭数据库
将日志文件备份,并删除日志文件
打开数据库
SQL> startup mount;
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> select * from v$recover_file;
no rows selected
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: '/oracle/oradata/ora9i/redo01.log'
SQL> recover database until cancel;
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
之后日志重新生成;
不完全恢复:
基于恢复到某一个时点:
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2008-07-23 05:24:17
然后,通过
SQL> alter system switch logfile;
SQL> alter system switch logfile;
重新启动到mount模式下
SQL> recover database until time '2008-07-23 05:24:17';
Media recovery complete.
5)数据库rman备份
创建rmanbak用户;
使得数据库处于自动归档模式;
SQL>startup;
SQL>alter system archive log start;
1:连接
Rman target=rmanbak/rmnabak
2:设定配置
RMAN> configure default device type to disk;
RMAN> configure device type disk parallelism 2;
RMAN> configure channel 1 device type disk format '/oracle/rmanbak/rmanbak1/rmanbak_%U'; RMAN>configure channel 2 device type disk format '/oracle/rmanbak/rmanbak2/rmanbak_%U';
RMAN> configure controlfile autobackup on;
RMAN>configure controlfile autobackup format for device type disk to '/oracle/rmanbak/ctl_%F';
利用RMAN备份全库的脚本:
run{
allocate channel c1 type disk;
backup full tag 'dbfull' format '/oracle/rmanbak/full%u_%s_%p' database include current controlfile;
sql 'alter system archive log current';
release channel c1;
}
恢复全库的脚本:
run{
allocate channel c1 type disk;
restore database;
recover database;
sql 'alter database open';
release channel c1;
}
不完全恢复
SQL> select max(ktuxescnw * power(2, 32) + ktuxescnb) scn from x$ktuxe;
SCN
----------
420841
开始恢复到改变点SCN XXXXX
RMAN> run{
allocate channel c1 type disk;
restore database;
recover database until scn 423765;
sql 'ALTER DATABASE OPEN RESETLOGS';
release channel c1;
}
安装vsftpd独立服务的ftp服务器
安装vsftpd最新版本,并自行编译代码。

启动vsftpd的独立服务。

可通过设定的系统用户下载、上传文件。

编写列树形目录的SHELL 脚本。

相关文档
最新文档