Migrating RHN From Oracle XE To Oracle 11gR2 Database

I have been running redhat spacewalk server to manage packages to redhat linux systems.The initial backend database is oracle XE that the size of the database can grow to approach 4GB limit.So,i mirate it to oracle 11gR2 database.

Current Environment

1.RedHat Linux 6

2.Spacewalk verison:1.7

3.Spacewalk channel:3 base,4 child

4.Total packages:13,230

Prerequisites

1.For install and configure spacewalk with oracle XE from here.

2.Configure linux for installing oracle 11gR2 database.Run following script:

 
 
  1. #!/bin/bash 
  2. echo ------------------------------------------------- 
  3. echo "This script prepare for Oracle 11g database." 
  4. #add group 
  5. echo ------------------------------------------------- 
  6. echo "Now add asmadmin、dba、oper group." 
  7. for id in oinstall asmadmin dba oper;do groupadd $id;done 
  8. sleep 1 
  9. #add oracle user 
  10. echo ------------------------------------------------- 
  11. echo "Now create oracle user and set password for it." 
  12. echo "The Oracle's Default Password is "oracle"." 
  13. echo ------------------------------------------------- 
  14. useradd -g oinstall -G asmadmin,dba,oper -m -d /home/oracle -s /bin/bash oracle 
  15. echo oracle|passwd --stdin oracle 
  16. sleep 1 
  17.  
  18. echo ------------------------------------------------- 
  19. echo "Configure System Parameters For Oracle" 
  20. sleep 2 
  21. echo ------------------------------------------------- 
  22. echo "Edit the /etc/sysctl.conf file." 
  23. #define /etc/sysctl.conf 
  24. cat >>/etc/sysctl.conf<< EOF 
  25. kernel.shmmni = 4096 
  26. kernel.sem = 250 32000 100 128 
  27. net.ipv4.ip_local_port_range = 9000 65500 
  28. net.core.rmem_default=262144 
  29. net.core.rmem_max=8388608 
  30. net.core.wmem_default=262144 
  31. net.core.wmem_max=8388608 
  32. fs.aio-max-nr=1048576 
  33. fs.file-max = 6815744 
  34. net.ipv4.tcp_rmem=4096 262144 8388608 
  35. net.ipv4.tcp_wmem=4096 262144 8388608 
  36. EOF 
  37. sleep 1 
  38.  
  39. #define /etc/pam.d/login 
  40. echo ------------------------------------------------- 
  41. echo "Edit the /etc/pam.d/login file." 
  42. cat >>/etc/pam.d/login<<EOF 
  43. session    required     pam_limits.so 
  44. EOF 
  45. sleep 1 
  46.  
  47. #define /etc/security/limits.conf 
  48. echo ------------------------------------------------- 
  49. echo "Edit the /etc/security/limits.conf file." 
  50. cat >>/etc/security/limits.conf<<EOF 
  51. oracle soft nproc 2047 
  52. oracle hard nproc 16384 
  53. oracle soft nofile 1024 
  54. oracle hard nofile 65536 
  55. EOF 
  56. sleep 1 
  57.  
  58. #define /etc/profile 
  59. echo ------------------------------------------------- 
  60. echo "Edit the /etc/profile file." 
  61. cat >>/etc/profile<<EOF 
  62. if [ \$USER = "oracle" ] || [ \$USER = "grid" ]; then  
  63.     if [ \$SHELL = "/bin/ksh" ]; then 
  64.         ulimit -p 16384 
  65.         ulimit -n 65536 
  66.     else 
  67.         ulimit -u 16384 -n 65536 
  68.     fi 
  69.     umask 022 
  70. fi 
  71. EOF 
  72. sleep 1 
  73.  
  74. echo -------------------------------------------------- 
  75. echo "Set Oracle's Environment Variable." 
  76. #defile oracle user's profile 
  77. if [ -e /home/oracle/.bash_profile ]&&[ -e /home/oracle/.bashrc ];then 
  78. cat >>/home/oracle/.bash_profile<<EOF 
  79. export ORACLE_SID=example 
  80. export ORACLE_BASE=/u01/app/oracle 
  81. export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1 
  82. export NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS" 
  83. export TNS_ADMIN=\$ORACLE_HOME/network/admin 
  84. export ORA_NLS11=\$ORACLE_HOME/nls/data 
  85. export PATH=\$PATH:\$HOME/bin:\$ORACLE_HOME/bin:\$JAVA_HOME/bin 
  86. export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\${LD_LIBRARY_PATH}:\$ORACLE_HOME/oracm/lib:/lib:/usr/lib:/usr/local/lib 
  87. export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib:\$ORACLE_HOME/network/jlib 
  88. export THREADS_FLAG=native 
  89. umask 022 
  90. EOF 
  91. chown oracle:oinstall /home/oracle/.bash_profile 
  92. echo "alias df='df -h'">>/home/oracle/.bashrc 
  93. echo "alias du='du -sh'">>/home/oracle/.bashrc 
  94. echo "alias la='ls -lha'">>/home/oracle/.bashrc 
  95. echo ---------------------------------------------------- 
  96. echo "The Default ORACLE_SID is example." 
  97. fi 
  98. sleep 1 
  99.  
  100. #create /u01 
  101. echo ---------------------------------------------------- 
  102. echo "Now,Create ORACLE_HOME." 
  103.         if [ ! -e /u01 ];then 
  104.                 mkdir /u01 
  105.                 chown -R oracle:oinstall /u01 
  106.                 chmod 775 /u01 
  107.                 su - oracle -c "mkdir -p \$ORACLE_HOME" 
  108.         else 
  109.                 echo "The ORACLE_HOME exist." 
  110.         fi 
  111. sleep 1 
  112. #install packages 
  113. echo "**********************************************************************" 
  114. echo "Please Install Follow Packages:" 
  115. echo "binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel" 
  116. echo "elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common" 
  117. echo "glibc-devel glibc-headers ksh libaio libaio-devel libgcc" 
  118. echo "libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel" 
  119. echo "**********************************************************************" 
  120. echo "WARNING:After run this scripts,You Must Reboot Your Machine !!!" 

