You are on page 1of 5

Transcript name: 12.

DB2 instances
English
In this video, we provide an overview of DB2 instances. An instance is an independent environment where applications can run, and databases can be created. For example, in this figure we show a gray box representing a DB2 data server after installing DB2 Express-C 9.7. When installing DB2 Express-C on Windows, a default DB2 instance is created, which happens to be called DB2. On Linux this default instance is called db2inst1. This is represented by the green box. You can create multiple instances on a data server, and use them for different purposes. For example, one instance can hold databases for production, another one for test, and another one for development. All of these instances are independent; that is, performing operations on one instance will not affect the other instances. For example, in this figure, instance MYINST is totally independent from instance DB2. If instance DB2 crashes, it will not affect instance MYINST. Each instance has a unique TCP/IP port number. This helps to En este video vemos el tema Instancias DB2 Una instancia es un entorno independiente en el cual se pueden ejecutar aplicaciones y crear bases de datos. Por ejemplo, en esta imagen tenemos una caja gris representando un servidor DB2 luego de instalar DB2 Express-C 9.7. Cuando instalamos DB2 Express-C en Windows, se crea una instancia DB2 por omisin, la cual se denomina DB2. En Linux esta instancia por omisin se denomina db2inst1. Esto est representado por la caja verde. Se pueden crear mltiples instancias en un servidor de datos, y usarlos para distintos propsitos. Por ejemplo, una instancia puede tener bases de datos para produccin, otra para test, y otra ms para desarrollo. Todas estas instancias son independientes; o sea, las operaciones que se ejecutan sobre una instancia, no afectan a ninguna de las otras. Por ejemplo, en este cuadro, la instancia MYINST es independiente de la instancia DB2. Si la instancia DB2 se cae, esto no afecta a la instancia MYINST. Cada instancia tiene asignado un puerto TCP/IP nico. Esto ayuda

distinguish between instances when you want to connect to a database in a given instance from a remote client using TCP/IP. To create a new DB2 instance, from the Command Window or Linux shell use the command db2icrt and the <instance name>. For example, to create the instance MYINST, we use: db2icrt myinst and press enter. To list the instances in your system, run the command: db2ilist In our case, it shows two instances, instance MYINST and instance DB2. To make an instance the active one, meaning that all commands are directed to that instance within a Command Window, or Linux shell, use set db2instance=myinst if you want to make the MYINST instance the active one. And press enter. Note that there should not be any blank spaces before or after the equal sign (=). On Linux, an instance maps to a Linux user, so if you want to make another instance the active one, simply switch to the corresponding user using the Linux's su command. To list the current active instance, issue:

a distinguir las instancias cuando uno quiere conectarse con una instancia de la base de datos desde un cliente remoto va TCP/IP. Para crear una nueva instancia, desde la ventana de comandos de Windows o el shell de Linux use el comando db2icrt y el nombre de la instancia. Por ejemplo, para crear la instancia MYINST, usamos: db2crt myinst y presionamos enter. Para listar todas las instancias de nuestro sistema, ejecutamos el comando: db2ilist En nuestro caso, muestra dos instancias, MYINST y DB2. Para que una instancia sea la activa por omisin, y que todos los comandos se direccionen a dicha instancia, desde una ventana de comandos Windows o un shell Linux, usamos set db2instance=myinst si queremos hacer que la instancia MYINST sea la activa. Y presionamos enter. Fjense que no debera haber espacios ni antes ni despus del signo (=). En Linux, una instancia se asocia con un usuario Linux, as que para hacer que otra instancia sea la activa, simplemente hay que cambiar al usuario correspondiente, usando el comando Linux su. Para ver cul es la instancia activa, escribimos:

db2 get instance As you can see MYINST is shown as the active one to this command window since I set the db2instance variable to MYINST earlier. Let me set the instance DB2 to be again the active one to my commands. So I issue: set db2instance=db2 And I press enter. To stop an instance, issue the command db2stop As you can see I have now stopped the instance DB2, which was the active one to my commands. The other instance MYINST is not affected, so if that other instance was running, it will still continue to run. If I try to connect to the SAMPLE database by by issuing a: db2 connect to sample and pressing enter. I will get an error message because the instance is not up. To start an instance, issue the command: db2start Press enter. As you can see, I have now started the instance DB2. Now I can try to connect to sample again and this time it works. On Windows, you can also stop and start an instance from the Services panel.

db2 get instance Como puede verse, MYINST aparece como la instancia activa para esta ventana de comandos, ya que puse antes la variable db2instance igual a MYINST. Voy a poner otra vez la instancia DB2 como activa para mis comandos. Entonces escribo: set db2instance=db2 Y presiono enter. Para detener una instancia, usamos el comando db2stop Como pueden ver acabo de detener la instancia DB2, que era la activa para mis comandos. La otra instancias, MYINST no es afectada, as que si estaba corriendo antes, seguir corriendo ahora. Si trato de conectarme con la base de datos SAMPLE ejecutando: db2 connect to sample y presiono enter, obtengo un mensaje de error porque la instancia no est corriendo. Para arrancar una instancia, usamos el comando: db2start Presionamos enter. Como pueden ver, arranqu la instancia DB2. Ahora puedo volver a intentar connect to sample y esta vez funciona. En Windows, tambin se puede parar y arrancar una instancia desde el panel de Servicios.

Each instance corresponds to a Windows service. Here we can see one service for instance DB2, and another service for instance MYINST. Let's double-click on the service for instance MYINST, and you can see from here that you can start or stop the service or instance. You can also click on thelogon tab and you can see that this service is started as a local system. But, normally you will see services of DB2 being started by the account that you specified when you installed DB2. To drop an instance issue db2idrop and the name of the instance. So for example, I will put here db2idrop myinst and press enter. To confirm that I in fact dropped the instance MYINST I can do a: db2ilist And this time I see that the MYINST instance does not show up in the list of instances. Let me quickly create it again so I can use the instance MYINST later on in other videos. You can also manage instances from GUI tools like IBM Data Studio which we'll discuss in another video. This concludes this presentation. Thank you for watching. To learn more, visit db2university.com

Cada instancia corresponde a un servicio Windows. Ac vemos un servicio para la instancia DB2, y otro servicio para la instancia MYINST. Hacemos doble click en el servicio para la instancia MYINST, y vemos que desde ac se puede arrancar o parar el servicio o instancia. Tambin se puede clickear en el tab logon y ver que el servicio es iniciado como sistema local. Pero, normalmente vern a los servicios DB2 siendo arrancados por la cuenta que se especific al instalar DB2. Para eliminar una instancia, usamos db2idrop y el nombre de la instancia. Por ejemplo, yo voy a poner db2idrop myinst y presionar enter. Para confirmar que efectivamente elimin la instancia MYINST puedo hacer un: db2ilist y comprobar que esta vez la instancia MYINST no aparece en la lista de instancias. Dejenme recrearla rpidamente as puedo utilizar MYINST ms adelante para otros videos. Tambin podemos manejar las instancias desde herramientas GUI como el IBM Data Studio el cual veremos en otro video. Esto concluye la presentacin. Gracias por verla! Para ms informacin, visite db2university.com

You might also like