lunes, 2 de septiembre de 2013

VMWare migrating vm the method is disabled by vm-xxxx


This error appears migrating virtual machine, storage vmotion fails with the error: vmware migrating vm the method is disabled by vm-xxxx, remove from inventory and delete from disk options are grayed out.

This issue occurs because the entries from VPX_DISABLED_METHODS table are not removed after a VM backup.
When a VM backup begins the backup engine informs vcenter to disable Storage vmotion for that VM, ensuring that backup can complete succesfully.

Resolution:

- Schedule another backup of virtual machine, once backup is completed succesfully, entry on VPX_DISABLED_METHODS is automatically removed.

If the preceding resolution doesn't work:

- Remove an re-add the VM from the inventory

Backup your vcenter database first!!!

1.- Poweroff VM
2.- in vSphere Client right-click the VM and click Remove from inventory
3.- Browse the datastore where the VM resides.
4.- Right-click the .vmx file of the VM and click Add to inventory
5.- Poweron the VM and retry de Storage vMotion.

viernes, 2 de agosto de 2013

Oracle 11 - RMAN Creating scripts inside catalog

A few examples creating, deleting and listing scripts stored inside an RMAN catalog.

Creating RMAN scripts inside rman catalog. 

GLOBAL scripts are available for all database instances connected to rman catalog.

RMAN> create global script
2> global_backup_db {backup database plus archivelog;}

created global script blobal_backup_db

Running previous script.

RMAN> run {execute global script global_backup_db;}

executing global script: global_backup_db


Starting backup at 30-JUL-2013 23:03:28
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 instance=RACDB1 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=2 sequence=11 RECID=1 STAMP=821038151
input archived log thread=1 sequence=83 RECID=2 STAMP=821038215
input archived log thread=1 sequence=84 RECID=3 STAMP=821043970
.
.
.
channel ORA_DISK_1: finished piece 1 at 30-JUL-2013 23:30:44
piece handle=+FRA/racdb/backupset/2013_07_30/annnf0_tag20130730t233041_0.300.822180641 tag=TAG20130730T233041 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-JUL-2013 23:30:44

Creating global script including tablespace variable

RMAN> create global script backup_ts
2> { backup tablespace &1; }

Enter value for 1: users

created global script backup_ts

Running global script with variable backup_ts

RMAN> run {execute global script backup_ts;}

executing global script: backup_ts

Enter value for 1: system

Starting backup at 30-JUL-2013 23:43:39
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/racdb/datafile/system.259.820185587
channel ORA_DISK_1: starting piece 1 at 30-JUL-2013 23:43:43

Listing scripts stored inside catalog. 

RMAN> list script names;

List of Stored Scripts in Recovery Catalog


    Global Scripts


       Script Name
       Description
       -----------------------------------------------------------------------
       backup_ts

       global_backup_db


Listing description

RMAN> print global script global_backup_db;

printing stored global script: global_backup_db
{backup database plus archivelog;}

Deleting script from catalog.

RMAN> delete global script backup_ts;

deleted global script: backup_ts


Oracle 11 - Creating RMAN Catalog


On this new post, information regarding how to create an RMAN catalog. It's a very easy process, with this step by step guide your RMAN catalog will be ready in 5 minutes.

Accomplishing this goal requires a dedicated database, in this example called RCAT, to store the rman catalog.

1.- Export ORACLE_SID to database instance name of RMAN catalog.

[oracle@racnode1 admin]$ export ORACLE_SID=RCAT1
[oracle@racnode1 admin]$ sqlplus / as sysdba

2.- Create tablespace where the catalog data will remain on RCAT instance.

SQL> create tablespace rman datafile '+DATA2' size 200m autoextend on;

Tablespace created.

3.- Create user to connect to catalog on RCAT instance.

SQL> create user rman identified by rman default tablespace rman quota unlimited on rman;

User created.

4.- Grant owner catalog privileges to rman user.

SQL> grant recovery_catalog_owner to rman;

Grant succeeded.

5.- Connect to catalog database with rman user and create the catalog.