3.Installing oracle 11gR2 database (omitted).

4.Create the oracle 11gR2 start and stop scripts

 
 
  1. [root@server ~]#vi /etc/init.d/oracle 
  2. #!/bin/bash  
  3. # oracle   This shell script takes care of starting and stopping the oracle services.  
  4. # Init file for oracle daemon  
  5. #  
  6. # chkconfig: 2345 55 25  
  7. # description: oracle daemon  
  8. #  
  9. #oracle_home:/u01/app/oracle/product/11.2.0/db_1  
  10.   
  11. RETVAL=0  
  12.   
  13. # Source function library.  
  14. . /etc/rc.d/init.d/functions  
  15.   
  16.   
  17. # Source networking configuration.  
  18. [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network  
  19.   
  20. #define global envionment variables  
  21. #ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1  
  22.   
  23. #define the start function  
  24. start () {  
  25. #start LISTENER  
  26. if [ -x $ORACLE_HOME/bin/lsnrctl ]; then  
  27. su - oracle -c 'lsnrctl start' >/home/oracle/lsnrctl_start.log 2>&1  &  
  28. fi  
  29.   
  30. #start oracle instance  
  31. if [ -x $ORACLE_HOME/bin/sqlplus ]; then  
  32. su - oracle -c 'sqlplus'<<EOF  
  33. connect / as sysdba  
  34. startup  
  35. quit  
  36. EOF  
  37. fi  
  38.   
  39. #create pid file  
  40. sleep 20s  
  41. ps -ef|grep ora|grep inherit|awk '{print $2}'>$PID_DIR/lsnrctl.pid  
  42.   
  43. }  
  44.   
  45. #  
  46. #define the stop function  
  47. #  
  48.   
  49. stop () {  
  50.   
  51. #stop oracle instance  
  52. if [ -x $ORACLE_HOME/bin/sqlplus ]; then  
  53. su - oracle -c 'sqlplus'<<EOF  
  54. connect / as sysdba  
  55. shutdown immediate  
  56. quit  
  57. EOF  
  58. fi  
  59.   
  60. #stop LISTENER  
  61. if [ -x $ORACLE_HOME/bin/lsnrctl ]; then  
  62. su - oracle -c 'lsnrctl stop' >/home/oracle/lsnrctl_stop.log 2>&1  &  
  63. fi  
  64. #delete all log file on oracle home  
  65. su - oracle -c 'rm -rf /home/oracle/*.log'  
  66. #delete listener isqlplus pid file  
  67. rm -rf /var/run/lsnrctl.pid  
  68. }  
  69.   
  70.   
  71. #define status functions  
  72. status () {  
  73.     if [ -d /var/run ];then  
  74.        if [ -f $PID_DIR/lsnrctl.pid ];then  
  75.           LISNTER_PID=`cat $PID_DIR/lsnrctl.pid`  
  76.           echo The oracle listener is running and pid is $LISNTER_PID .....  
  77.        else  
  78.               echo The oracle listener is stopped  
  79.        fi  
  80.         fi  
  81.          
  82. }     
  83.   
  84. # See how we were called.  
  85. case "$1" in  
  86.   start)  
  87.         start  
  88.         ;;  
  89.   stop)  
  90.         stop  
  91.         ;;  
  92.   restart)  
  93.         stop  
  94.         start  
  95.         ;;  
  96.   status)  
  97.     status  
  98.     ;;  
  99.     *)  
  100.         echo $"Usage: $prog {start|stop|restart|status}"  
  101.         exit 1  
  102. esac  
  103.   
  104. exit $RETVAL 
  105.  
  106. [root@server ~]# chkconfig --add oracle 
  107. [root@server ~]# chkconfig --list oracle 
  108. oracle          0:off   1:off   2:off   3:off   4:off   5:off   6:off 
  109. [root@server ~]# chkconfig oracle on 
  110. [root@server ~]# chkconfig --list oracle 
  111. oracle          0:off   1:off   2:on    3:on    4:on    5:on    6:off 
  112. [root@server ~]# chkconfig --level 24 oracle off 
  113. [root@server ~]# chkconfig --list oracle 
  114. oracle          0:off   1:off   2:off   3:on    4:off   5:on    6:off 
  115. [root@server ~]#  
 

