Oracle Live

12/04/2016

RAC – Comandos de administracion

Filed under: RAC — mogukiller @ 12:02 am
-- Add database
-- Add instance
-- Add listener
-- Add services
-- Modify atributes
-- Start / Stop instance
-- Start / Stop services
-- Start / Stop / Status ASM
-- Habilitamos / Deshabilitamos recursos del cluster
-- Realocate services
-- Remove configuration
-- Set / Get Environment
-- Get Status
-- Get Configuration
-- Resource
-- CLUVFY

----------------------------
-- Add database
----------------------------

srvctl add database 
	-d db_unique_name                                 << -- db_unique_name de la base de datos
	-o oracle_home                                    << -- $ORACLE_HOME
	[-x node_name]                                     
	[-m domain_name]                                   
	[-p spfile]                                       << -- Ubicacion del pfile
	[-c {RACONENODE | RAC | SINGLE}                   << -- RAC por defecto
	[-e server_list]                                  
	[-i instance_name]                                << 
	[-w timeout]]                                     <<
	[-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}]	<< -- Role de la base de datos
	[-s start_options]                                << -- Cuando se hace srvctl start database como quieres que te la deje. Comillas para comandos complejos 'read only'
	[-t stop_options]                                 << -- Cuando srvctl stop database si queremos que sea IMMEDIATE o ABORT
	[-n db_name]									  << --	Si el db_name es diferente al db_unique_name
	[-j "acfs_path_list"] 
	[-y {AUTOMATIC | MANUAL | NORESTART}]             << -- Si queremos que se reinicie la base de datos automaticamente cuando se reinicie el cluster
	[-g server_pool_list]                             <<
	[-a "disk_group_list"]                            
                                                      << -- Con ASM que diskgroup esta utilizando

 -- Ejemplo:

 srvctl add database -d moguland -o $ORACLE_HOME -p +RECO/moguland/spfilemoguland.ora -r PRIMARY -s OPEN -t IMMEDIATE -Y AUTOMATIC -a "RECO,DATA"
 
------------------------------
-- Add instance
------------------------------

srvctl add instance -d db_unique_name -i instance_name -n node_name

------------------------------
-- Add listener
------------------------------

srvctl add listener 
	[-l listener_name] 
	[-o Oracle_home]
	[-p "[TCP:]port_list[/IPC:key][/NMP:pipe_name][/TCPS:s_port][/SDP:port]"]
	[-k network_number] 
	[-s]

	--Ejemplo
	srvctl add listener -l listener2 -p "TCP:1531"

------------------------------
-- Add services
------------------------------

-- Sintaxis 1:

