= oracle 10G 安裝以及 rman 備份測試 =
= 操作系統:redhat 5.4 =
= oracle:10.2.0 =
==============================================================
----------------==========linux系統部分,oracle10g數據的安裝=====================--------
1.修改linux系統的內核:因爲oracle 的官方只支持到RHEL4爲止,所以要修改版本說明。把Red Hat Enterprise Linux Server release 5.4 (Tikanga)這一行註釋掉,
前面加上一行redhat-4。當然oracle安裝完成後要修改回來。redhat-4 必須爲redhat-release文件的第一行,否則安裝時還會報警告。
[root@localhost ~]# cat /etc/redhat-release /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[root@localhost ~]# vi /etc/redhat-release
redhat-4
#Red Hat Enterprise Linux Server release 5.4 (Tikanga)
2.修改內核參數:
[root@localhost ~]# vi /etc/sysctl.conf
--增加下面的內容到文件中:
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
--運行下面的命令使得內核參數生效:
[root@localhost ~]# /sbin/sysctl -p
3. 建立安裝Oracle需要的用戶、組及目錄
--新增組和用戶:
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# groupadd oper
[root@localhost ~]# useradd -g oinstall -G dba oracle
[root@localhost ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully
--創建Oracle的安裝目錄,並把權限付給oracle用戶:
[root@localhost ~]# mkdir -p /u01/app/oracle/product/10.2.0/db_1
[root@localhost ~]# chown -R oracle.oinstall /u01
4. 設置oracle用戶的shell limit
[root@localhost ~]# vi /etc/security/limits.conf
--增加下面的內容到文件 /etc/security/limits.conf 文件中:
* soft nproc 2047
* hard nproc 16384
* soft nofile 1024
* hard nofile 65536
--增加下面的內容到文件 /etc/pam.d/login 中,使shell limit生效:
session required /lib/security/pam_limits.so
[root@localhost ~]# echo session required /lib/security/pam_limits.so>>/etc/pam.d/login
/*
[root@localhost ~]# cat /etc/pam.d/login
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session include system-auth
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session optional pam_keyinit.so force revoke
session required /lib/security/pam_limits.so
*/
5.配置靜態IP地址
--安裝RedHat Linux的時候最好採用靜態IP地址,如果當時選擇的是DHCP,現在需要更改/etc/sysconfig/network-scripts/ifcfg-eth0文件:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=168.169.88.255
HWADDR=00:0C:29:80:93:CB
IPADDR=168.169.88.221
IPV6INIT=yes
IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
NETWORK=168.169.88.254
ONBOOT=yes
7.修改/etc/hosts
--把127.0.0.1改爲具體的ip地址,注意最好去掉那些無用的,格式如下:ip地址 – 主機名 – localhost
[root@localhost ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
168.169.88.221 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
8.關閉SeLinux
--因爲SeLinux對oracle有影響,所以把Secure Linux設成無效,編輯文件/etc/selinux/config :SELINUX=disabled
[root@localhost ~]# cat /etc/selinux/config
#SELINUXTYPE=targeted
SELINUX=disabled
--當然你也可以用圖形界面下的工具 (系統 > 管理 > 安全級別和防火牆),選擇SELinux頁面並且設爲無效
9.配置Oracle用戶的環境變量
--登錄到oracle用戶並且配置環境變量,編輯/home/oracle目錄下的.bash_profile文件
--增加下面的內容到文件 .bash_profile
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
[oracle@localhost ~]$ vi .bash_profile
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=$PATH:$ORACLE_HOME/bin; export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JREORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
----裏面的SID在安裝數據庫時候如果修改了,安裝完後需要回來重新修改SID。
----修改完用“source .bash_profile”使其生效。
10.修改開機使用文本模式登錄
---如果沒有下面這些步驟,oracle在安裝時可能出現問題。可能會出現使用oracle用戶啓動安裝界面的時候報錯,無法啓動圖形化界面。
[root@localhost ~]# su - root
#vi /etc/inittab
把 id:5:initdefault: 修改爲 id:3:initdefault,等oracle安裝完成後可以修改回來。
#reboot(重啓)
11.添加你的機器oracle用戶可以使用圖形化界面
--在文本模式下,用root登錄,然後:
[root@localhost ~]# startx
[root@localhost ~]# xhost +
[root@localhost ~]# su - oracle
[root@localhost ~]# export DISPLAY="168.169.88.221" #此處修改爲你的IP地址
[root@localhost ~]# export LANG=en_US #設置運行語言
[root@localhost ~]# cd /mnt/share/databases #進入Oracle安裝目錄
[root@localhost ~]# ./runInstaller #開始安裝嘍
12.linux 中文顯示亂碼解決辦法
[root@localhost ~]# vi /etc/sysconfig/i18n
--將內容改爲
LANG="zh_CN.GB18030"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
SYSFONT="lat0-sun16"
這樣中文在SSH,telnet終端就可以正常顯示了
----------------==========oracle數據庫的環境設置=====================--------
數據庫的設置:設置爲歸檔模式
1.查看數據的當前工作模式:
SQL> select dbid,name,log_mode from v$database;
DBID NAME LOG_MODE
---------- --------- ------------
1317831093 ORCL NOARCHIVELOG
2. 關閉數據庫,更改數據庫的工作模式爲歸檔模式
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 239075328 bytes
Fixed Size 1218724 bytes
Variable Size 83887964 bytes
Database Buffers 150994944 bytes
Redo Buffers 2973696 bytes
SQL> alter database mount;
Database altered.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 3
SQL> alter database archivelog;
Database altered.
SQL> alter database archivelog; -----更改數據庫爲歸檔模式
Database altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 3
Current log sequence 3
3.創建備份目錄
[oracle@localhost ~]$ pwd
/home/oracle
[oracle@localhost ~]$mkdir -p databak
[oracle@localhost ~]$mkdir -p databak/archlog
[oracle@localhost ~]$mkdir -p databak/database
[oracle@localhost ~]$mkdir -p databak/ctrl
4.啓動監聽服務
[oracle@localhost ~]$ lsnrctl
LSNRCTL> start
LSNRCTL> status
5.備份測試:登陸rman,非catalog連接備份
[oracle@localhost ~]$ rman nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Jul 31 05:21:55 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
[oracle@localhost ~]$ connect target /
RMAN> list backupset;
RMAN>
--設置控制文件自動備份(autobackup on)
RMAN> configure controlfile autobackup on; ------->設置自動備份
RMAN> configure controlfile autobackup format for type disk to '/opt/data/%f'; ---->設置自動備份的格式
------零級增量備份,增量備份的基礎
RMAN> run
2> {
3> allocate channel c1 device type disk maxopenfiles=4;
4> backup incremental level 0 filesperset 4
5> format "/home/oracle/databak/database/orcl_%d-%T-%t-%s.dbl0" database;
6> crosscheck archivelog all;
7> backup not backed up archivelog all format "/home/oracle/databak/archlog/orcl_%d-%T-%t-%s.arch" maxsetsize=4G;
8> release channel c1;
9> }
allocated channel: c1
channel c1: sid=158 devtype=DISK
Starting backup at 01-AUG-12
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
channel c1: starting piece 1 at 01-AUG-12
channel c1: finished piece 1 at 01-AUG-12
piece handle=/home/oracle/databak/database/orcl_ORCL-20120801-790194238-1.dbl0 tag=TAG20120801T182358 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:47
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel c1: starting piece 1 at 01-AUG-12
channel c1: finished piece 1 at 01-AUG-12
piece handle=/home/oracle/databak/database/orcl_ORCL-20120801-790194285-2.dbl0 tag=TAG20120801T182358 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:26
Finished backup at 01-AUG-12
Starting Control File and SPFILE Autobackup at 01-AUG-12
piece handle=/home/oracle/databak/ctrl/c-1317966119-20120801-00 comment=NONE
Finished Control File and SPFILE Autobackup at 01-AUG-12
specification does not match any archive log in the recovery catalog
Starting backup at 01-AUG-12
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=1 stamp=790194323
channel c1: starting piece 1 at 01-AUG-12
channel c1: finished piece 1 at 01-AUG-12
piece handle=/home/oracle/databak/archlog/orcl_ORCL-20120801-790194324-4.arch tag=TAG20120801T182524 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
Finished backup at 01-AUG-12
Starting Control File and SPFILE Autobackup at 01-AUG-12
piece handle=/home/oracle/databak/ctrl/c-1317966119-20120801-01 comment=NONE
Finished Control File and SPFILE Autobackup at 01-AUG-12
released channel: c1
6.設計增量備份的備份方案,目標:做到數據庫 7X24 小時 運行
----------------------========================安裝過程報錯解決==================================------------------------
------有時安裝過程中會報如下錯誤
reparing to launch Oracle Universal Installer from /tmp/OraInstall2014-03-06_04-55-30PM.
Please wait ...[oracle@localhost database]$ Exception in thread "main" java.lang.UnsatisfiedLinkError:
/tmp/OraInstall2014-03-06_04-55-30PM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.NativeLibLoader.loadLibraries(Unknown Source)
at sun.awt.DebugHelper.<clinit>(Unknown Source)
at java.awt.Component.<clinit>(Unknown Source)
-----掛載linux安裝盤,安裝相應的包
[root@localhost Server]# ls -lh libXp*
-rwxrwxrwx 1 root root 23K 2007-07-26 libXp-1.0.0-8.1.el5.i386.rpm
-rwxrwxrwx 1 root root 15K 2007-07-26 libXp-devel-1.0.0-8.1.el5.i386.rpm
-rwxrwxrwx 1 root root 46K 2007-01-18 libXpm-3.5.5-3.i386.rpm
-rwxrwxrwx 1 root root 31K 2007-01-18 libXpm-devel-3.5.5-3.i386.rpm
[root@localhost Server]# rpm -ivh libXp-devel-1.0.0-8.1.el5.i386.rpm
warning: libXp-devel-1.0.0-8.1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libXp = 1.0.0-8.1.el5 is needed by libXp-devel-1.0.0-8.1.el5.i386
libXp.so.6 is needed by libXp-devel-1.0.0-8.1.el5.i386
[root@localhost Server]# rpm -ivh libXpm-3.5.5-3.i386.rpm
warning: libXpm-3.5.5-3.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package libXpm-3.5.5-3.i386 is already installed
[root@localhost Server]# rpm -ivh libXpm-devel-3.5.5-3.i386.rpm
warning: libXpm-devel-3.5.5-3.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package libXpm-devel-3.5.5-3.i386 is already installed
[root@localhost Server]# rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm
warning: libXp-1.0.0-8.1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:libXp ########################################### [100%]
[root@localhost Server]# rpm -ivh libXp-devel-1.0.0-8.1.el5.i386.rpm
warning: libXp-devel-1.0.0-8.1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:libXp-devel ########################################### [100%]