千家信息网

oracle的克隆

发表于:2024-11-26 作者:千家信息网编辑
千家信息网最后更新 2024年11月26日,oracle on linux安装多台服务器时可以采用一次安装副本多台克隆即可,简单快速.*******************************************************
千家信息网最后更新 2024年11月26日oracle的克隆
  1. oracle on linux安装多台服务器时可以采用一次安装副本多台克隆即可,简单快速.
  2. **************************************************************
  3. 1、检查下列包是否安装
  4. **************************************************************
  5. yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 compat-libcap1 \
  6. elfutils-libelf elfutils-libelf-devel glibc glibc-devel glibc-common \
  7. libaio libaio-devel libgcc libstdc++ libstdc++-devel sysstat expat \
  8. ksh unixODBC unixODBC-devel
  9. --配置系统
  10. # grep MemTotal /proc/meminfo
  11. MemTotal: 4946772 kB
  12. # grep SwapTotal /proc/meminfo
  13. SwapTotal: 12289716 kB
  14. # df -h
  15. Filesystem Size Used Avail Use% Mounted on
  16. /dev/sda2 17G 2.8G 14G 18% /
  17. /dev/sda1 1012M 40M 921M 5% /boot
  18. none 891M 0 891M 0% /dev/shm
  19. /dev/hdc 192M 192M 0 100% /media/cdrom
  20. **************************************************************
  21. 2.参数修改
  22. **************************************************************
  23. 1.设置需要的IP
  24. 2、修改host文件
  25. 在/etc/hosts文件中添加一个全限定域名,如:
  26. vi /etc/hosts
  27. 192.168.50.180 vp01 vp01.vpay.com
  28. 192.168.50.190 vp02 vp02.vpay.com
  29. 3. 查看修改结果
  30. hostname
  31. cat /etc/hosts | grep `eval hostname`
  32. 4、设置核心参数
  33.  1、在/etc/sysctl.conf文件中加入下列行:
  34. #vi /etc/sysctl.conf
  35. fs.suid_dumpable = 1
  36. fs.aio-max-nr = 1048576
  37. fs.file-max = 6815744
  38. kernel.shmmni = 4096
  39. # semaphores: semmsl, semmns, semopm, semmni
  40. kernel.sem = 250 32000 100 128
  41. net.ipv4.ip_local_port_range = 9000 65500
  42. net.core.rmem_default=4194304
  43. net.core.rmem_max=4194304
  44. net.core.wmem_default=262144
  45. net.core.wmem_max=1048586
  46.  5、运行下列命令改变核心参数:
  47. #/sbin/sysctl -p
  48.  6、在/etc/security/limits.conf文件中加入下列行:
  49. # vi /etc/security/limits.conf
  50. oracle soft nproc 2047
  51. oracle hard nproc 16384
  52. oracle soft nofile 1024
  53. oracle hard nofile 65536
  54. oracle hard stack 10240
  55. 7、在/etc/pam.d/login文件中加入下列行:
  56. # vi +13 /etc/pam.d/login
  57. session required pam_limits.so
  58. **************************************************************
  59. 3.创建下列组和用户
  60. **************************************************************
  61. groupadd oinstall
  62. groupadd dba
  63. groupadd oper
  64. useradd -g oinstall -G dba,oper -d /home/oracle -m oracle
  65. passwd oracle
  66. 123
  67. **************************************************************
  68. 4.设置oracle用户的环境变量
  69. **************************************************************
  70. 用oracle登录在:/home/oracle/.bash_profile文件末尾,注意把其中ORACLE_SID换成自己的实例名:
  71. # vi /home/oracle/.bash_profile
  72. 也可以
  73. #su - oracle
  74. #vi .bash_profile
  75. 增加下列内容:
  76. # Oracle Settings
  77. TMP=/tmp;
  78. export TMP
  79. TMPDIR=$TMP;
  80. export TMPDIR
  81. ORACLE_BASE=/u01/app/oracle;
  82. export ORACLE_BASE
  83. ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;
  84. export ORACLE_HOME
  85. ORACLE_SID=jinri;
  86. export ORACLE_SID
  87. ORACLE_TERM=xterm;
  88. export ORACLE_TERM
  89. PATH=/usr/sbin:$PATH;
  90. export PATH
  91. PATH=$ORACLE_HOME/bin:$PATH;
  92. export PATH
  93. LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
  94. export LD_LIBRARY_PATH
  95. CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
  96. export CLASSPATH
  97. #LD_ASSUME_KERNEL=2.4.1;
  98. export LD_ASSUME_KERNEL
  99. #set language
  100. NLS_LANG="SIMPLIFIED CHINESE"_CHINA.AL32UTF8
  101. export NLS_LANG
  102. EDITOR=vi
  103. export EDITOR
  104. if [ $USER = "oracle" ]; then
  105. if [ $SHELL = "/bin/ksh" ]; then
  106. ulimit -p 16384
  107. ulimit -n 65536
  108. else
  109. ulimit -u 16384 -n 65536
  110. fi
  111. fi
  112. alias oratrace="cat $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_jinri.log"
  113. alias oradata="cd $ORACLE_BASE/oradata/$ORACLE_SID"
  114. alias oranetwork="cd $ORACLE_HOME/network/admin"
  115. alias topc='ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head'
  116. alias topm='ps -e -o pmem,pid,user,tty,args | sort -n -k 1 -r | head'
  117. ----新建必要的数据目录
  118. #mkdir /u01/backup/ && chown -R oracle.oinstall /u01/backup/
  119. # mkdir /data/ctl
  120. # chown -R oracle.oinstall /data/ctl/
  121. **************************************************************
  122. 5.副本克隆安装数据库
  123. **************************************************************
  124. --1.vp01正常关闭数据库
  125. [oracle@vp01 20760982]$ sqlplus / as sysdba
  126. SQL*Plus: Release 11.2.0.4.0 Production on 星期一 9月 28 18:27:13 2015
  127. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  128. 连接到:
  129. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  130. With the Partitioning, OLAP, Data Mining and Real Application Testing options
  131. SQL> shutdown immediate
  132. 数据库已经关闭。
  133. 已经卸载数据库。
  134. ORACLE 例程已经关闭。
  135. SQL> exit
  136. [oracle@vp01 20760982]$ lsnrctl stop
  137. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-9月 -2015 18:27:39
  138. Copyright (c) 1991, 2013, Oracle. All rights reserved.
  139. 正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  140. 命令执行成功
  141. ---2.vp01打包
  142. $cd /u01/
  143. $tar czvf oracle.tar.gz /u01/
  144. ---3.vp01将oracle安装副本压缩包传递到vp02
  145. scp -r -p -P 16335 /u01/oracle.tar.gz oracle@10.174.157.163:/u01/backup/
  146. ---4.vp02解压修改权限
  147. #chown -R oracle.oinstall /u01/backup/oracle.tar.gz
  148. #cd /u01/backup/
  149. # tar zxvf oracle.tar.gz -C /u01/
  150. --移动目录到上一层
  151. # cd /u01/u01/ && mv app/ ../ && ls /u01/u01/ && ls /u01/app/
  152. #rm -rf /u01/u01
  153. ---控制文件有个副本在不同目录
  154. #cp /u01/app/oracle/oradata/jinri/control01.ctl /data/ctl/control03.ctl
  155. #chown -R oracle.oinstall /u01/app/
  156. #chown -R oracle.oinstall /data/ctl/
  157. --relink
  158. $cd
  159. $relink all
  160. writing relink log to: /u01/app/oracle/product/11.2.0/dbhome_1/install/relink.log
  161. ----5.修改监听解析文件
  162. $ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  163. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  164. # Generated by Oracle configuration tools.
  165. SID_LIST_LISTENER =
  166. (SID_LIST =
  167. (SID_DESC =
  168. (GLOBAL_DBNAME = jinri)
  169. (SID_NAME = jinri)
  170. )
  171. )
  172. LISTENER =
  173. (DESCRIPTION_LIST =
  174. (DESCRIPTION =
  175. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.174.157.163)(PORT = 1521))
  176. )
  177. )
  178. ADR_BASE_LISTENER = /u01/app/oracle
  179. [oracle@vp02 ~]$
  180. #将vp01修改为vp02对应IP
  181. $ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  182. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  183. # Generated by Oracle configuration tools.
  184. JINRI =
  185. (DESCRIPTION =
  186. (ADDRESS = (PROTOCOL = TCP)(HOST = vp02)(PORT = 1521))
  187. (CONNECT_DATA =
  188. (SERVER = DEDICATED)
  189. (SERVICE_NAME = jinri)
  190. )
  191. )
  192. -----6.附加oracle主目录
  193. cd $ORACLE_HOME/oui/bin
  194. $ $ORACLE_HOME/oui/bin/runInstaller -silent -attachHome -invPrtLoc /u01/app/oraInventory/oraInst.loc \
  195. ORACLE_HOME_NAME="OraDb11g_home1" \
  196. ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
  197. Starting Oracle Universal Installer...
  198. Checking swap space: must be greater than 500 MB. Actual 4999 MB Passed
  199. The inventory pointer is located at /etc/oraInst.loc
  200. The inventory is located at /u01/app/oraInventory
  201. Please execute the '/u01/app/oraInventory/orainstRoot.sh' script at the end of the session.
  202. 'AttachHome' was successful.
  203. #/u01/app/oraInventory/orainstRoot.sh
  204. --注册前
  205. $ cat /u01/app/oraInventory/ContentsXML/inventory.xml
  206. "1.0" standalone="yes" ?>
  207. -- Copyright (c) 1999, 2013, Oracle and/or its affiliates.
  208. All rights reserved. -->
  209. -- Do not modify the contents of this file by hand. -->
  210. 11.2.0.4.0
  211. 2.1.0.6.0
  212. --注册前
  213. $ cat /u01/app/oraInventory/ContentsXML/inventory.xml
  214. "1.0" standalone="yes" ?>
  215. -- Copyright (c) 1999, 2013, Oracle and/or its affiliates.
  216. All rights reserved. -->
  217. -- Do not modify the contents of this file by hand. -->
  218. 11.2.0.4.0
  219. 2.1.0.6.0
  220. NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="1"/>
  221. $ cat /etc/oraInst.loc
  222. inventory_loc=/u01/app/oraInventory
  223. inst_group=oinstall
  224. ----7.分离oracle主目录(需要的时候)
  225. $ORACLE_HOME/oui/bin/runInstaller -silent -detachHome -invPrtLoc /u01/app/oraInventory/oraInst.loc \
  226. ORACLE_HOME_NAME="OraDb11g_home1" \
  227. ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
  228. ----8.启动监听文件
  229. $ lsnrctl start
  230. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-9月 -2015 19:30:48
  231. Copyright (c) 1991, 2013, Oracle. All rights reserved.
  232. 启动/u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: 请稍候...
  233. TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  234. 系统参数文件为/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  235. 写入/u01/app/oracle/diag/tnslsnr/vp02/listener/alert/log.xml的日志信息
  236. 监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  237. 监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vp02)(PORT=1521)))
  238. 正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  239. LISTENER 的 STATUS
  240. ------------------------
  241. 别名 LISTENER
  242. 版本 TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  243. 启动日期 28-9月 -2015 19:30:48
  244. 正常运行时间 0 天 0 小时 0 分 2 秒
  245. 跟踪级别 off
  246. 安全性 ON: Local OS Authentication
  247. SNMP OFF
  248. 监听程序参数文件 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  249. 监听程序日志文件 /u01/app/oracle/diag/tnslsnr/vp02/listener/alert/log.xml
  250. 监听端点概要...
  251. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  252. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vp02)(PORT=1521)))
  253. 监听程序不支持服务
  254. 命令执行成功
  255. $ tnsping jinri
  256. TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 28-9月 -2015 19:31:11
  257. Copyright (c) 1997, 2013, Oracle. All rights reserved.
  258. 已使用的参数文件:
  259. /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
  260. 已使用 TNSNAMES 适配器来解析别名
  261. 尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = vp02)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = jinri)))
  262. OK (0 毫秒)
  263. $ sqlplus / as sysdba
  264. SQL*Plus: Release 11.2.0.4.0 Production on 星期一 9月 28 20:17:45 2015
  265. Copyright (c) 1982, 2013, Oracle. All rights reserved.
  266. 已连接到空闲例程。
  267. SQL> startup
  268. ORACLE 例程已经启动。
  269. Total System Global Area 3925032960 bytes
  270. Fixed Size 2259240 bytes
  271. Variable Size 822085336 bytes
  272. Database Buffers 3087007744 bytes
  273. Redo Buffers 13680640 bytes
  274. 数据库装载完毕。
  275. 数据库已经打开。
  276. SQL> select open_mode from v$database;
  277. OPEN_MODE
  278. --------------------
  279. READ WRITE
0