srvctl add service 
		-d db_unique_name                                     << -- db_unique_name de la base de datos
		-s service_name                                       << -- Nombre del servicio
		{-r "preferred_list"								  << -- Lista de instancias donde se prefiere que se levante						
			[-a "available_list"] 							  << -- Lista de instancias donde se levantara si en la lista preferida no se puede	
			[-P {BASIC | NONE | PRECONNECT}] | -g server_pool
			[-c {UNIFORM | SINGLETON]}
		[-k network_number]                                   << -- Sobre que interface se ofrece el servicio
		[-l [PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY]		<< -- Role de la base de datos
		[-y {AUTOMATIC | MANUAL}]                             << -- AUTOMATIC se levantara el servicio cuando la instancia levante
		[-q {TRUE | FALSE}]                                   << -- 
		[-x {TRUE | FALSE}]                                   << --
		[-j {SHORT | LONG}]                                   << -- Para el balanceo de conexiones. SHORT funcionaria como un pool. LONG cuando balanceamos por nodo
		[-B {NONE | SERVICE_TIME | THROUGHPUT}]               << -- 
		[-e {NONE | SESSION | SELECT}]                        << --
		[-m {NONE | BASIC}]                                   << --
		[-z failover_retries]                                 << --
		[-w failover_delay]                                   << --

-- Sintaxis 2:

srvctl add service 
	-d db_unique_name 
	-s service_name
	-u {-r preferred_list | -a available_list} 
	[-f]													<< -- Fuerza añadir un servicio aunque el listener no este configurado para la red.

---------------------------------
-- Modify atributes
---------------------------------
-- Database
	srvctl modify database 
		-d db_unique_name 
		[-n db_name]				<< -- si es diferente de db_unique_name
		[-o oracle_home] 
		[-u user_name]				<< -- owner de $ORACLE_HOME
		[-m db_domain]
		[-p spfile]
		[-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}]
		[-s start_options] 
		[-t stop_options] 
		[-y {AUTOMATIC | MANUAL | NORESTART}]
		[-g "server_pool_list"] 
		[{-a "diskgroup_list" | -z}]	<< -- -z sirve para quitar la dependencia con ASM
		[-e server_list] 
		[-w timeout] 
		[-j "acfs_path_list"]
-- Instance
	srvctl modify instance 
		-d db_unique_name 
		-i instance_name
		{-n node_name | -z}		<< -- cambia el nombre del nodo donde se intentara levantar la instancia
-- Listener
	srvctl modify listener 
		[-l listener_name] 
		[-o oracle_home] 
		[-u user_name]
		[-p "[TCP:]port_list[/IPC:key][/NMP:pipe_name][/TCPS:s_port][/SDP:port]"]
		[-k network_number]		
	' nos puede servir para cambiar el puerto del listener'	
-- Service
	' para mover servicios de una instancia a otra'
	srvctl modify service
		-d db_unique_name 
		-s service_name 
		-i old_instance_name
		-t new_instance_name 
		[-f]			<< -- desconecta todas las sesiones cuando se realoca el servicio		
	
	' para configurar una instancia de posible a preferida'
	srvctl modify service 
		-d db_unique_name 
		-s service_name 
		-t edition_name
		-i avail_inst_name 
		-r 
		[-f]
	' configura tanto las preferred como las available'
	srvctl modify service 
		-d db_unique_name 
		-s service_name 
		-n 
		-i preferred_list
		[-a available_list] 
		[-f]
	' cambiamos otras configuraciones'
	srvctl modify service
		-d db_unique_name 
		-s service_name 
		-l {[PRIMARY] | [PHYSICAL_STANDBY] | [LOGICAL_STANDBY] | [SNAPSHOT_STANDBY]}
		-y {AUTOMATIC | MANUAL}

--------------------------------
-- Start / Stop instance
--------------------------------
	
-- Start instance
	srvctl start instance 
		-d db_unique_name
		{ [-n node_list] | [-i instance_list]}
		[-o start_options]
	'nota: opciones compuestas entre comillas read only'
	
-- Stop instance
	srvctl stop instance
		-d db_unique_name
		{ [-n node_list] | [-i instance_list]}
		[-o start_options]
	
--------------------------------
-- Start / Stop services
--------------------------------
srvctl start service 
	-d database_unique_name 
	[-s service_name_list] 
	[-i inst_name]
	[-o start_options]

srvctl stop service 
	-d database_unique_name 
	-s service_name_list 
	[-i inst_name]
	[-f] 			<< -- Desconecta todas las sesiones.

--------------------------------
-- Start / Stop / Status ASM
--------------------------------
-- Start asm
srvctl start asm 
	[-n node_list]
	[-o start_mode]
-- Stop asm
srvctl stop asm
	[-n node_list]
	[-o stop_mode]
-- Status asm
srvctl status asm
	[-n node_list]
---------------------------------------------------------
-- Habilitamos / Deshabilitamos recursos del cluster
---------------------------------------------------------

-- Enable / Disable database
	srvctl disable database -d moguland
	' ahora no funcionaria el comando srvctl start database'
	srvctl enable database -d moguland
-- Enable / Disable instance
	srvctl disable instance -d moguland -i moguland2
	' ahora al hacer un start database solo sube una instancia'
	srvctl enable instance -d moguland -i moguland2
-- Enable / Disabel service
	srvctl disable service -d moguland -s "lista_servicios" [ -i instance_name | -n node_name ]
	' si no indicamos la instancia lo deshabilita de todos los nodos donde este registrado'
	srvctl enable service -d moguland -s "lista_servicios" [ -i instance_name | -n node_name ]

-------------------------------------------------
-- Realocate services
-------------------------------------------------
	srvctl relocate service 
		-d db_unique_name 
		-s service_name
		{-c source_node -n target_node | -i old_instance_name -t new_instance_name}
		[-f]	<< -- Desconecta todas las sesiones

-------------------------------------------------
-- Remove configuration
-------------------------------------------------

-- Remove database
	srvctl remove database 
		-d db_unique_name 
		[-f] 		<< -- Force remove
		[-y]		<< -- No prompt
--Remove instance
	srvctl remove instance 
		-d db_unique_name 
		-i instance_name 
		[-f]		<< -- Evita checkeos, como por ejemplo si la instancia esta levantada
--Remove listener
	srvctl remove listener 
		[-l listener_name] 		<< -- Sino se expecifica utiliza LISTENER
		[-a] 					<< -- ALL listener configuration
		[-f]					<< -- Evita checkeos
--Remove service
	srvctl remove service 		
		-d db_unique_name 
		-s service_name 
		[-i instance_name] 
		[-f]					<< -- Borra el servicio aunque este corriendo

------------------------------------------
-- Set / Get Environment
------------------------------------------		

-- Set		
	srvctl setenv database 
		-d db_unique_name
		{-t "name=val[,name=val][...]" | -T "name=val"}	
		' -t introduces una lista, -T unicamente un valor'
		
--------------------------------------------		
-- Get Status
--------------------------------------------

-- Status database
	srvctl status database 
		-d db_unique_name 
		[-f] 		<< -- Incluye disabled options
		[-v]		<< -- Puede expresar opciones en progreso
	/*Ejemplo salida:	
		Instance moguland1 is running on node mogubedb11n1
		Instance moguland2 is disabled on node mogubedb11n2
		Instance moguland2 is not running on node mogubedb11n2
	*/	
-- Status instance
	srvctl status instance 
		-d db_unique_name 
			{-n node_name | -i "instance_name_list"}
		[-f]
		[-v]		
-- Status service
	srvctl status service 
		-d db_unique_name 
		[-s "service_name_list"] 
		[-f] 
		[-v]		
		
srvctl status service -d apps

----------------------------------------------
-- Get Configuration
----------------------------------------------
srvctl config service -d apps -s erp

----------------------------------------------
-- Resource
----------------------------------------------

-- Resource types

crsctl status type <type_name>
	[-f]		<< -- Muestra toda la informacion	 

-- Añade un tipo

crsctl add type app.appvip.type -basetype ora.cluster_vip.type

-- Añado un recurso asociado a ese tipo
crsctl add resource MiServidor -type app.appvip.type -file /home/oracle/list_attr.lst

cat /home/oracle/list_attr.lst
/*
RESTART_ATTEMPTS=2
START_TIMEOUT=100
STOP_TIMEOUT=100
CHECK_INTERVAL=10
USR_ORA_VIP=192.163.1.50
START_DEPENDENCIES=pullup(ora.net1.network) hard(ora.net1.network)
STOP_DEPENDENCIES=hard(ora.net1.network)
*/

'nota: ya solo faltaria levantar el recurso con crsctl start resource MiServidor'

-- Borramos un resource
crsctl delete resource check_resource.rsc 
	[-f]		<<< -- Borra el recurso aunque haya dependiencias
	
-- Ejemplo: script añadido como resource
/*
cat >/home/oracle/list_attr.lst                                               ||       #!/bin/bash
                                                                              ||       
NAME=check_resource.rsc                                                       ||       log_script=/home/oracle/log_resource.out
TYPE=cluster_resource                                                         ||       
ACL=owner:oracle:rwx,pgrp:oinstall:rwx,other::r--                             ||       case $1 in 
ACTION_SCRIPT=/home/oracle/my_Resource.sh                                     ||       'start') 
PLACEMENT=restricted                                                          ||       		echo "[`date +%T`] Start" >>$log_script
ACTIVE_PLACEMENT=0                                                            ||       ;; 
AUTO_START=restore                                                            ||       
CARDINALITY=1                                                                 ||       'clean') 
CHECK_INTERVAL=10                                                             ||       		echo "[`date +%T`] Clean" >>$log_script
DEGREE=1                                                                      ||       ;; 
ENABLED=1                                                                     ||       
HOSTING_MEMBERS=mogubedb11n1 mogubedb11n2                                     ||       
LOGGING_LEVEL=1                                                               ||       'check') 
RESTART_ATTEMPTS=1                                                            ||       		echo "[`date +%T`] Check" >>$log_script
START_DEPENDENCIES=hard(ora.moguland.db) pullup(ora.moguland.db)              ||       ;; 
START_TIMEOUT=600                                                             ||       'stop')
STOP_DEPENDENCIES=hard(ora.moguland.db)                                       ||       		echo "[`date +%T`] Stop" >>$log_script
STOP_TIMEOUT=600                                                              ||       ;;
UPTIME_THRESHOLD=1h                                                           ||       esac
*/

crsctl add resource check_resource.rsc -type cluster_resource -file /home/oracle/list_attr.lst
crsctl start resource check_resource.rsc

'nota: aqui veremos como nuestro script se levanta en un nodo y empieza a responder a check'

-- Sacamos las dependencias de un recurso

-----------------------------------------------------
-- CLUVFY
-----------------------------------------------------
-- Componentes

'nota lista los componentes a checkear'
> cluvfy comp -list
/*
      nodereach       : checks reachability between nodes
      nodecon         : checks node connectivity 
      cfs             : checks CFS integrity
      ssa             : checks shared storage accessibility
      space           : checks space availability
      sys             : checks minimum system requirements
      clu             : checks cluster integrity
      clumgr          : checks cluster manager integrity
      ocr             : checks OCR integrity
      olr             : checks OLR integrity
      ha              : checks HA integrity
      freespace       : checks free space in CRS Home
      crs             : checks CRS integrity
      nodeapp         : checks node applications existence
      admprv          : checks administrative privileges
      peer            : compares properties with peers
      software        : checks software distribution
      acfs            : checks ACFS integrity
      asm             : checks ASM integrity
      gpnp            : checks GPnP integrity
      gns             : checks GNS integrity
      scan            : checks SCAN configuration
      ohasd           : checks OHASD integrity
      clocksync       : checks Clock Synchronization
      vdisk           : checks Voting Disk configuration and UDEV settings
      healthcheck     : checks mandatory requirements and/or best practice recommendations
      dhcp            : checks DHCP configuration
      dns             : checks DNS configuration
*/

'nota comparamos crs en todos los nodos'
> cluvfy comp crs -n all -verbose

Dejar un comentario »

Aún no hay comentarios.

RSS feed for comments on this post. TrackBack URI

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

Crea un blog o un sitio web gratuitos con WordPress.com.

A %d blogueros les gusta esto: