签到成功

知道了

CNDBA社区CNDBA社区

Oracle 11g 通过copy 方式安装并使用不同的用户组

2018-09-20 15:09 2497 0 原创 Oracle 11g
作者: dave

1. 背景说明

一般直接copy ORACLE_HOME时,都会选择相同的用户,路径和group,我们这里演示一个复杂一点的案例。

通过直接copy的方式安装Oracle,速度也会比我们通过GUI安装快很多。

Source 端已经安装好一个Oracle 11.2.0.4的数据库了,我们直接copy这个数据库。

2. Target 的准备工作

这里有很多,包括安装包,配置环境变量,修改参数,创建用户和组等信息。 http://www.cndba.cn/dave/article/3077

http://www.cndba.cn/dave/article/3077

最简单的,就是Source 和Target 使用相同的用户和组。 我们这里使用不同的组来测试。

Source:
[ora11g@www.cndba.cn bin]$ id ora11g
uid=502(ora11g) gid=501(oinstall) groups=501(oinstall),502(dba)

我们在Target 端建一个新用户: newora, 所有的组都加new* 前缀。http://www.cndba.cn/dave/article/3077

[dave@www.cndba.cn ~]# groupadd newoinstall
[dave@www.cndba.cn ~]# groupadd newdba
[dave@www.cndba.cn ~]# groupadd newoper
[dave@www.cndba.cn ~]# useradd -g newoinstall -G newdba newora
[dave@www.cndba.cn ~]# passwd newora
Changing password for user newora.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[dave@www.cndba.cn ~]#

3. Source 端打包ORACLE_HOME

注意:用root打包,有些包oracle用户打不了。http://www.cndba.cn/dave/article/3077http://www.cndba.cn/dave/article/3077

[dave@www.cndba.cn 11.2.0]# pwd
/home/ora11g/oracle/product/11.2.0
[dave@www.cndba.cn 11.2.0]# ls
db_1
[dave@www.cndba.cn 11.2.0]# tar zcvfp db_1.tar.gz db_1

[dave@www.cndba.cn 11.2.0]# ls -lh
total 2.3G
drwxr-xr-x. 74 ora11g oinstall 4.0K Jul 20 19:08 db_1
-rw-r--r--   1 root   root     2.3G Jul 22 01:01 db_1.tar.gz

4. 把TAR包传到Target并解压缩

我这里是在同一个机器上操作,做事直接cp或者mv过去。 不同机器,就用scp命令。http://www.cndba.cn/dave/article/3077

[dave@www.cndba.cn 11.2.0]# mv db_1.tar.gz /home/newora/

[dave@www.cndba.cn 11.2.0]# cd /home/newora
[dave@www.cndba.cn newora]# ls
db_1.tar.gz
[dave@www.cndba.cn newora]# tar zxvf db_1.tar.gz

--删除旧的tar包
[dave@www.cndba.cn newora]# ll
total 2341924
drwxr-xr-x 74 ora11g oinstall       4096 Jul 20 19:08 db_1
-rw-r--r--  1 root   root     2398119191 Jul 22 01:01 db_1.tar.gz
[dave@www.cndba.cn newora]# rm -rf db_1.tar.gz 
[dave@www.cndba.cn newora]# ll
total 4
drwxr-xr-x 74 ora11g oinstall 4096 Jul 20 19:08 db_1

--修改目录权限:
[dave@www.cndba.cn newora]# chown -R newora:newoinstall db_1 
[dave@www.cndba.cn newora]# ll
total 4
drwxr-xr-x 74 newora newoinstall 4096 Jul 20 19:08 db_1

这里顺便把用户的参数文件也copy一份,注意修改对应的目录:

[dave@www.cndba.cn newora]# cp /home/ora11g/.bash_profile /home/newora/
cp: overwrite `/home/newora/.bash_profile'? y

[newora@www.cndba.cn ~]$ vi ~/.bash_profile 
[newora@www.cndba.cn ~]$ source ~/.bash_profile

5. 修改ORACLE_HOME中用户组的配置

因为我们source 和 target 对应的用户组不一样,所以我们这里需要修改,如果是一样的,可以跳过这一步。

修改之后如下:

[newora@www.cndba.cn ~]$ cat $ORACLE_HOME/rdbms/lib/config.c

/*  SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

/* IMPORTANT: this file needs to be in sync with
              rdbms/src/server/osds/config.c, specifically regarding the
              number of elements in the ss_dba_grp array.
 */

#define SS_DBA_GRP "newdba"
#define SS_OPER_GRP "newoper"
#define SS_ASM_GRP ""

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};   
[newora@www.cndba.cn ~]$

--修改$ORACLE_HOME 下的oraInst.loc 文件,填入正确的oraInventory 目录,这个oraInventory 可以不建,但是父目录必须存在,并且Oracle用户可以写入(建目录):

[ora11g@www.cndba.cn db_1]$ cat oraInst.loc 
inventory_loc=/home/newora/oraInventory
inst_group=newoinstall

还有/etc/oraInst.loc 文件:
[dave@www.cndba.cn newora]# cat /etc/oraInst.loc
inventory_loc=/home/newora/oraInventory
inst_group=newoinstall
[dave@www.cndba.cn newora]

重新relink all:
[newora@www.cndba.cn ~]$ relink all
writing relink log to: /home/newora/db_1/install/relink.log

6. Target上执行Clone 命令

修改 $ORACLE_HOME/clone/config/cs.properties 在最后加上参数-invPtrLoc 指明 oraInst.loc 所在的路径:

[dave@www.cndba.cn db_1]$ cd /home/dave/oracle/11.2.0/db_1/clone/config/
[dave@www.cndba.cn config]$ vim cs.properties 
[dave@www.cndba.cn config]$ cat cs.properties 
# Copyright (c) 2005, Oracle. All rights reserved.  

# clone command line
#clone_command_line= -silent -noConfig -nowait
clone_command_line= -silent -noConfig -nowait -invPtrLoc "/home/dave/oracle/11.2.0/db_1/oraInst.loc"
[dave@www.cndba.cn config]$

再去到 $ORACLE_HOME/clone/bin 目录执行一下一个perl脚本:http://www.cndba.cn/dave/article/3077

[dave@www.cndba.cn bin]$ pwd
/home/dave/oracle/11.2.0/db_1/clone/bin
[dave@www.cndba.cn bin]$ ls
clone.pl  prepare_clone.pl
[dave@www.cndba.cn bin]$ perl clone.pl ORACLE_HOME=$ORACLE_HOME ORACLE_BASE=$ORACLE_BASE
--要确保环境变量的准确性。
./runInstaller -clone -waitForCompletion  "ORACLE_HOME=/home/dave/oracle/11.2.0/db_1" "ORACLE_BASE=/home/dave/oracle" -defaultHomeName -silent -noConfig -nowait -invPtrLoc "/home/dave/oracle/11.2.0/db_1/oraInst.loc" 
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 3670 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-07-29_01-24-57PM. Please wait ...Oracle Universal Installer, Version 11.2.0.4.0 Production
Copyright (C) 1999, 2013, Oracle. All rights reserved.

You can find the log of this install session at:
 /home/dave/oraInventory/logs/cloneActions2014-07-29_01-24-57PM.log
.................................................................................................... 100% Done.



Installation in progress (Tuesday, July 29, 2014 1:25:10 PM CST)
..............................................................................                                                  78% Done.
Install successful

Linking in progress (Tuesday, July 29, 2014 1:25:16 PM CST)
Link successful

Setup in progress (Tuesday, July 29, 2014 1:26:20 PM CST)
Setup successful

End of install phases.(Tuesday, July 29, 2014 1:26:46 PM CST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
/home/dave/oracle/11.2.0/db_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts

The cloning of OraHome1 was successful.
Please check '/home/dave/oraInventory/logs/cloneActions2014-07-29_01-24-57PM.log' for more details.
[dave@www.cndba.cn bin]$

[root@www.cndba.cn lib]# /home/dave/oracle/11.2.0/db_1/root.sh
Check /home/dave/oracle/11.2.0/db_1/install/root_rac2_2014-07-29_13-28-47.log for the output of root script
[root@www.cndba.cn lib]#

或者手工执行:

http://www.cndba.cn/dave/article/3077
http://www.cndba.cn/dave/article/3077

./clone.pl /
ORACLE_HOME="/u01/app/ora11g/product/11.2.0.2/db_1" /
ORACLE_BASE="/u01/app/ora11g" /
OSDBA_GROUP="oradba" /
OSOPER_GROUP="oradba" /
OSASM_GROUP="oradba" /
ORACLE_HOME_NAME="OracleHome1"

7. 扫尾

创建监听,创建实例等等.http://www.cndba.cn/dave/article/3077

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2235
    原创
  • 2
    翻译
  • 535
    转载
  • 185
    评论
  • 访问:6528344次
  • 积分:4223
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