Monday, March 17, 2014

Oracle: Database Migration with Datafile location changed

1. Copy all the data files, control files to new server.
2. Modify init ora file accordingly
3. Start up the instance, and you will get some errors because data file location changed.
4. Run below command to extract all data files list.
$ SQLPLUS/NOLOG 
SQL> CONNECT / AS SYSDBA 
SQL> spool dfiles.lst
SQL> SELECT * from V$DBFILE; 
SQL> spool off 
SQL> SELECT * from V$LOGFILE; 
SQL> SHUTDOWN 
SQL> EXIT 
 
5.  create config.sql as below

STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "<ORACLE_SID>" RESETLOGS
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 200
    MAXINSTANCES 8
    MAXLOGHISTORY 1168
LOGFILE
  GROUP 1 '/data1/<ORACLE_SID>/redo01.log'  SIZE 100M,
  GROUP 2 '/data2/<ORACLE_SID>/redo02.log'  SIZE 100M,
  GROUP 3 '/data3/<ORACLE_SID>/redo03.log'  SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/data2/<ORACLE_SID>/system01.dbf',
'/data4/<ORACLE_SID>/undotbs01.dbf',
'/data1/<ORACLE_SID>/sysaux01.dbf',
'/data5/<ORACLE_SID>/users01.dbf',
'/data1/<ORACLE_SID>/csisdata01.dbf',
'/data2/<ORACLE_SID>/csisdata02.dbf',
'/data3/<ORACLE_SID>/csisdata03.dbf',
'/data4/<ORACLE_SID>/csisdata04.dbf',
'/data5/<ORACLE_SID>/csisdata05.dbf',
'/data6/<ORACLE_SID>/csisdata06.dbf',
'/data7/<ORACLE_SID>/csisdata07.dbf',
'/data8/<ORACLE_SID>/csisdata08.dbf',
'/data1/<ORACLE_SID>/csisindex01.dbf',
'/data2/<ORACLE_SID>/csisindex02.dbf',
'/data3/<ORACLE_SID>/csisindex03.dbf',
'/data4/<ORACLE_SID>/csisindex04.dbf',
'/data5/<ORACLE_SID>/csisindex05.dbf',
'/data8/<ORACLE_SID>/tfdindex08.dbf',
'/data6/<ORACLE_SID>/user02.dbf'
CHARACTER SET WE8ISO8859P1
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/DBF/QA/ORA_LOGS/1_1_705162525.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
-- All logs need archiving and a log switch is needed.
-- --ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
-- --ALTER TABLESPACE TEMP ADD TEMPFILE '/data3/<ORACLE_SID>/temp01.dbf'
    -- -- SIZE 3000M REUSE AUTOEXTEND OFF;
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/data3/<ORACLE_SID>/temp01.dbf' SIZE 500M REUSE AUTOEXTEND OFF;
COMMIT;

6. Move all old control files out of its location.
7. Run below command to create new control files
$ SQLPLUS/NOLOG
SQL> CONNECT / AS SYSDBA 
SQL> spool newControls.log
SQL> @config.sql
SQL> spool off
SQL> shutdown immediate
SQL> startup
 
8. Verify the migration. 

Wednesday, March 12, 2014

Remove Comments and empty lines from SQL file

sed '/\/\*.*\*\// d; /\/\*/,/\*\// d; s/--.*$//; /^$/ d; $!N; s/\n/ /' sample.sql > /tmp/parsed.sql

Thursday, March 6, 2014

Compile rdp desktop on SUSE 11.2

Resource:
http://lists.opensuse.org/opensuse-security-announce/2010-04/msg00000.html

 Get RDP Desktop source code from http://www.rdesktop.org/
i.e.
# mkdir /var/tmp/rdp
# cd /var/tmp/rdp
# wget http://prdownloads.sourceforge.net/rdesktop/rdesktop-1.8.1.tar.gz?download
# tar -zxf  rdesktop-1.8.1.tar.gz
# cd  rdesktop-1.8.1
# ./configure --prefix=/opt/rdp-1.8.1 --disable-credssp --disable-smartcard
# make
# make install

“ERROR: Could not find X Window System headers/libraries
To specify paths manually, use the options –x-includes and –x-libraries”
FIX: add the X-windows development tools though YaST to compile successfully – x-org-x11-devel
ERROR: Could not find OpenSSL headers/libraries.
To specify a path manually, use the –with-openssl option
FIX: add the OpenSSL development tools through YaST to compile successfully – openssl-devel
# cd /opt/rdp-1.8.1/bin
# ./rdesktop -x l -g 90% rdpserver

on Windows 2k8 server

from a Run box, type "mmc" to open the Microsoft Management Console. Click File -> Add/Remove Snap-in. Click the "Add..." button, choose "Group Policy Object Editor" from the list and click "Add" (you may have to push "Finish") then "Close" then "OK".

Now browse to Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Terminal Services. From the list, modify "Always show desktop on connection" to "Enabled" and "Enforce Removal of Remote Desktop Wallpaper" to "Disabled". Now close the MMC clicking "No" about saving the settings.