Presentation is loading. Please wait.

Presentation is loading. Please wait.

Aleph 系统备份、恢复与同步 周磊 艾利贝斯北京代表处 2014 年6月.

Similar presentations


Presentation on theme: "Aleph 系统备份、恢复与同步 周磊 艾利贝斯北京代表处 2014 年6月."— Presentation transcript:

1 Aleph 系统备份、恢复与同步 周磊 艾利贝斯北京代表处 2014 年6月

2 提纲 操作系统文件的备份与同步 oracle数据表及数据库文件的备份与恢复 服务器移植与同步

3 操作系统文件的备份与同步 常用命令 本地文件系统 mv cp tar 远程文件系统 ftp wget scp rsync

4 本地文件系统- mv mv - move (rename) files - 移动或重命名文件 样例 特点:保持文件属性
mv source_file target_file mv source_file target_dir/ mv source_file target_dir/target_file 特点:保持文件属性

5 本地文件系统- cp cp - copy files and directories - 拷贝文件或目录 参数
-r copy directories recursively 拷贝目录 -p preserve file attribute 保持属性

6 本地文件系统- tar tar - create tape archives and add or extract files - 打包、解包 FUNCTION LETTERS 功能参数: -c create a new archive 打包 -x extract files from an archive 解包 -t list the contents of an archive 查看文件列表 -A append tar files to an archive -d find differences between archive and file system -r append files to the end of an archive -u only append newer --delete delete from the archive

7 本地文件系统- tar 参数: -f file 对象是文件而不是磁带
-v verbosely list files processed 显示文件列表 -z gzip 压缩 -h dump the files the link point to 获取连接原文件 --exclude PATTERN exclude files 排除 --keep-newer-files do not overwrite files which are newer than the archive -k, --keep-old-files keep existing files; don't overwrite them from archive

8 本地文件系统- tar 样例: tar -czf u20_1.tar.gz ./u20_1 打包
tar -xzf u20_1.tar.gz 解包 tar -tzvf u20_1.tar.gz 查看文件列表 tar -xzf whu01.exportSEQ.tar.gz z13.seqaa tar -czf --exclude “*/scratch/*” u20_1.tar.gz cat file_list |xargs tar –rf backup.tar //可以在file_list 文件中列出需要打包的文件或目录

9 远程文件系统- ftp ftp - Internet file transfer program 命令 open, user, bye
get, mget, put, mput ls, pwd, cd, lcd, mkdir ascii, bin passive prompt

10 远程文件系统- ftp 自动 ftp – 免登录 cd 到HOME 目录 创建或编辑文件 .netrc chmod 600 .netrc
machine login test password test // 注意: 在命令后面请留一个空行。 chmod 600 .netrc 编辑一个脚本文件,比如 ftp_list bin put ./u20_1/whu01/files/whu01.exportSEQ.tar.gz put ./u20_1/whu09/files/whu09.exportSEQ.tar.gz bye 运行 ftp < ftp_list

11 远程文件系统- ftp 自动 ftp – 通过脚本 cat ftp_list
ftp -ni < ftp_list > ftp.log & cat ftp_list user $ftp_user $ftp_passwd bin cd $ftp_backup_data/$backup_date lcd $backup_data/$backup_date mput *.tar.gz bye

12 远程文件系统- ftp lftp – mirror 镜像 mirror [OPTS] [source [target]]
Mirror specified source directory to local target directory

13 远程文件系统- wget wget - The non-interactive network downloader. 参数
-b background 在后台运行 -o logfile -c Continue getting a partially-downloaded file -q --quiet turn off Wget's output. -r turn on recursive retrieving. -m mirror Examples /usr/bin/wget -o ftp_apss.log -c -b

14 远程文件系统- scp scp - secure copy (远程文件系统拷贝程序) 样例:
scp -pr [...] -r copy directories recursively -p preserve file attribute 样例: scp -p :./u20_1/alephe/tab/tab_full_z39 ./ scp -p ./*.log scp -pr ./* cceu:`pwd` // 用反引号··括起pwd,是指将pwd(当前目录)命令的结果放在该位置,达到的效果是将当前文件拷贝到另外一台服务器的相同目录下.

15 远程文件系统- scp 通过ssh实现免登录 创建 SSH-key: ssh-keygen。 会在 ~/.ssh/下产生两个文件:
id_rsa.pub (公钥) id_rsa (密钥 ) scp 公钥文件id_rsa.pub 到远程服务器 cat id_rsa.pub >> ~/.ssh/authorized_keys (在远程服务器)

16 远程文件系统- rsync Rsync – Remote synchronization http://rsync.samba.org/
可以镜像保存整个目录树和文件系统。 可以很容易做到保持原来文件的权限、时间、软硬链接等等。 无须特殊权限即可安装。 优化的流程,文件传输效率高。 可以使用rcp、ssh等方式来传输文件,当然也可以通过直接的socket连接。 支持匿名传输,以方便进行网站镜象。

17 远程文件系统- rsync 安装rsync 以守护进程方式启动 rsync linux 缺省安装了
solaris 请到公司ftp: soft/rsync/下载 以守护进程方式启动 rsync rsync --daemon

18 远程文件系统- rsync Setting /etc/rsyncd.conf use chroot = yes
max connections = 1 syslog facility = local5 pid file = /var/run/rsyncd.pid log file = /tmp/rsync.log hosts allow = [utree] path=/exlibris/aleph/u20_1 exclude=*/scratch */files */print */apache/logs uid = aleph gid = exlibris read only=yes list = yes comment=Utree for ALEPH500. [atree] ……

19 远程文件系统- rsync Options 语法
Pull: rsync [OPTION...] [DEST] Push: rsync [OPTION...] SRC... Options -a, --archive 保持文件属性 -b, --backup 文件被覆盖前先做备份,缺省在原文件名后面加~。 --delete 慎用! -z, --compress --exclude=PATTERN --exclude-from=FILE

20 远程文件系统- rsync 同步脚本 csh -f $lcl_proc/exec_rsync.csh
$lcl_proc/rsync_auto.csh csh -f $lcl_proc/exec_rsync.csh 主要同步语句: rsync -avb --suffix=-bak exclude-from=/exlibris/aleph/exclude_file_rsync aleph94:/exlibris/aleph/u18_1/cnu50/ /exlibris/aleph/u18_1/cnu50/ 不参与同步的文件列表 /exlibris/aleph/exclude_file_rsync

21 cat /exlibris/aleph/exclude_file_rsync
alephe/aleph_start # alephe/www_server.conf # alephe/apache/conf/httpd.conf # alephe/apache/htdocs/.index.html # alephe/jboss_conf/main.properties # *local_define* # *job_list* # *settings.jsp *scratch/* # *print/* *report/* *files/* *Standalone* *loan_top_ten* *cache/* *access_log* *error_log* *tmp/* *log/* *logs/* *xml_logs/* *bor_pics*

22 远程文件系统- rsync host2-a18(1) >>csh -f $lcl_proc/exec_rsync.csh Please input the remote server's name aleph94 Please input the directory to do rsync /exlibris/aleph/u18_1/cnu50 The remote server is aleph94 The dir is /exlibris/aleph/u18_1/cnu50/ Right? Y/[N] Y The files have the same file name in two servers will be backup with -bak as suffix. rsync -avb --suffix=-bak exclude-from=/exlibris/aleph/exclude_file_rsync aleph94:/exlibris/aleph/u18_1/cnu50/ /exlibris/aleph/u18_1/cnu50/ > /exlibris/aleph/a18_1/tmp/rsync_ log.20183

23 远程文件系统- rsync rsync completed. Would you view the log? [Y]/N Y
The files have the same file name in two servers will be backup with -bak as suffix. Would you check these files? [Y]/N Y Check completed. 1. Files different in two servers : 2. Files older in local servers : 3. Files newer in local servers : 4. Files which contents are the same in two servers : 5. Edit the delete file list using vi 6. Delete backup files for the same files and old files 0. Exit Please select [0]:

24 远程文件系统- rsync 自动完成 需设置脚本中的 set remote_server = "aleph94"
csh -f /exlibris/aleph/a18_1/aleph/lclproc/rsync_auto.csh 需设置脚本中的 set remote_server = "aleph94" set target_dir = "/exlibris/aleph/a18_1/" set target_dir = "/exlibris/aleph/u18_1/"

25 提纲 操作系统文件的备份与同步 oracle数据表及数据库文件的备份与恢复 服务器移植与同步

26 Oracle 数据表及数据库的备份与恢复 单表备份与恢复 整个库的备份与恢复 oracle数据库的备份与恢复

27 单表的备份与恢复 p_file_03/p_file_04方式 oracle_exp_table/oracle_imp_table
导出纯文本文件 导入使用sqlldr 可以对文件进行修改再导入 数据中存在控制符可能会有问题 oracle_exp_table/oracle_imp_table 基于oracle 的exp/imp机制 oracle_expdp_table/oracle_impdp_table 基于oracle 的expdp/impdp机制 快!

28 单表导出 p_file_03

29 单表导出 p_file_03 导出结果文件 导出文件格式: 从命令行直接提交 在$data_files 目录下
文件名为 Znn.seqaa, Znn.seqab …… 导出文件格式: 定长 (FIX) 每个字段固定长度 (缺省) 定义 (DLM) 每个字段用 tab 分割 从命令行直接提交 csh -f $aleph_proc/p_file_03 CNU50,z31,,,DLM csh -f $aleph_proc/p_file_03 CNU50,z31,,,FIX

30 单表导入 p_file_04

31 单表导入 p-file-04 要导入的文件需放在库的files目录下 导入方式 导入文件格式: 从命令行直接提交
替换 (replace) (缺省) 追加(append) 导入文件格式: 定长 (FIX) 每个字段固定长度 (缺省) 定义 (DLM) 每个字段用 tab 分割 从命令行直接提交 csh -f $aleph_proc/p_file_04 CNU50,z31,replace,DLM csh -f $aleph_proc/p_file_04 CNU50,z31,append,FIX

32 单表导出/导入 导出/导入整个库,在表名位置填 all 导出/导入部分表
csh -f $data_root/source/backup_znn csh -f $data_root/source/restore_znn 注意修改其中的 set tables = 'z82 z83 z70 z72 z76 z66 z67 z601 z602 z62 z61 '

33 单表导入的日志 库的scratch目录下 数据中含回车符之类的控制符,导入前需处理,方法见论坛。
create_ora_context_z31 create_ora_tables_z31 z31.bad.1 导入不成功的文件,确认文件大小为0 z31.length z31_dmp_ora.ctl z31_dmp_ora.log.1 导入日志 z31_ora_dlm.sql 数据中含回车符之类的控制符,导入前需处理,方法见论坛。

34 整库导出/导入 exp_current_library imp_current_library oracle_exp_current_lib
机制同p_file_03/p_file_04 oracle_exp_current_lib oracle_imp_current_lib 使用oracle 的exp/imp 工具 oracle_expdp_current_lib oracle_impdp_current_lib 使用oracle的 expdp/impdp

35 整库导出/导入 导出 dlib cnu01 $aleph_proc/exp_current_library >& $TMPDIR/exp_cnu01.log & 结果文件在库的 files 目录下cnu01.exportSEQ.tar.gz 结果文件是一系列的znn.seq* 文件打包而成 结果文件压缩之后一个库大约0.5-3G 导出时间1-4小时

36 整库导出/导入 导入 dlib cnu01 cnu01.exportSEQ.tar.gz文件需放在 files目录下
$aleph_proc/imp_current_library TAR YES >& $TMPDIR/imp_cnu01.log & 注意导入时会清了整个库的数据再装入。 纯粹数据的导入,不能保留表的视图、权限等 时间2-6小时

37 备份与恢复 - exp_current_library
正式机job_list 中的定义

38 备份与恢复 - exp_current_library
备用机的job_list

39 备份与恢复 - exp_current_library
$lcl_proc目录下脚本 备份目录在$backup_data/$week 目录下 backup_data :将每个库的files目录下 $lib.exportSEQ.tar.gz的文件移到备份目录下 backup_ftp 将每天的备份文件ftp到备份机 restore_data:将备份目录下的备出文件拷贝到每个库的files目录下 imp_local_libraries 导入每个库的数据

40 整库备份 expdp/impdp 导出/导入 结果文件在 files/dpdir目录下 优点
导出 csh -f $aleph_proc/oracle_expdp_current_lib 导入 csh -f $aleph_proc/oracle_impdp_current_lib 结果文件在 files/dpdir目录下 CNU0101.dmp CNU0102.dmp CNU0103.dmp CNU0104.dmp CNU0105.dmp expCNU01.log 不压缩一个库备份文件大约2-10G 优点 快速 5-30分钟 保留表的视图、权限等

41 Oracle 数据库的备份与恢复 直接备份移植oracle数据文件 文件很大 G 通过RMAN备份与恢复

42 移植oracle数据文件 停oracle 拷贝以下目录到备份服务器 注意保持文件属性 /exlibris/oradata/$sid
/exlibris/app/oracle/admin/$sid /exlibris/app/oracle/product/11/dbs /exlibris/app/oracle/product/11/network/admin /exlibris/app/oracle/diag (oracle 11 才需要) 注意保持文件属性

43 移植oracle 数据文件 备份机的oracle数据文件路径、sid名最好与正式机一致
修改$ORACLE_HOME/network/admin下的文件,涉及到主机名、ip等

44 移植oracle 数据文件 修改oracle 参数表 sqlplus /nolog idle> conn / as sysdba;
idle> show parameters service_names idle> show parameters db_domain idle> alter system set service_names='aleph2' scope=spfile; idle> alter system set db_domain='test' scope=spfile; idle> shutdown immediate idle> startup

45 Oracle 数据库备份与恢复 - RMAN RMAN是Oracle自带的一个备份与恢复工具 可以对数据库实现完整备份和恢复 支持热备
支持增量备份 备份、恢复速度快,文件小 支持完全恢复、不完全恢复 通过脚本实现备份 需启动archive模式 需设置备份策略

46 Oracle 数据库备份与恢复 - RMAN Exlibris backup package 公司提供的一个备份恢复包
可以实现对数据库、数据、应用程序、参数表等的备份与恢复 其中对数据库的备份基于RMAN 改造 backup_package.2.6.lcl.tar.gz

47 backup package 安装 下载 backup_package.2.6.lcl.tar.gz
解压到 /exlibris/backup 目录下 conf logs scripts 配置 /exlibris/backup/conf/ bkp_init.dat bkp_param.conf 创建backup_files 目录(存放备份结果) mkdir /exlibris/backup_files chmod 777 /exlibris/backup_files

48 backup package bkp_param.conf setenv BKP_ROOT /exlibris/backup
setenv BKP_DIR /exlibris/backup_files/ setenv SUCCESS_BKPS 3 setenv BKP_MAIL

49 backup package bkp_init.dat #Aleph
a1:aleph:aleph:/exlibris/aleph/a20_1:ora_cold a2:aleph:aleph:/exlibris/aleph/a20_1:ora_hot a3:aleph:aleph:/exlibris/aleph/a20_1:ora_archive a4:aleph:aleph:/exlibris/aleph/a20_1:prd_software a5:aleph:aleph:/exlibris/aleph/a20_1:user_data a6:aleph:aleph:/exlibris/aleph/a20_1:exp_user_data

50 backup package 执行RMAN备份 结果文件在 /exlibris/backup_files/
cd /exlibris/backup/scripts 冷备 ./exec_backup_main a1 & 热备 ./exec_backup_main a2 & 备份归档 ./exec_backup_main a3 & 结果文件在 /exlibris/backup_files/ ALEPH20_11_ora_hot_ _460_1 ALEPH20_11_ora_hot_ _460_2 ALEPH20_11_ora_hot_ _460_3 aleph20_11_ora_hot_control_file_c

51 RMAN 恢复 以oracle用户执行/exlibris/backup/scripts/restore_rman
rman target / set DBID ; startup nomount; set CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/exlibris/backup_files/aleph20_11_ora_hot_control_file_%F'; RESTORE CONTROLFILE FROM AUTOBACKUP; alter database mount; restore database; recover database; alter database open resetlogs; 以oracle用户执行/exlibris/backup/scripts/restore_rman 具体请参见《RMAN备份与恢复手册》

52 RMAN 备份策略 推荐:每周做一次停机冷备,然后每天做热备 可以定义到root用户的crontab里 也可以采用每天热备方式
~]# crontab -l 10 02 * * 0 /exlibris/backup/scripts/exec_backup_main a1 10 02 * * 1-6 /exlibris/backup/scripts/exec_backup_main a2 也可以采用每天热备方式 10 02 * * * /exlibris/backup/scripts/exec_backup_main a2

53 提纲 操作系统文件的备份与同步 oracle数据表及数据库文件的备份与恢复 服务器移植与同步

54 ALEPH 产品目录结构 Products - cobol gcc apache perl ALEPH (../a20_1) Oracle
software (../app) data-base (../oradata) Unix Server alephe (../u20_1) Libraries (../u20_1/ndu01)

55 a20_1 vs. u20_1 通常每个用户安装时都有: a20_1 和 u20_1. a20_1 公司的程序 u20_1 用户的配置
exlibris /aleph a20_1 u20_1 EXU50… usm50 usm01 … alephe (original) alephe (active) EXU01…

56 ALEPH产品移植的步骤 标准安装的pre_exlibris部分 标准安装或移植oracle、product 移植aleph目录
18版执行setup_2 到 setup_5 20版执行ikit_menu 2 完成用户创建,操作系统参数修改,目录创建等 标准安装或移植oracle、product 移植aleph目录 atree (a18_1, a20_1) utree (u18_1, u20_1) 修改跟服务器有关的参数

57 ALEPH产品移植 需移植的目录: 以下可在安装时创建。 /exlibris/aleph/a20_1
/exlibris/aleph/u20_1 以下可在安装时创建。 /exlibris/app/ /exlibris/product/ /exlibris/oradata

58 ALEPH 产品移植 移植后需修要文件: 修改内容 alephe/aleph_start alephe/www_server.conf
alephe/apache/conf/httpd.conf alephe/apache/htdocs/.index.html alephe/apache/cgi-bin/opac.conf alephe/jakarta-tomcat /conf/server.xml alephe/jakarta-tomcat /webapps/apsm/settings.jsp alephe/jakarta-tomcat /webapps/apss/settings.jsp alephe/jakarta-tomcat /webapps/easysql/settings.jsp alephe/jboss_conf/main.properties alephe/tab/tab100 修改内容 主机名,IP地址 oracle sid

59 ALEPH 产品移植 跨平台移植: 以下目录跟平台相关: 以下目录下的文件需要重新编译 $aleph_exe $alephm_proc
$alephe_root/aleph_start 以下目录下的文件需要重新编译 $alephm_source/ffs $alephm_source/ffs_opac $alephm_source/preorder $alephm_source/ffs_xxx (xxx是用户代码) 所有自定义批处理服务。

60 ALEPH 产品移植 注意事项: 先执行aleph_shutdown 停所有应用
通过du –sh * 查看那个目录文件比较多,需要手工删除无效文件。

61 Oracle的移植 同平台的情况 跨平台的情况 方法一:直接移植oradata目录下的数据文件 方法二:Rman备份恢复
修改oracle参数:db_domain,service_name,memory 修改listener,tnsname 跨平台的情况 需导出数据再导入到另外服务器上 导出/导入方法可以是: exp_current_library / imp_current_library oracle_expdp_current_lib / oracle_impdp_current_lib oracle_exp_current_lib / oracle_imp_current_lib 需手工创建opac,easysql, 门禁的帐户或表、视图

62 服务器同步 在正式机上运行: 数据文件的备份与同步 数据库的备份 exp_current_library backup_data
backup_ftp 数据库的备份 以root用户定义crontab 10 02 * * * /exlibris/backup/scripts/exec_backup_main a2

63 服务器同步 在备机上 同步参数表和程序,aleph用户的crontab 同步数据库备份文件,oracle用户的crontab
00 07 * * 1 csh -f /exlibris/aleph/a20_1/aleph/lclproc/rsync_auto.csh 同步数据库备份文件,oracle用户的crontab 10 07 * * * rsync -a --delete aleph1:/exlibris/backup_files/ /exlibris/backup_files/

64 作业 查看本馆job_list 找出跟数据备份相关的定义 查看本馆root用户和aleph用户的crontab
确认本馆数据备份目录,查看数据备份文件大小

65 谢谢!


Download ppt "Aleph 系统备份、恢复与同步 周磊 艾利贝斯北京代表处 2014 年6月."

Similar presentations


Ads by Google