[oracle@racnode1 admin]$ rman catalog rman/rman@RCAT

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jul 30 21:53:18 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to recovery catalog database

RMAN> create catalog;

recovery catalog created

6.- You can ensure login on RMAN user that metadata has been added.

[oracle@racnode1 ~]$ export ORACLE_SID=RCAT1
[oracle@racnode1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jul 30 22:09:29 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select object_name,object_type,status from dba_objects where owner='RMAN';

OBJECT_NAME OBJECT_TYPE     STATUS
---------------------------------------- ------------------- -------
RC_PROXY_DATAFILE VIEW     VALID
RC_PROXY_CONTROLFILE VIEW     VALID
RC_RMAN_CONFIGURATION VIEW     VALID
BCR TABLE     VALID
BCR_P INDEX     VALID
RC_DATABASE_BLOCK_CORRUPTION VIEW     VALID
RC_PROXY_ARCHIVEDLOG VIEW     VALID
RC_RESTORE_POINT VIEW     VALID
RC_RMAN_STATUS VIEW     VALID
RC_SITE  VIEW     VALID
BP_I_2 INDEX     VALID
BS_I_1 INDEX     VALID
.
.
.

7.- Registering database on catalog.

[oracle@racnode1 ~]$ rman target / catalog rman@RCAT

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jul 30 22:14:05 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (DBID=817802211)
recovery catalog database Password: 
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

8.- Cataloging an existing flash recovery area.

RMAN> catalog recovery area noprompt;

searching for all files in the recovery area

List of Files Unknown to the Database
=====================================
File Name: +fra/RACDB/CONTROLFILE/Current.256.820185477
File Name: +fra/RACDB/CONTROLFILE/Current.nuevo
cataloging files...
no files cataloged

List of Files Which Where Not Cataloged
=======================================
File Name: +fra/RACDB/CONTROLFILE/Current.256.820185477
  RMAN-07519: Reason: Error while cataloging. See alert.log.
File Name: +fra/RACDB/CONTROLFILE/Current.nuevo
  RMAN-07519: Reason: Error while cataloging. See alert.log.

List of files in Recovery Area not managed by the database
==========================================================
File Name: +FRA/racdb/onlinelog/group_5.261.820970867
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter
File Name: +FRA/racdb/onlinelog/group_6.262.820971003
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter

number of files not managed by recovery area is 2, totaling 100.00MB


9.- If the catalog database stops temporally, or network problems blocks connectivity between target database and catalog database, could be necessary, re-syncing modifications made to controlfile against rman catalog once the problem is solved.

RMAN> resync catalog;

starting full resync of recovery catalog
full resync complete


MySQL export sql select to csv file.

To export data from a sql statement in a MySQL environment, to a csv file:

select * into outfile '/var/tmp/1.csv' fields terminated by ',' enclosed by '"' lines terminated by '\n' from tabla1;

This SQL statement will export the desired data to the file /var/tmp/1.csv, in this example fields are separated by commas.

jueves, 1 de agosto de 2013

Oracle 11 RAC Services, creating and managing services


Services

Services are used to manage the workload in an Oracle RAC environment. Services are designed to group a workload, so users meetings the same requeriments can be grouped by using the same service.
For example, in an Oracle Rac environment could be defined a service for users who execute small and short transactions, other service for users executing long running transactions, and so on...

Service could be defined for both admin-managed and policy-managed databases.
There are restrictions creating services on policy-managed databases, services there are assigned to a server pool and can be defined as a Singleton or Uniform service.
A Singleton service runs only on one database instance on its server pool, and the user does not have the control over wich instance will serve the service.
A Uniform service runs on all database instances in its server pool.
The administrator-managed database runs the service assigning it in the preferred instances, if the preferred instance fails the service will run on the available instance.


Managing Services.

Database Services.

This sql statement show information about services from v$services view.

SQL> select name, network_name, creation_date, goal, dtp, aq_ha_notification,clb_goal from v$services;

NAME     NETWORK_NAME    CREATION_ GOAL   D AQ_ CLB_G
-------------------- ------------------------------ --------- ------------ - --- -----
servicetest     servicetest    22-JUL-13 NONE   N NO  LONG
RACDBXDB     RACDBXDB    07-JUL-13 NONE   N NO  LONG
RACDB.test     RACDB.test    07-JUL-13 NONE   N NO  LONG
SYS$BACKGROUND    07-JUL-13 NONE   N NO  SHORT
SYS$USERS    07-JUL-13 NONE   N NO  SHORT

With srvctl utility we can obtain information about a configured service.

[oracle@racnode1 ~]$ srvctl config service -d RACDB
Service name: servicetest
Service is enabled
Server pool: racdb_servicetest
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2

Preferred an available instances.

Preferred instances for a service are instances in wich the service will be started, available instances are backup instances, if a preferred instance fails, the service will be started on these instances.

Management Policy.

Oracle 11 allows specifying the management policy, manual or automatic, occasionally the DBA may want to start the database services manually, with srvct utility change the management policy to MANUAL to accomplish this goal.

Changing Service goal.

Service goal consist in a classification per service, this parameter could be SHORT or LONG due to the session life.

[oracle@racnode1 ~]$ srvctl modify service -s SERVICE_NAME -d RACDB -j SHORT


[oracle@racnode1 ~]$ srvctl config service -d RACDB
Service name: servicetest
Service is enabled
Server pool: racdb_servicetest
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: SHORT
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2

Connection Load Balancing Goal has changed from LONG to short.

Changing DTP (Distributed Transaction Processing).

By default all services running distributed transactions will be distributed along all rac instances, this option can be disabled or enabled.

[oracle@racnode1 ~]$ srvctl modify service -s servicetest -d RACDB -x TRUE
[oracle@racnode1 ~]$ srvctl config service -d RACDB
Service name: servicetest
Service is enabled
Server pool: racdb_servicetest
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: true
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: SHORT
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2
[oracle@racnode1 ~]$ srvctl modify service -s servicetest -d RACDB -x FALSE
[oracle@racnode1 ~]$ srvctl config service -d RACDB
Service name: servicetest
Service is enabled
Server pool: racdb_servicetest
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: SHORT
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2

Changing TAF (Transparent Application Failover).

Established sessions on a database are reallocated on other database instance in case of a source instance failure.
There are three policies: NONE, BASIC and PRECONNECT.
None: No TAF policy applied.
Basic: Restarts the failed query on the new database instance upon failover.
Preconnect: The same as the Basic method but in this case Oracle anticipates connection failure creating a shadow connection on the other instance, which is always available on the available instance, to improve the failover time.

[oracle@racnode1 ~]$ srvctl modify service -s servicetest -d RACDB -P BASIC

Creating new services.

The following command creates a service called TEST that defines RACDB1 as the preferred instance, RACDB2 as available instance, and BASIC TAF policy, also configures the service to start automatically using automatic management policy.

[oracle@racnode1 ~]$ srvctl add service -d racdb -s TEST -r RACDB1 -a RACDB2 -P basic -y AUTOMATIC
[oracle@racnode1 ~]$ srvctl config service -d RACDB -s TEST
Service name: TEST
Service is enabled
Server pool: racdb_TEST
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2

Starting, Stoping and disabling the service.

[oracle@racnode1 ~]$ srvctl start service -d RACDB -s TEST

[oracle@racnode1 ~]$ srvctl status service -d RACDB
Service servicetest is running on instance(s) RACDB1
Service TEST is running on instance(s) RACDB1

[oracle@racnode1 ~]$ srvctl stop service -d RACDB -s TEST

[oracle@racnode1 ~]$ srvctl status service -d RACDB
Service servicetest is running on instance(s) RACDB1
Service TEST is not running.

[oracle@racnode1 ~]$ srvctl disable service -d RACDB -s TEST

[oracle@racnode1 ~]$ srvctl config service -d RACDB -s TEST
Service name: TEST
Service is disabled
Server pool: racdb_TEST
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Preferred instances: RACDB1
Available instances: RACDB2


Oracle RAC SRVCTL operations

Below, a few commands to manage databases with srvctl utility.

Show registered databases in OCR repository.

[grid@racnode1 ~]$ srvctl config database
RACDB
RCAT
RMANCAT

Show configuration details of a database.

[grid@racnode1 ~]$ srvctl config database -d racdb
Database unique name: RACDB
Database name: RACDB
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/RACDB/spfileRACDB.ora
Domain: test
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: RACDB
Database instances: RACDB1,RACDB2
Disk Groups: DATA,FRA
Services: 
Database is administrator managed

Change management policy mode.

[grid@racnode1 ~]$ srvctl modify database -d racdb -y MANUAL
[grid@racnode1 ~]$ srvctl config database -d racdb
Database unique name: RACDB
Database name: RACDB
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/RACDB/spfileRACDB.ora
Domain: test
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: MANUAL
Server pools: RACDB
Database instances: RACDB1,RACDB2
Disk Groups: DATA,FRA
Services: 
Database is administrator managed

Change start option mode.

[grid@racnode1 ~]$ srvctl modify database -d racdb -s mount
[grid@racnode1 ~]$ srvctl config database -d racdb
Database unique name: RACDB
Database name: RACDB
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/RACDB/spfileRACDB.ora
Domain: test
Start options: mount
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: RACDB
Database instances: RACDB1,RACDB2
Disk Groups: DATA,FRA
Services: 
Database is administrator managed

Show database status.


[grid@racnode1 ~]$ srvctl status database -d racdb
Instance RACDB1 is running on node racnode1
Instance RACDB2 is not running on node racnode2

Show nodeapps status.


[grid@racnode1 ~]$ srvctl status nodeapps
VIP racnode1-vip is enabled
VIP racnode1-vip is running on node: racnode1
VIP racnode2-vip is enabled
VIP racnode2-vip is running on node: racnode1
Network is enabled
Network is running on node: racnode1
Network is not running on node: racnode2
GSD is disabled
GSD is not running on node: racnode1
GSD is not running on node: racnode2
ONS is enabled
ONS daemon is running on node: racnode1
ONS daemon is not running on node: racnode2
eONS is enabled
eONS daemon is running on node: racnode1
eONS daemon is not running on node: racnode2

Start / Stop database.

[oracle@racnode1 ~]$ srvctl start database -d racdb

[oracle@racnode1 ~]$ srvctl stop database -d racdb

Stop database with options.

[oracle@racnode1 ~]$ srvctl stop database -d racdb -o immediate

Start / Stop database on a node.

[oracle@racnode1 ~]$ srvctl start instance -d RACDB -i RACDB1

[oracle@racnode1 ~]$ srvctl stop instance -d RACDB -i RACDB1

Stop database with abort option on a node.

[oracle@racnode1  ~]$ srvctl stop instance -d RACDB -i RACDB1 -o abort

lunes, 4 de febrero de 2013

MySQL convert latin1 database to utf8

On the necessity of migrating the character set on a MySQL database, it is possible to easily achieve following these steps.

1.- Exporting database structure, it is important exporting to original character set.

mysqldump --default-character-set=latin1 --skip-set-charset -d -u root -p bd1 > bd1_estructura.sql

2.- Export data to a dump file, also exporting to original character set.
mysqldump --default-character-set=latin1 --skip-set-charset -t -u root -p bd1 > bd1_data.sql
 

3.- On the first dump file, change the character set with the new desired character set, in this case utf-8.

DEFAULT CHARSET=latin1
to
DEFAULT CHARSET=utf8

4.- Create the new database with utf-8 database character set.
create database bd2 default character set utf8 collate utf8_general_ci;

5.- Import structure with utf-8 character set.
mysql --default-character-set=utf8 -u root -p bd2 < bd1_estructura.sql

6.- Finally import data, also with utf-8 character set.
mysql --default-character-set=utf8 -u root -p bd2 < bd1_data.sql