Translation

The oldest posts, are written in Italian. If you are interested and you want read the post in English, please use Google Translator. You can find it on the right side. If the translation is wrong, please email me: I'll try to translate for you.
Visualizzazione post con etichetta HP-UX. Mostra tutti i post
Visualizzazione post con etichetta HP-UX. Mostra tutti i post

venerdì, giugno 17, 2016

Export/Import: on the fly

Here I show how to run export and import from a machine to another, just using pipes.

This is the configuration:
  • Two unix machine
    • source => HP-UX B.11.11
    • target => Red Hat Enterprise Linux 7.1
  •  Two database Oracle
    • source => Oracle 9.2.0.6
    • target => Oracle 11.2.0.4

This is what we want:


In this picture:
  • "src_hst", is the source machine
  • "src_db", is the source database
  • "src_usr", is the user, on the source database, which we export
  • "trc_db", is the target database
  • "trc_hst", is the target machine
  • "trg_user", is the user, on the target database, to be imported
  • "exp", is the export command
  • "imp", is the import command
  • "net", is the network between src_db and trg_db

To do this job (exp/imp), I configure the target machine, first and the source machine at least.

Starting from the target, you start to create a tube from the end to the biginning. In this way, when you fill the tube (start the export), the data flow through it and when they arrived to the end, they find someone (the import) that empty the tube.


Configuring the target and the source

This is the step number 0. In order to avoid the password when you connect from source to the target, you need to exchange the ssh-key.

You have just to run the "ssh-keygen" command on the source, and press RETURN any time. 

[oracle@src_hst]$ ssh-keygen (see update)
Generating public/private rsa key pair.
Please be patient....   Key generation may take a few minutes
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
bc:23:30:20:37:20:5b:9b:17:f5:5f:f9:10:cd:62:bd oracle@ht1-jim
The key's randomart image is:
+--[ RSA 2048]----+
|o . ...     .+   |
|.+ o . .    oo+  |
|o * .   .  .+. . |
| o +   . . . oE  |
|    o   S .   .  |
|     o   .       |
|      . o        |
|       . .       |
|                 |
+-----------------+



At this point you have two files in the /home/oracle/.ssh, direcotry
  • id_rsa
  • id_rsa.pub

You have to copy the content of the /home/oracle/.ssh/id_rsa.pub (following an example).....

[oracle@src_hst]$ cat /home/oracle/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArRfiCNq6nodHj5EKWeQ6ILOe/yICYVONaZa0SKF09msdZvfXYU+rN55fbubonwftyUjZbMRnMIoKTrsxi+UhFe8jIS2l/oVbOerHlCeyhXgCu+NrGM6Q56QPmrJgBMm7b1rb2Tsnh3jdTo3R00i7aCdaLvrVL3oK7IFS2jaVGGhJYTU1LXi8mhXQ3oQXkQ2bHkGGQ9Z68CD4cyYZ4St6lF7xLamwtvXwpC+M8m4s6zM/YiYTKib6RohLt7+kfXfzF3Boyx9AXOmTu93IS2GsRaiMcGVW/GH6T7qVvwPQej0vxpALOf2wdkRL5uSjVdGFUxwgXWDOtKlFDoWHEyYuuw== oracle@src_hst

.....in the /home/oracle/.ssh/authorized_keys file of the target host (following an example)

[oracle@trc_hst]$ cat /home/oracle/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArRfiCNq6nodHj5EKWeQ6ILOe/yICYVONaZa0SKF09msdZvfXYU+rN55fbubonwftyUjZbMRnMIoKTrsxi+UhFe8jIS2l/oVbOerHlCeyhXgCu+NrGM6Q56QPmrJgBMm7b1rb2Tsnh3jdTo3R00i7aCdaLvrVL3oK7IFS2jaVGGhJYTU1LXi8mhXQ3oQXkQ2bHkGGQ9Z68CD4cyYZ4St6lF7xLamwtvXwpC+M8m4s6zM/YiYTKib6RohLt7+kfXfzF3Boyx9AXOmTu93IS2GsRaiMcGVW/GH6T7qVvwPQej0vxpALOf2wdkRL5uSjVdGFUxwgXWDOtKlFDoWHEyYuuw== oracle@src_hst

