Antón María Rodríguez Yuste

 
 
 
  • About

    Consultor orientado al sector TELCO (eTOM, SID), dirección de proyectos (scrum) y sistemas (Oracle, Weblogic, Jboss, Solaris, etc.). Un poco de todo, vamos.

  • Varios

Sindicación


Licencia


Validación



Sistemas






Varios

 
Aumentando el nº de conexiones de Oracle December 31st, 2008

Después de obtener diversos errores levantando el servidor de aplicaciones, he decidido aumentar el nº de conexiones de la BBDD a ver si así la cosa mejora.

Lo primero, ver el nº de conexiones que tenemos actualmente:

CODE:
  1. select * from v$parameter;

De ahí, sacamos los parámetros 'processes' y 'sessions'.

Me he conectado al servidor de BBDD y he modificado el siguiente fichero: /usr/local/oracle/9.2_64/dbs/initmslvenv1.ora

He cambiado ambos parámetros ('processes' y 'sessions').

Toca bajar la BBDD y volver a levantarla de la siguiente forma:

CODE:
  1. ORACLE_SID=mslvenv1 sqlplus /nolog
  2. connect / as sysdba;
  3. startup pfile='/usr/local/oracle/9.2_64/dbs/initmslvenv1.ora'
  4.  

Ahora comprobamos que todo va bien, los valores se han cargado y son realmente los correctos. A continuación, toca hacer el cambio permanente para que se use en el próximo reinicio.

CODE:
  1. create spfile='/usr/local/oracle/9.2_64/dbs/spfilemslvenv1.ora' from pfile='/usr/local/oracle/9.2_64/dbs/initmslvenv1.ora'

Y ya tá.

Gracias a Rober por la ayuda ;-)

Y feliz año!

Reconocer el set de carácteres de un export de BBDD sin su log November 6th, 2008

Estos días he tenido diversos problemas por el set de caracteres de unos exports.

Esta información me ha sido muy útil para solucionarlos:

QUOTE:
    Introduction:

    One of the most common NLS-related problems reported to Oracle Worldwide
    Customer Support is the loss or changing of characters after an export and
    import. This is almost always due to NLS_LANG being set to the incorrect
    character set during export.

    Role of NLS_LANG During Export/Import:

    This is explained in detail in Note 15095.1 but, in brief, export and import
    are client tools and will work under the character set specified by NLS_LANG.
    If, for instance, the database is created with a character set of WE8DEC and
    NLS_LANG is set to AMERICAN_AMERICA.WE8PC850 then the ascii values of the stored
    characters in the database will be translated to the values for the same
    characters in the WE8PC850 character set. The character set defined by NLS_LANG
    during the export is stored in the export dump file and is used to ensure that
    the data is translated correctly to the character set defined by NLS_LANG for
    the import.

    Potential Problems:

    If NLS_LANG is not set, for instance, export will be done under US7ASCII, the
    default character set. If the database was built with character set WE8DEC
    the characters stored in the database will be converted to US7ASCII and any
    8-bit characters, having no equivalent in US7ASCII, will be stripped out.

    The same problem will be seen if the character set defined by NLS_LANG is
    not a superset of the one being translated from (ie: the database character
    set on export or the export file character set on import).

    Identifying the Export Character Set:

    When investigating problems like these it is useful to check the character
    set used for the export. As said above, this is held in the export dump file.
    It can be seen by doing a hex dump of the export file as follows (in Unix):

    cat expdat.dmp | od -x | head

    This will produce output similar to:

    0000000 0300 0145 5850 4f52 543a 5630 372e 3033
    0000020 2e30 330a 4454 534f 0a52 5441 424c 4553
    0000040 0a31 3032 340a 300a 0020 2020 2020 2020
    0000060 2020 2020 2020 2020 2020 2020 2020 2020
    *
    0000140 2020 2020 2020 2020 4d6f 6e20 4e6f 7620
    0000160 3130 2031 343a 3031 3a33 3620 3139 3937
    0000200 0a54 4142 4c45 2022 454d 5022 0a43 5245
    0000220 4154 4520 5441 424c 4520 2245 4d50 2220

    The second and the third byte in the file define the character set used for
    the export.

    In the example above, the second byte is 0x00 and the third byte is 0x01,
    yielding 0x0001 as the character set ID. This shows that NLS_LANG was set
    to US7ASCII during the export. The new Oracle8 functions NLS_CHARSET_NAME
    and NLS_CHARSET_ID can be used to map character set IDs to character set names.
    The mapping is also given in Note 13971.1.

    Note that the 16-bit value is stored in the EXP platform endian.

    Most unix platforms are big-endian ( Sparc, PowerPc, PARisc, RS/6000, SGI R4000 systems),
     i.e. the most significant byte is showed first.
    (like above example -> if the file begins with 03xx -> big endian)

    On little-endian platforms, (platforms running on Intel/AMD x86 and Alpha mainly)
    the output will be slightly different as below:

    00000000 0003 4501 5058 524f 3a54 2e37 3330
    etc.

    Here the most significant byte is showed *last* (!)

    (if the file begins with xx03 -> little endian)

    The values for the most commonly used character sets are below:

    Name            ID
    ----------------------
    US7ASCII        0x0001
    WE8DEC    0x0002
    WE8ISO8859P1    0x001f
    EE8ISO8859P2    0x0020
    SE8ISO8859P3    0x0021
    NE8ISO8850P4    0x0022
    CL8ISO8859P5    0x0023
    AR8ISO8859P6    0x0024
    EL8ISO8859P7    0x0025
    IW8ISO8859P8    0x0026
    WE8ISO8859P9    0x0027
    WE8ISO8859P15   0x002e
    TH8TISASCII     0x0029
    US8PC437        0x0004
    WE8ROMAN8       0x0005
    WE8PC850        0x000a
    EE8PC852        0x0096
    RU8PC855        0X009B         
    TR8PC857        0x009C         
    WE8PC858        0x001c
    WE8PC860        0x00A0
    IS8PC861        0x00A1         
    N8PC865         0x00BE         
    RU8PC866        0x0098
    EE8MSWIN1250    0x00aa
    CL8MSWIN1251    0x00ab
    WE8MSWIN1252    0x00b2
    EL8MSWIN1253    0x00ae
    TR8MSWIN1254    0x00b1
    IW8MSWIN1255    0x00af         
    AR8MSWIN1256    0x0230
    BLT8MSWIN1257   0x00b3
    ZHT16MSWIN950   0x0363
    ZHS16GBK        0x0354
    ZHT16HKSCS      0x0364
    JA16EUC  0x033e
    JA16SJIS        0x0340
    ZHT16BIG5       0x0361
    AL24UTFFSS      0x0366
    UTF8            0x0367
    AL32UTF8        0x0369

            select nls_charset_id(value) nls_charset_id,  value
            from  v$nls_valid_values
            where parameter = 'CHARACTERSET'
            order by nls_charset_id(value);

    Gives the nls_charset_id in DECIMAL, so you need to convert it to HEX first.

    Alternative you can open the characterset definition using Locale Builder (9i
    and up), this will also show the characterset ID in DECIMAL in the first screen
    (note that there is also an ISO ID that is NOT used here in the exp file)
    Note 223706.1  Using Locale Builder to view the definition of character sets

    Warning:  User modifications of export dump files are not supported
    ========  by Oracle.  The character set information is also held in other
              places in the export dump file and modifying only the two bytes
              may lead to problems with imported data.

              NOT WORKING any more with Oracle 9i R2 (9.2) and up,
              due to changes in the import /export tools
              but you can use a 8i exp against a 9i db for example, more
              info is in Note 132904.1 Compatibility Matrix for Export & Import
                                         Between Different Oracle Versions

    In some cases it can be useful to modify the character set information
    held in the dump file. This should not be taken lightly since the character
    set information is also held in other places.

    We STRONGLY advice you to log a NLS tar FIRST to get confirmation that this is
    a solution for your problem before starting to change this header.

    If, after careful consideration of other options and verification by support,
    you do decide to edit the character set simply use a binary file editor to do so.

    You could for example use a freeware Hex Editor like
    * XVI32 http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm
    * HxD  http://mh-nexus.de/en/hxd/

    In case of multiple dump files from a single export, you need to modify each
    and every export dump file. Otherwise, you will error out with -
    IMP-00008: unrecognized statement in the export file:
    when opening the second file.

Fuentes:
ligarius.wordpress.com
infor.uva.es

Sequences October 13th, 2008

Incrementado secuencias....

CODE:
  1.  
  2. select ' alter sequence ' || us.sequence_name || ' increment by 10000000;' from user_sequences us;
  3. select 'select ' || us.sequence_name || '.nextval from dual; ' from user_sequences us;
  4. select ' alter sequence ' || us.sequence_name || ' increment by 1;' from user_sequences us;
  5.  
Cache y shared August 22nd, 2008

ORACLE_SID=mslvenv1 sqlplus '/ as sysdba'
show parameter cache
ALTER SYSTEM SET db_cache_size='209715200' SCOPE=BOTH;
show parameter shared
ALTER SYSTEM SET shared_pool_size='157286400' SCOPE=BOTH;

NLS_LANG, locales y Oracle May 29th, 2008

Ahí van un par de entraditas.

Tenía el problema de que al lanzar un script con tildes con el usuario 'oracle' y el sqlplus me daba errores por las tildes.

Lo que hice fué como root:

CODE:
  1.  
  2. dpkg-reconfigure locales
  3.  

y marqué es_ES.UTF-8.

Como usuario oracle edite el .bash_profile con algo como esto:

CODE:
  1.  
  2. NLS_LANG=SPANISH_SPAIN.WE8ISO8859P1
  3. export NLS_LANG
  4. LANG=es_ES.UTF-8
  5. export LANG
  6.  

Y listo. Problema resuelto.

Tablespace a usuario January 21st, 2008
CODE:
  1. ALTER USER scott default tablespace USERS quota unlimited on USERS
  2. /
  3.  
Permisos sobre una tabla de Oracle November 28th, 2007

Lo malo de ser autodidacta y aprender algo nuevo al mismo tiempo que se usa es que te dejas un montón de cosas básicas por el camino. Una de ellas es, por ejemplo, darle permisos a un usuario (1) de la BD para borrar registros en la tabla de otro usuario (2). Sencillo, como system:

CODE:
  1. GRANT delete ON usuario2.tabla TO usuario1;

Y si además, queremos que usuario1 pueda darle permisos a un usuario3:

CODE:
  1. GRANT delete ON usuario2.tabla TO usuario1 WITH GRANT OPTION;
Copiando usuarios sin el contenido en Oracle November 26th, 2007

La idea, copiar el schema de un usuario a otro pero sin copiar el contenido de todas sus tablas. La solución, una vez creado el usuario2. Hacer el export del usuario1:

CODE:
  1. ORACLE_SID=sid_de_la_BD exp usuario1/contraseña file=archivo.dmp rows=n direct=y

y luego el import.

CODE:
  1. ORACLE_SID=sid_de_la_BD imp system/manager file=archivo.dmp fromuser=usuario1 touser=usuario2 commit=y

Gracias por la ayuda, Rober.

Nota: no lo hice del todo bien, el usuario con el que hacemos el export/import debe ser el system y luego usarl el fromuser touser.

Algo más de info: elholgazan

ORA-03297 November 23rd, 2007

Dejé que un tablespace creciera de forma descontrolada con la idea de con el OEM volverlo a su tamaño después. Pero al hacer el resize me saltaba un ORA-03297: file contains used data beyond requested RESIZE value . Al final se optó por crear un nuevo archivo de datos y un nuevo tablespace y borrar el anterior. Todo ello con el OEM salvo la asignacion que se hizo así:

CODE:
  1. alter system set undo_tablespace = NUEVO_TABLESPACE  scope = memory;

y una vez borrado y vuelto a crear:

CODE:
  1. alter system set undo_tablespace = VIEJO_TABLESPACE  scope = memory;

Otra vez, Richi, gracias.

AUTOCOMMIT ORACLE November 22nd, 2007

Vamos a poner un pequeño caso práctico. Se trata de duplicar un usuario con todo su contenido en una base de datos Oracle. Luego, además, le pegamos un repaso para eliminar todo aquello que ocupe demasiado ya que el nuevo usuario no se va a usar para las mismas funcionalidades.

Veamos, lo primero. Nos vamos al SQL/Developer y le damos a View sobre el usuario en cuestión. Luego a ViewSql. Copiamos el código, modificamos el nombre y añadimos una password y lo ejecutamos como usuario system.

CODE:
  1.  
  2. -- Create the user
  3. create user PICOCORBA
  4.   identified by "password";
  5. -- Grant/Revoke role privileges
  6. grant connect to PICOCORBA;
  7. grant resource to PICOCORBA;
  8. -- Grant/Revoke system privileges
  9. grant unlimited tablespace to PICOCORBA;
  10.  

Ahora hacemos un export de la BD del usuario que queremos importar.

CODE:
  1. ORACLE_SID=se2 exp userid=pico/password direct=y file=host-se2_chanante-pico-071122.dmp

y lo importamos en el nuevo usuario:

CODE:
  1. ORACLE_SID=se2 imp userid=picocorba/password file=chanante-se2_chanante-pico-071122.dmp log=chanante-se2_chanante-picorba-071122.log full=y

Vamos ahora a echar un vistazo al tamaño de las tablas. Ejecutamos como el nuevo usuario:

CODE:
  1. select segment_name, bytes/1024/1024 MB from user_segments
  2. where segment_type='TABLE' order by bytes desc;

Ok, vamos a vaciar todas aquellas tablas que ocupen más de un mega. Ejecutamos como el nuevo usuario:

CODE:
  1. select 'delete from ' || segment_name ||' cascade;' from user_segments
  2. where segment_type='TABLE' and bytes/1024/1024> 1 order by bytes desc;

Cojemos el resultado de la query, lo pegamos en el PL/SQL Developer o en sqlplus y listo.. o no. Si las tablas son realmente grande se puede petar el tablespace temporal ya que se guarda toda la información para el posible rollback. ¿Como arreglarlo?. Ejecutando antes:

CODE:
  1. set autocommit on

Luego todos los delete from y finalmente:

CODE:
  1. set autocommit off