Create a Database Dump

1.Disable automatic start of  oracle XE  on system boot up

 
 
  1. [root@server ~]# chkconfig oracle-xe off 
  2. [root@server ~]# chkconfig --list oracle-xe 
  3. oracle-xe       0:off   1:off   2:off   3:off   4:off   5:off   6:off 
  4. [root@server ~]#  

2.Shutdown spacewalk services

 
 
  1. [root@server ~]# spacewalk-service stop 
  2. Shutting down spacewalk services... 
  3. Stopping RHN Taskomatic... 
  4. Stopped RHN Taskomatic. 
  5. Stopping cobbler daemon:                                   [  OK  ] 
  6. Stopping rhn-search... 
  7. Stopped rhn-search. 
  8. Stopping MonitoringScout ...   
  9.     Stopping InstallSoftwareConfig ...  [ OK ] 
  10. [ OK ] 
  11. Stopping Monitoring ...   
  12.     Stopping TSDBLocalQueue ...  [ OK ] 
  13.     Stopping AckProcessor ...  [ OK ] 
  14.     Stopping Notifier ...  [ OK ] 
  15.     Stopping NotifLauncher ...  [ OK ] 
  16.     Stopping GenerateNotifConfig ...  [ OK ] 
  17.     Stopping NotifEscalator ...  [ OK ] 
  18. [ OK ] 
  19. Stopping httpd:                                            [  OK  ] 
  20. Stopping tomcat6:                                          [  OK  ] 
  21. Shutting down osa-dispatcher:                              [FAILED] 
  22. Terminating jabberd processes ... 
  23. Stopping router:                                           [  OK  ] 
  24. Stopping sm:                                               [  OK  ] 
  25. Stopping c2s:                                              [FAILED] 
  26. Stopping s2s:                                              [  OK  ] 
  27. Done. 

3.start oracle XE

 
 
  1. [root@server ~]#/etc/init.d/oracle-xe start 
  2. Starting Oracle Net Listener. 
  3. Starting Oracle Database 10g Express Edition Instance. 

4.Backup the XE database:

 
 
  1. [oracle@server scripts]$ pwd 
  2. /u01/app/oracle/product/11.2.0/xe/config/scripts 
  3. [oracle@server scripts]$ ./backup.sh 
  4. ....... 
  5. Backup of the database succeeded. 
  6. Log file is at /usr/lib/oracle/xe/oxe_backup_current.log. 

