==============================================================
=
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.(Unknown Source)
at java.awt.Component.(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%]