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

1. 背景说明

一般直接copy ORACLE_HOME时,都会选择相同的用户,路径和group,我们这里演示一个复杂一点的案例。https://www.cndba.cn/dave/article/3077

通过直接copy的方式安装Oracle,速度也会比我们通过GUI安装快很多。https://www.cndba.cn/dave/article/3077

Source 端已经安装好一个Oracle 11.2.0.4的数据库了,我们直接copy这个数据库。https://www.cndba.cn/dave/article/3077

2. Target 的准备工作

这里有很多,包括安装包,配置环境变量,修改参数,创建用户和组等信息。

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

Source:

[ora11g@www.cndba.cn bin]$ id ora11g

uid=502(ora11g) gid=501(oinstall) groups=501(oinstall),502(dba)

我们在Target 端建一个新用户: newora, 所有的组都加new* 前缀。https://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用户打不了。

[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命令。https://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一份,注意修改对应的目录:https://www.cndba.cn/dave/article/3077https://www.cndba.cn/dave/article/3077

[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 对应的用户组不一样,所以我们这里需要修改,如果是一样的,可以跳过这一步。

修改之后如下:

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

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

[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 所在的路径:https://www.cndba.cn/dave/article/3077

[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脚本:

[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]#

或者手工执行:

./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. 扫尾

创建监听,创建实例等等.

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值