5.Create a dump of the XE database for importation into Oracle 11r2 database

 
 
  1. [oracle@server ~]$ . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh 
  2. [oracle@server ~]$ exp spacewalk/oracle owner=spacewalk consistent=y statistics=none file=spacewalk.oracleXE.dmp log=spacewalk.oracleXE.log 
  3.  
  4. Export: Release 11.2.0.3.0 - Production on Mon Aug 6 18:09:56 2012 
  5.  
  6. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  7.  
  8. Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production 
  9. Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set 
  10.  
  11. ... 
  12.  
  13. . exporting dimensions 
  14. . exporting post-schema procedural objects and actions 
  15. . exporting statistics 
  16. Export terminated successfully without warnings. 

Configure oracle 11gR2 database

1.Create a spacewalk tablespace on oracle 11gr2 databse

 
 
  1. [oracle@server ~]$ echo $ORACLE_SID 
  2. spwdb 
  3. [oracle@server ~]$ echo $ORACLE_HOME 
  4. /u01/app/oracle/product/11.2.0/db_1 
  5. [oracle@server ~]$ sqlplus "/as sysdba" 
  6. SQL*Plus: Release 11.2.0.3.0 Production on Tue Aug 6 18:43:56 2012 
  7.  
  8. Copyright (c) 1982, 2011, Oracle.  All rights reserved. 
  9.  
  10. Connected to: 
  11. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  12. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  13.  
  14. SQL> create tablespace spacewalk datafile '/u01/oradata/spwdb/spw01.dbf' size 10G autoextend on next 1G; 
  15. SQL>create user spacewalk identified by oracle default tablespace spacewalk; 
  16. SQL>grant dba to spacewalk; 

2.Import the oracle XE dumped database

 
 
  1. [oracle@server ~]$imp spacewalk/oracle@spwdb fromuser=spacewalk touser=spacewalk file=spacewalk.oracleXE.dmp ignore=y 
  2. ................. 
  3.  
  4. import done in AL32UTF8 character set and AL16UTF16 NCHAR character set 
  5. . importing SPACEWALK's objects into SPACEWALK 
  6. . . importing table                     "DEMO_LOG"          0 rows imported 
  7. . . importing table            "HTMLDB_PLAN_TABLE"          2 rows imported 
  8. . . importing table                  "PXTSESSIONS"          0 rows imported 
  9. . . importing table                    "RHNACTION"        140 rows imported 
  10.  
  11. ... 
  12.  
  13. . importing SPACEWALK's objects into SPACEWALK 
  14. About to enable constraints... 
  15. Import terminated successfully with warnings. 

3.Remove execute permissions from the oracle-xe:

 
 
  1. [root@server ~]#chkconfig oracle-xe off 
  2. [root@server ~]#chmod -x /etc/init.d/oracle-xe 

4.Edit the /etc/rhn/rhn.conf file and replace any occurrence of 'xe' with 'spwdb'

 
 
  1. [root@server ~]# grep -n spwdb /etc/rhn/rhn.conf 
  2. 32:db_name = //localhost/spwdb 

5.Edit the /etc/rhn/cluster.ini and replace 'xe' with 'spwdb'

 
 
  1. [root@server ~]# grep -n spwdb /etc/rhn/cluster.ini 
  2. 2:LocalConfig.0.dbname=//LOCALHOST/spwdb 

6.Start the spacewalk services:

 
 
  1. [root@server rhn]# spacewalk-service start 
  2. Starting spacewalk services... 
  3. Initializing jabberd processes ... 
  4. Starting router:                                           [  OK  ] 
  5. Starting sm:                                               [  OK  ] 
  6. Starting c2s:                                              [  OK  ] 
  7. Starting s2s:                                              [  OK  ] 
  8. Starting osa-dispatcher:                                   [  OK  ] 
  9. Starting tomcat6:                                          [  OK  ] 
  10. Waiting for tomcat to be ready ... 
  11. Starting httpd:                                            [  OK  ] 
  12. Starting Monitoring ...   
  13.     Starting InstallSoftwareConfig ...  [ OK ] 
  14.     Starting NotifEscalator ...  [ OK ] 
  15.     Starting GenerateNotifConfig ...  [ OK ] 
  16.     Starting NotifLauncher ...  [ OK ] 
  17.     Starting Notifier ...  [ OK ] 
  18.     Starting AckProcessor ...  [ OK ] 
  19.     Starting TSDBLocalQueue ...  [ OK ] 
  20. [ OK ] 
  21. Starting MonitoringScout ...   
  22. [ OK ] 
  23. Starting rhn-search... 
  24. Starting cobbler daemon:                                   [  OK  ] 
  25. Starting RHN Taskomatic... 
  26. Done. 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值