Sunday, June 22, 2014

Shell Setting Notes

Turn on or off color syntax highlighting in vi or vim To turn on syntax highlighting in vi or vim, enter command below
:syntax on
To turn of color syntax highlighing , enter command below in vi or vum
:syntax off
You can edit ~/.vimrc file and add command syntax on to it so that next you will start vim with color syntax highlighting option
$ cd
$ vi .vimrc
Append the following line:
syntax on

Friday, February 28, 2014

SLES 11 Unlock An Account

To unlock an account in SLES 11 SP3
$ pam_tally2 --user=accountname --reset=0
$ faillog -u root -reset

Thursday, February 13, 2014

Loại bỏ dấu tiếng Việt trong Oracle PL/SQL

CREATE OR REPLACE FUNCTION CONVERTTOUNSIGN(p_string VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN TRANSLATE(p_string, 'ăâđêôơưàảãạáằẳẵặắầẩẫậấèẻẽẹéềểễệếìỉĩịíòỏõọóồổỗộốờởỡợớùủũụúừửữựứỳỷỹỵýĂÂĐÊÔƠƯÀẢÃẠÁẰẲẴẶẮẦẨẪẬẤÈẺẼẸÉỀỂỄỆẾÌỈĨỊÍÒỎÕỌÓỒỔỖỘỐỜỞỠỢỚÙỦŨỤÚỪỬỮỰỨỲỶỸỴÝ', 'aadeoouaaaaaaaaaaaaaaaeeeeeeeeeeiiiiiooooooooooooooouuuuuuuuuuyyyyyAADEOOUAAAAAAAAAAAAAAAEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOUUUUUUUUUUYYYYYDD'); END CONVERTTOUNSIGN;

Sunday, April 14, 2013

DBMS_REPAIR SCRIPT - ORA-26040: Data block was loaded using the NOLOGGING option

Applies to:
Oracle Server - Enterprise Edition - Version 8.1.5.0 to 11.2.0.3 [Release 8.1.5 to 11.2]
Purpose
This script is intended to provide a simple and quick way to run DBMS_REPAIR to identify and skip corrupted blocks
Script
REM Create the repair table in a given tablespace:

BEGIN
  DBMS_REPAIR.ADMIN_TABLES (
  TABLE_NAME => 'REPAIR_TABLE',
  TABLE_TYPE => dbms_repair.repair_table,
  ACTION => dbms_repair.create_action,
  TABLESPACE => '&tablespace_name');
END;
/ 

REM Identify corrupted blocks for schema.object:

set serveroutput on
DECLARE num_corrupt INT;
BEGIN
  num_corrupt := 0;
  DBMS_REPAIR.CHECK_OBJECT (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME => '&object_name',
  REPAIR_TABLE_NAME => 'REPAIR_TABLE',
  corrupt_count => num_corrupt);
  DBMS_OUTPUT.PUT_LINE('number corrupt: ' || TO_CHAR (num_corrupt));
END;
/

REM Optionally display any corrupted block identified by check_object:

select BLOCK_ID, CORRUPT_TYPE, CORRUPT_DESCRIPTION 
from REPAIR_TABLE;

REM Mark the identified blocks as corrupted

DECLARE num_fix INT;
BEGIN
  num_fix := 0;
  DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME=> '&object_name',
  OBJECT_TYPE => dbms_repair.table_object,
  REPAIR_TABLE_NAME => 'REPAIR_TABLE',
  FIX_COUNT=> num_fix);
  DBMS_OUTPUT.PUT_LINE('num fix: ' || to_char(num_fix));
END;
/

REM Allow future DML statements to skip the corrupted blocks:

BEGIN
  DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME => '&object_name',
  OBJECT_TYPE => dbms_repair.table_object,
  FLAGS => dbms_repair.SKIP_FLAG);
END;
/

Notes:

  • Recreate indexes after using DBMS_REPAIR as INDEX scan may produce errors if accessing the corrupt block. If there is an unique index, then reinserting the same data may also produce error ORA-1.
  • Use the dbms_repair.NOSKIP_FLAG in the FLAGS value in procedure SKIP_CORRUPT_BLOCKS if it is needed to stop skipping corrupt blocks in the object after the dbms_repair.SKIP_FLAG was used. 
  • If the goal is to skip the corrupt blocks for a specific object, it is just needed to run procedure SKIP_CORRUPT_BLOCKS. Only blocks producing ORA-1578 will be skipped in that case. If different errors are produced then it is required to run these additional procedures: ADMIN_TABLES, CHECK_OBJECT and FIX_CORRUPT_BLOCKS 
  • If it is needed to clear a table from corruptions and after using procedure SKIP_CORRUPT_BLOCKS, the table can be moved with: "alter table MOVE" instead of recreating or truncating it. Then use the dbms_repair.NOSKIP_FLAG described above. Note that the data inside the corrupt blocks is lost.
Reference: 
DBMS_REPAIR SCRIPT [ID 556733.1]

Monday, April 1, 2013

How to edit template's blogger



...insert code here...
...insert code here...
Reference: http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration

How to use encrypted password in JBoss EAP 6 datasource


In order to use encrypted password in EAP 6 datasource follow the bellow mentioned steps:
Step-1). Encrypt the database password by running the following script:
JBOSS_HOME=/apps/jboss-jpp-6.0
echo "Please enter the password to be encrypted"
read password
java -cp $JBOSS_HOME/modules/org/picketbox/main/picketbox-4.0.14.Final-redhat-3.jar:$JBOSS_HOME/modules/org/picketbox/main/picketbox-commons-1.0.0.final-redhat-2.jar:$JBOSS_HOME/modules/org/picketbox/main/picketbox-infinispan-4.0.14.Final-redhat-2.jar:$JBOSS_HOME/modules/org/jboss/logging/main/jboss-logging-3.1.2.GA-redhat-1.jar org.picketbox.datasource.security.SecureIdentityLoginModule $password
Step-2). In your JBoss configuration file like "standalone.xml", "standalone-full.xml", "domain.xml"...etc in the [subsystem xmlns="urn:jboss:domain:security:1.2"] subsystem create a by specifying the encrypted database password as following:

 
  
    
    
    
  
 

Step-3). Create a DataSource like following by specifying the rather than passing the cleartext username & password:

  jdbc:mysql://localhost:3306/testDB
  com.mysql.jdbc.Driver
  mysql-connector-java-5.1.13-bin.jar
  
   encryptedSecurityDomain
  

Step-4). Restart your JBoss EAP6 and then with the help of CLI utility you can test your DataSource as following:
In Standalone mode:
[standalone@localhost:9999 /] /subsystem=datasources/data-source=MySqlDS_Pool:test-connection-in-pool { "outcome" => "success", "result" => [true] } Reference : https://access.redhat.com/knowledge/solutions/184963


Wednesday, March 27, 2013

How to Change DBSNMP Password in Database 10g and 11g Monitored by DB Control

To change the password of the user DBSNMP you must strictly follow the steps below, otherwise the 10g or 11g DB Control used to manage your database will not function properly.

1. Stop the standalone dbconsole
On Unix - DB Control Release up to 11.1.x
$ export ORACLE_SID=
$ emctl stop dbconsole

On Unix - DB Control Release 11.2.x and higher
$ export ORACLE_SID=
$ export ORACLE_UNQNAME=

$ emctl stop dbconsole
On Windows - DB Control Release up to 11.1.x
Stop the Windows Service OracleDBConsole orOpen a DOS Command Window and type
C:> set ORACLE_SID=
C:> set ORACLE_HOME=

C:> cd %ORACLE_HOME%/bin
C:> emctl stop dbconsole
On Windows - DB Control Release 11.2.x and higher
Stop the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> set ORACLE_SID=
C:> set ORACLE_UNQNAME=

C:> set ORACLE_HOME=

C:> cd %ORACLE_HOME%/bin
C:> emctl stop dbconsole

Check that the DB Control is stopped
On Unix
$ emctl status dbconsole
On Windows
Check the status of the Windows Service OracleDBConsole or Open a DOS Command Window, cd to the database $ORACLE_HOME\bin and type
emctl status dbconsole 

Connect to the database as a user with DBA privilege with SQL*Plus and execute
alter user dbsnmp identified by ;
Check the new password
SQL> connect dbsnmp/[@database_alias]
Go to $ORACLE_HOME/host_sid/sysman/emd, Save the file targets.xml to targets.xml.orig, Edit the file targets.xml with your favorite text editor
Search for the line: encrypted_string
>" encrypted="TRUE">
       Replace the encrypted value by the new password value
       Replace TRUE by FALSE

Restart the standalone dbconsole
On Unix - DB Control Release up to 11.1.x
$ export ORACLE_SID=
$ emctl start dbconsole
On Unix - DB Control Release 11.2.x and higher
$ export ORACLE_SID=
$ export ORACLE_UNQNAME=
$ emctl start dbconsole

On Windows - DB Control Release up to 11.1.x
Start the Windows Service OracleDBConsole
Or
Open a DOS Command Window and type
set ORACLE_SID=
set ORACLE_HOME=
cd %ORACLE_HOME%/bin
emctl start dbconsole 

On Windows - DB Control Release 11.2.x and higher
Start the Windows Service OracleDBConsole
Or
Open a DOS Command Window and type
set ORACLE_SID=
set ORACLE_UNQNAME=
set ORACLE_HOME=
cd %ORACLE_HOME%/bin
emctl start dbconsole 

Check that the password has been encrypted
Edit the file targets.xml
Search for the line: 
Check that the password VALUE is encrypted
Check that the value of ENCRYPTED is TRUE

Note: In case of RAC DB, the dbsnmp password should be changed in targets.xml not only for instances(oracle_database), but also for rac_database target. The file targets.xml needs to be updated on all the RAC Cluster nodes.
References