Now you are ready to start the import/export job.

Configuring the target

[oracle@trc_hst]$ mkdir /home/oracle/IMPORT
[oracle@trc_hst]$ mknod /tmp/impTrcUsr.pipe p
[oracle@trc_hst]$ nohup imp trc_usr/trc_pwd \
                        file=/tmp/impTrcUsr.pipe \
                        parfile=/home/oracle/IMPORT/impTrcUsr.par \
                        > /home/oracle/IMPORT/impTrcUsr.nohup 2>&1 &

I used a parfile. Because I don't want to import the index, I used these options:

[oracle@trc_hst]$ cat /home/oracle/IMPORT/impTrcUsr.par
BUFFER=5000000
INDEXES=N

 

Configuring the source

[oracle@src_hst]$ mkdir /home/oracle/EXPORT
[oracle@src_hst]$ mknod /tmp/expTrcUsr.pipe p
[oracle@src_hst]$ nohup ssh oracle@src_hst "cat > /tmp/impSrcUsr.pipe" < /tmp/expTrcUsr.pipe &
[oracle@src_hst]$ time nohup exp src_usr/src_pwd \
                       file=/tmp/expTrcUsr.pipe \
                       parfile=/home/oracle/EXPORT/expSrcUsr.par \
                       > /home/oracle/EXPORT/expSrcUsr.nohup 2>&1 &

I used a parfile. Because I want to export only 2 tables, I used these options:

[oracle@src_hst]$ cat /home/oracle/EXPORT/expSrcUsr.par
DIRECT=Y
BUFFER=5000000
RECORDLENGTH=5000000
TABLES=(MYTAB01, MYTAB02)

 

Note on the import

I'm using a pipe instead a standard file. Except this, all is usual.


Note on the export

* I'm using a pipe instead a standard file
* I'm using a remote command "cat", in order to write the exported data into the remote pipe
* The source pipe is used as standard of input of ssh command. In this way all that is wrote in the source pipe is also wrote in the remote pipe
* I use the "time" command, in order to know how long the export/import process takes


Update

19/July/2017
Sometimes the ssh-keygen command want the type of  encryption. In this case you have to use the -t switch. For example

$ ssh-keygen -t rsa

venerdì, febbraio 26, 2016

CPU count (ENG)

  • HP-UX (B.11.11)

[oracle]$/usr/sbin/ioscan  -knfC processor |grep processor |wc -l
      8
 
[oracle]$/usr/sbin/ioscan  -knfC processor

Class       I  H/W Path  Driver    S/W State H/W Type  Description
===================================================================
processor   0  4/10      processor CLAIMED   PROCESSOR Processor
processor   1  4/11      processor CLAIMED   PROCESSOR Processor
processor   2  4/12      processor CLAIMED   PROCESSOR Processor
processor   3  4/13      processor CLAIMED   PROCESSOR Processor
processor   4  6/10      processor CLAIMED   PROCESSOR Processor
processor   5  6/11      processor CLAIMED   PROCESSOR Processor
processor   6  6/12      processor CLAIMED   PROCESSOR Processor
processor   7  6/13      processor CLAIMED   PROCESSOR Processor



  • Solaris
[oracle]$/usr/sbin/psrinfo |wc -l
      32


