ASM
Ir para navegação
Ir para pesquisar
Links
Comandos
RAW
Mapping multipath devices to RAW.
raw /dev/raw/raw20 /dev/mapper/ARCHIVE01 raw /dev/raw/raw21 /dev/mapper/ARCHIVE02 raw /dev/raw/raw22 /dev/mapper/ARCHIVE03
Removing RAW devices specifying major and minor with 0, zero.
raw /dev/raw/raw20 0 0 raw /dev/raw/raw21 0 0 raw /dev/raw/raw22 0 0
List new added devices.
[root@server raw]# pwd /dev/raw [root@server raw]# ls -l total 0 crw-rw---- 1 oracle oinstall 162, 20 Jan 27 15:38 raw20 crw-rw---- 1 oracle oinstall 162, 21 Jan 27 15:38 raw21 crw-rw---- 1 oracle oinstall 162, 22 Jan 27 15:38 raw22 crw-rw---- 1 oracle oinstall 162, 0 Jan 27 15:31 rawctl
60-raw.rules
Esta configuração traduz o dispositivo de blocos para um nome específico, podendo associar com o ID do SCSI e define a permissão para o usuário ORACLE.
- /etc/udev/rules.d/60-raw.rules
Configuração
Configurar UDEV para ASM com placa FusionIO/NVME
sequencia=8;iteracao=0;echo fio{a,b} | tr ' ' '\n' | while read placa; do controle=$(expr $sequencia \* $iteracao);seq 1 $sequencia| while read seqf;do echo ACTION==\"add\", KERNEL==\""$placa""$seqf"\", RUN+=\"/bin/raw /dev/raw/raw$(expr $seqf + $controle) %N\"; done;iteracao=$(expr $iteracao + 1);done;echo ACTION==\"add\", KERNEL==\"raw*\", OWNER=\"oracle\", GROUP=\"oinstall\", MODE=\"0660\"
# Enter raw device bindings here. # # An example would be: # ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N" # to bind /dev/raw/raw1 to /dev/sda, or # ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m" # to bind /dev/raw/raw2 to the device with major 8, minor 1. #KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_", NAME="asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660" ACTION=="add", KERNEL=="fioa1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", KERNEL=="fioa2", RUN+="/bin/raw /dev/raw/raw2 %N" ACTION=="add", KERNEL=="fioa3", RUN+="/bin/raw /dev/raw/raw3 %N" ACTION=="add", KERNEL=="fioa4", RUN+="/bin/raw /dev/raw/raw4 %N" ACTION=="add", KERNEL=="fiob1", RUN+="/bin/raw /dev/raw/raw5 %N" ACTION=="add", KERNEL=="fiob2", RUN+="/bin/raw /dev/raw/raw6 %N" ACTION=="add", KERNEL=="fiob3", RUN+="/bin/raw /dev/raw/raw7 %N" ACTION=="add", KERNEL=="fiob4", RUN+="/bin/raw /dev/raw/raw8 %N" ACTION=="add", KERNEL=="fioc1", RUN+="/bin/raw /dev/raw/raw9 %N" ACTION=="add", KERNEL=="fioc2", RUN+="/bin/raw /dev/raw/raw10 %N" ACTION=="add", KERNEL=="fioc3", RUN+="/bin/raw /dev/raw/raw11 %N" ACTION=="add", KERNEL=="fioc4", RUN+="/bin/raw /dev/raw/raw12 %N" ACTION=="add", KERNEL=="raw*", OWNER="oracle", GROUP="oinstall", MODE="0660"
- Reload das configs
udevadm control --reload-rules
Artigos
- https://bartsjerps.wordpress.com/2014/07/01/linux-udev-create-asm-disk-volumes/
- https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux
- https://fritshoogland.wordpress.com/2012/07/23/using-udev-on-rhel-6-ol-6-to-change-disk-permissions-for-asm/
- http://www.hhutzler.de/blog/configure-udev-rules-for-asm-devices/
- https://community.oracle.com/thread/2475124
Comandos
Formatar Discos
Em um servidor com ASM nunca executar o partprobe para todos os discos.
Pois o partprobe pode impactar nos discos ASM já em produção.
Sempre especificar o disco que o partprobe deve analisar a alteração de geometria.
parted /dev/mapper/ASM1 mklabel gpt parted /dev/mapper/ASM1 mkpart primary 2MB 100%
multipath -l | \
grep ^mpa | \
awk '{print $1}' | \
while read disco
do
echo parted $disco mklabel gpt
echo parted $disco mkpart primary 2MB 100%
echo partprobe $disco
done
Exemplo de saída:
parted /dev/mapper/mp-data24 mklabel gpt parted /dev/mapper/mp-data24 mkpart primary 2MB 100% partprobe /dev/mapper/mp-data24 parted /dev/mapper/mp-data25 mklabel gpt parted /dev/mapper/mp-data25 mkpart primary 2MB 100% partprobe /dev/mapper/mp-data25 parted /dev/mapper/mp-data26 mklabel gpt parted /dev/mapper/mp-data26 mkpart primary 2MB 100% partprobe /dev/mapper/mp-data26 parted /dev/mapper/mp-data27 mklabel gpt parted /dev/mapper/mp-data27 mkpart primary 2MB 100% partprobe /dev/mapper/mp-data27
Script automatico
#V1
lsblk -d -p | grep ^\/ | awk '{print $1}'| xargs -i echo {}| while read disco ; do parted $disco print 2> /dev/null| grep "Partition Table: unknown" > /dev/null; retorno=$?; if [ $retorno -eq 0 ]; then parted $disco mklabel gpt; parted $disco mkpart primary 2MB 100%; partprobe $disco; fi;done
#V2
lsblk -d -p | \
grep ^\/ | \
awk '{print $1}'| \
xargs -i echo {}| \
while read disco
do
parted $disco print 2> /dev/null| grep "Partition Table: unknown" > /dev/null
retorno=$?
if [ $retorno -eq 0 ]
then parted $disco mklabel gpt
parted $disco mkpart primary 2MB 100%
partprobe $disco
fi
done
Versão mais Simples
#!/bin/bash
function part() {
echo parted /dev/sd$1 mklabel gpt
echo parted /dev/sd$1 mkpart primary 2mb 100%
echo partprobe /dev/sd$1
}
echo b c d e f g h i j k | \
tr ' ' '\n' | \
while read valor
do
part $valor
done
Criar disco no ASM
/etc/init.d/oracleasm createdisk DISK17 /dev/mapper/mpasm19p1
Identificar Discos
[root@oracle rules.d]# lsblk /dev/fioa NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fioa 250:0 0 2,9T 0 disk ├─fioa1 250:1 0 93,1G 0 part ├─fioa2 250:2 0 93,1G 0 part ├─fioa3 250:3 0 93,1G 0 part ├─fioa4 250:4 0 93,1G 0 part ├─fioa5 250:5 0 93,1G 0 part ├─fioa6 250:6 0 465,7G 0 part ├─fioa7 250:7 0 465,7G 0 part ├─fioa8 250:8 0 465,7G 0 part ├─fioa9 250:9 0 465,7G 0 part └─fioa10 250:10 0 465,7G 0 part [root@oracle rules.d]# grep fioa1 /etc/udev/rules.d/60-raw.rules ACTION=="add", KERNEL=="fioa1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", KERNEL=="fioa10", RUN+="/bin/raw /dev/raw/raw10 %N"
oracleasm
querydisk
Listar discos /etc/init.d/oracleasm listdisks | xargs -i /etc/init.d/oracleasm querydisk -p {} Disk "DISK01" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM01p1: LABEL="DISK01" TYPE="oracleasm" Disk "DISK02" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM02p1: LABEL="DISK02" TYPE="oracleasm" Disk "DISK03" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM03p1: LABEL="DISK03" TYPE="oracleasm" Disk "DISK04" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM04p1: LABEL="DISK04" TYPE="oracleasm" Disk "DISK05" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM05p1: LABEL="DISK05" TYPE="oracleasm" Disk "DISK06" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM06p1: LABEL="DISK06" TYPE="oracleasm" Disk "DISK07" is a valid ASM disk /dev/mapper/vg_dgoracle-ASM07p1: LABEL="DISK07" TYPE="oracleasm" . . . [root@oracle rules.d]# oracleasm querydisk -d DISK01 Disk "DISK01" is a valid ASM disk on device [251,27] [root@oracle rules.d]# dmsetup ls | grep 251| grep 27 vg_oracle-ASM01p1 (251:27)
Scripts
Space used in ASM Disk Groups
SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN group_name FORMAT a20 HEAD 'Disk Group|Name' COLUMN sector_size FORMAT 99,999 HEAD 'Sector|Size' COLUMN block_size FORMAT 99,999 HEAD 'Block|Size' COLUMN allocation_unit_size FORMAT 999,999,999 HEAD 'Allocation|Unit Size' COLUMN state FORMAT a11 HEAD 'State' COLUMN type FORMAT a6 HEAD 'Type' COLUMN total_mb FORMAT 999,999,999 HEAD 'Total Size (MB)' COLUMN used_mb FORMAT 999,999,999 HEAD 'Used Size (MB)' COLUMN pct_used FORMAT 999.99 HEAD 'Pct. Used' break on report on disk_group_name skip 1 compute sum label "Grand Total: " of total_mb used_mb on report SELECT name group_name , sector_size sector_size , block_size block_size , allocation_unit_size allocation_unit_size , state state , type type , total_mb total_mb , (total_mb - free_mb) used_mb , ROUND((1- (free_mb / total_mb))*100, 2) pct_used FROM v$asm_diskgroup ORDER BY name /
Disks contained within Disk Groups
SET ECHO OFF SET FEEDBACK 6 SET HEADING ON SET LINESIZE 180 SET PAGESIZE 50000 SET TERMOUT ON SET TIMING OFF SET TRIMOUT ON SET TRIMSPOOL ON SET VERIFY OFF CLEAR COLUMNS CLEAR BREAKS CLEAR COMPUTES COLUMN disk_group_name FORMAT a25 HEAD 'Disk Group Name' COLUMN disk_file_path FORMAT a20 HEAD 'Path' COLUMN disk_file_name FORMAT a20 HEAD 'File Name' COLUMN disk_file_fail_group FORMAT a20 HEAD 'Fail Group' COLUMN total_mb FORMAT 999,999,999 HEAD 'File Size (MB)' COLUMN used_mb FORMAT 999,999,999 HEAD 'Used Size (MB)' COLUMN pct_used FORMAT 999.99 HEAD 'Pct. Used' BREAK ON report ON disk_group_name SKIP 1 COMPUTE sum LABEL "" OF total_mb used_mb ON disk_group_name COMPUTE sum LABEL "Grand Total: " OF total_mb used_mb ON report SELECT NVL(a.name, '[CANDIDATE]') disk_group_name , b.path disk_file_path , b.name disk_file_name , b.failgroup disk_file_fail_group , b.total_mb total_mb , (b.total_mb - b.free_mb) used_mb , ROUND((1- (b.free_mb / b.total_mb))*100, 2) pct_used FROM v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number) ORDER BY a.name /
List of ASM files as well as its volume information
SET ECHO OFF SET FEEDBACK 6 SET HEADING ON SET LINESIZE 180 SET PAGESIZE 50000 SET TERMOUT ON SET TIMING OFF SET TRIMOUT ON SET TRIMSPOOL ON SET VERIFY OFF CLEAR COLUMNS CLEAR BREAKS CLEAR COMPUTES COLUMN full_path FORMAT a75 HEAD 'ASM File Name / Volume Name / Device Name' COLUMN system_created FORMAT a8 HEAD 'System|Created?' COLUMN bytes FORMAT 9,999,999,999,999 HEAD 'Bytes' COLUMN space FORMAT 9,999,999,999,999 HEAD 'Space' COLUMN type FORMAT a18 HEAD 'File Type' COLUMN redundancy FORMAT a12 HEAD 'Redundancy' COLUMN striped FORMAT a8 HEAD 'Striped' COLUMN creation_date FORMAT a20 HEAD 'Creation Date' COLUMN disk_group_name noprint BREAK ON report ON disk_group_name SKIP 1 COMPUTE sum LABEL "" OF bytes space ON disk_group_name COMPUTE sum LABEL "Grand Total: " OF bytes space ON report SELECT CONCAT('+' || db_files.disk_group_name, SYS_CONNECT_BY_PATH(db_files.alias_name, '/')) full_path , db_files.bytes , db_files.space , NVL(LPAD(db_files.type, 18), '<DIRECTORY>') type , db_files.creation_date , db_files.disk_group_name , LPAD(db_files.system_created, 4) system_created FROM ( SELECT g.name disk_group_name , a.parent_index pindex , a.name alias_name , a.reference_index rindex , a.system_created system_created , f.bytes bytes , f.space space , f.type type , TO_CHAR(f.creation_date, 'DD-MON-YYYY HH24:MI:SS') creation_date FROM v$asm_file f RIGHT OUTER JOIN v$asm_alias a USING (group_number, file_number) JOIN v$asm_diskgroup g USING (group_number) ) db_files WHERE db_files.type IS NOT NULL START WITH (MOD(db_files.pindex, POWER(2, 24))) = 0 CONNECT BY PRIOR db_files.rindex = db_files.pindex UNION SELECT '+' || volume_files.disk_group_name || ' [' || volume_files.volume_name || '] ' || volume_files.volume_device full_path , volume_files.bytes , volume_files.space , NVL(LPAD(volume_files.type, 18), '<DIRECTORY>') type , volume_files.creation_date , volume_files.disk_group_name , null FROM ( SELECT g.name disk_group_name , v.volume_name volume_name , v.volume_device volume_device , f.bytes bytes , f.space space , f.type type , TO_CHAR(f.creation_date, 'DD-MON-YYYY HH24:MI:SS') creation_date FROM v$asm_file f RIGHT OUTER JOIN v$asm_volume v USING (group_number, file_number) JOIN v$asm_diskgroup g USING (group_number) ) volume_files WHERE volume_files.type IS NOT NULL / <pre> ==Disks performance metric== <pre> SET ECHO OFF SET FEEDBACK 6 SET HEADING ON SET LINESIZE 256 SET PAGESIZE 50000 SET TERMOUT ON SET TIMING OFF SET TRIMOUT ON SET TRIMSPOOL ON SET VERIFY OFF CLEAR COLUMNS CLEAR BREAKS CLEAR COMPUTES COLUMN disk_group_name FORMAT a20 HEAD 'Disk Group Name' COLUMN disk_path FORMAT a20 HEAD 'Disk Path' COLUMN reads FORMAT 999,999,999,999 HEAD 'Reads' COLUMN writes FORMAT 999,999,999,999 HEAD 'Writes' COLUMN read_errs FORMAT 999,999,999 HEAD 'Read|Errors' COLUMN write_errs FORMAT 999,999,999 HEAD 'Write|Errors' COLUMN read_time FORMAT 999,999,999,999 HEAD 'Read|Time' COLUMN write_time FORMAT 999,999,999,999 HEAD 'Write|Time' COLUMN bytes_read FORMAT 999,999,999,999,999 HEAD 'Bytes|Read' COLUMN bytes_written FORMAT 999,999,999,999,999 HEAD 'Bytes|Written' BREAK ON report ON disk_group_name SKIP 2 COMPUTE sum LABEL "" OF reads writes read_errs write_errs read_time write_time bytes_read bytes_written ON disk_group_name COMPUTE sum LABEL "Grand Total: " OF reads writes read_errs write_errs read_time write_time bytes_read bytes_written ON report SELECT a.name disk_group_name , b.path disk_path , b.reads reads , b.writes writes , b.read_errs read_errs , b.write_errs write_errs , b.read_time read_time , b.write_time write_time , b.bytes_read bytes_read , b.bytes_written bytes_written FROM v$asm_diskgroup a JOIN v$asm_disk b USING (group_number) ORDER BY a.n
Colocando o ASM on-line
- ATENÇÃO.
ESTE PROCEDIMENTO SERVE PARA SUBIR O ASM EM AMBIENTE CLONADO.
EXECUTAR O MESMO EM PRODUÇÃO VAI FODER A PORRA TODA !!!
-- COMM ROOT
-- Arrumar /etc/hosts com o novo hostname
-- Executar scripts
Com root:
/u01/app/12.1.0/grid_0200/crs/install/roothas.sh -deconfig -force
/u01/app/12.1.0/grid_0200/crs/install/roothas.sh
-- COM ORACLE
. .profile_+ASM
crsctl start res ora.cssd -init
srvctl add asm
srvctl start asm
-- Entrar no sqlplus
sqlplus / as sysasm
alter diskgroup ALL mount;
--- Caso ALL MOUNT não funcione
---- Verificar Alert.log
less $ORACLE_BASE/diag/asm/<instance_name_minusculo>/<instance_name_maiusculo>/trace/alert(completa com tab)
shift+G
-- Pegar o nome do diskgroup
?diskgroup
-- Entrar no sqlplus
sqlplus / as sysasm
-- Montar o diskgroup
alter diskgroup <nome> mount;
--OBS: Caso algum passo não funcione, acionar o DBA mais próximo e acertar o valor para a consultoria.