[oracle]$/usr/sbin/psrinfo 
0       on-line   since 02/12/2016 09:57:19
1       on-line   since 02/12/2016 09:57:21
2       on-line   since 02/12/2016 09:57:21
3       on-line   since 02/12/2016 09:57:21
8       on-line   since 02/12/2016 09:57:21
9       on-line   since 02/12/2016 09:57:21
10      on-line   since 02/12/2016 09:57:21
11      on-line   since 02/12/2016 09:57:21
16      on-line   since 02/12/2016 09:57:21
17      on-line   since 02/12/2016 09:57:21
18      on-line   since 02/12/2016 09:57:21
19      on-line   since 02/12/2016 09:57:21
24      on-line   since 02/12/2016 09:57:21
25      on-line   since 02/12/2016 09:57:21
26      on-line   since 02/12/2016 09:57:21
27      on-line   since 02/12/2016 09:57:21
32      on-line   since 02/12/2016 09:57:21
33      on-line   since 02/12/2016 09:57:21
34      on-line   since 02/12/2016 09:57:21
35      on-line   since 02/12/2016 09:57:21
36      on-line   since 02/12/2016 09:57:21
37      on-line   since 02/12/2016 09:57:21
38      on-line   since 02/12/2016 09:57:21
39      on-line   since 02/12/2016 09:57:21
40      on-line   since 02/12/2016 09:57:21
41      on-line   since 02/12/2016 09:57:21
42      on-line   since 02/12/2016 09:57:21
43      on-line   since 02/12/2016 09:57:21
44      on-line   since 02/12/2016 09:57:21
45      on-line   since 02/12/2016 09:57:21
46      on-line   since 02/12/2016 09:57:21
47      on-line   since 02/12/2016 09:57:21



  • Linux 
[oracle]$cat /proc/cpuinfo|grep processor|wc -l
      16

[oracle]$/sbRdbms/oracle-$cat /proc/cpuinfo|grep processor
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
processor       : 8
processor       : 9
processor       : 10
processor       : 11
processor       : 12
processor       : 13
processor       : 14
processor       : 15



  • AIX (6.1 verified)
[oracle]$/bin/lparstat |head -2| sed '/^$/d'| awk '{print $6}'
lcpu=16

[oracle]$/bin/pmcycles -m
CPU 0 runs at 3864 MHz
CPU 1 runs at 3864 MHz
CPU 2 runs at 3864 MHz
CPU 3 runs at 3864 MHz
CPU 4 runs at 3864 MHz
CPU 5 runs at 3864 MHz
CPU 6 runs at 3864 MHz
CPU 7 runs at 3864 MHz
CPU 8 runs at 3864 MHz
CPU 9 runs at 3864 MHz
CPU 10 runs at 3864 MHz
CPU 11 runs at 3864 MHz
CPU 12 runs at 3864 MHz
CPU 13 runs at 3864 MHz
CPU 14 runs at 3864 MHz
CPU 15 runs at 3864 MHz


  • Update (15/Mar/2016)

From Oracle point of view, in order to obtains the CPU count, you have to query V$OSSTAT. This view exist from Oracle 10g onwards. Normally the value you use is NUM_CPUS

[Linux] select stat_name, value from  v$osstat where stat_name like '%CPU%';

STAT_NAME                           VALUE
------------------------------ ----------
NUM_CPUS                               16 <<< correct value
RSRC_MGR_CPU_WAIT_TIME                 43
NUM_CPU_CORES                          16
NUM_CPU_SOCKETS                        16


Anyway, on AIX platform, because the "Bug 14215038 : CPU_COUNT DOESN'T MATCH", you need to use different column

[AIX] select stat_name, value from  v$osstat where stat_name like '%CPU%';

STAT_NAME                           VALUE
------------------------------ ----------
NUM_CPUS                               44 <<< wrong value due to 14215038 Bug
OS_CPU_WAIT_TIME               3.3043E+10
RSRC_MGR_CPU_WAIT_TIME                  0
NUM_CPU_CORES                          10
NUM_VCPUS                              10 <<< correct Virtual CPU number
NUM_LCPUS                              20 <<< correct Logical CPU number


If you compare this output with the "AIX (6.1 verified)", you see that the NUM_CPUS column cointain a wrong value.


  • Update 2016/Jun/13

Modified the /usr/sbin/ioscan output. It counted wrong the CPU processors number
  • Reference
Physical - Virtual - Logical CPU