Estrutura do DBFS
- Fácil configuração;
- Gerenciado e configurado pelo DMA/DBA;
- Autoextensão do Filesystem;
- Backups simplificados e gerenciados pelo DBA/DMA;
- Disponibilidade das informações – Cluster.
- Performance pode ser comprometida;
- Necessita de um banco de dados adicional (SGA, Datafiles, etc…);
- Exige administração via Cluster (RAC) e não via SO;
- Exige configuração a nível de SO.
Configurando o DBFS no Oracle Exadata Database Machine
1. Pré-requisitos:
- Copiar arquivo dbs_group para o diretório $HOME do usuário root e diretório $HOME do usuário Oracle:
cat dbs_group
dm02db01 dm02db02 dm02db03 dm02db04 cp dbs_group /home/oracle cp dbs_group /root
- Criar equivalência para o usuário root entre todos os DBNODES:
/home/oracle> dcli -k -g dbs_group -l root root@dm02db01's password: root@dm02db02's password: root@dm02db03's password: root@dm02db04's password: dm02db01: ssh key added dm02db02: ssh key added dm02db03: ssh key added dm02db04: ssh key added
- Criar equivalência para o usuário Oracle entre todos os DBNODES:
- Setar $ORACLE_HOME e $ORACLE_BASE corretamente para o usuário Oracle:
2. Configuração do FUSE
- Adicionar FUSE (Executar como root)
(root)# dcli -g ~/dbs_group -l root usermod -a -G fuse oracle
- Criar o arquivo /etc/fuse.conf com a opção “user_allow_other”
(root)# dcli -g ~/dbs_group -l root "echo user_allow_other > /etc/fuse.conf" (root)# dcli -g ~/dbs_group -l root chmod 644 /etc/fuse.conf (root)# cat /etc/fuse.conf user_allow_other
- Criar e dar permissões ao ponto de montagem, nesse caso /u02
(root)# dcli -g ~/dbs_group -l root mkdir -p /u02 (root)# dcli -g ~/dbs_group -l root chown oracle:oinstall /u02
- Executar um re-start do Cluster para ativar a configuração do FUSE
(root)# dcli -g ~/dbs_group -l root /u01/app/11.2.0.3/grid/bin/crsctl stop crs -f (root)# dcli -g ~/dbs_group -l root /u01/app/11.2.0.3/grid/bin/crsctl start crs
3. Criação do Database DBFS
- Criar o banco de dados DBFS
############################################# # SCRIPT PARA CRIAR O DATABASE DBFS #!/bin/sh WHOAMI=`/usr/bin/whoami` ID=/usr/bin/id USER=`/usr/bin/id -u oracle` CURRID=`/usr/bin/id -u` if [ "X$USER" != "X$CURRID" ]; then echo "This should be run as oracle ($USER) but is being run by $WHOAMI - $CURRID" exit 1 fi export ORACLE_SID=dbfs export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:$ORACLE_HOME/bin /u01/app/oracle/product/11.2.0.3/db/bin/dbca -createDatabase -silent \ -gdbName dbfs \ -sid dbfs \ -sysPassword welcome1 \ -systemPassword welcome1 \ -emConfiguration LOCAL \ -dbsnmpPassword DBsnmp123 \ -sysmanPassword DBsnmp123 \ -diskGroupName 'DBFS_DG' \ -recoveryGroupName 'DBFS_DG' \ -storageType ASM \ -asmSysPassword welcome1 \ -nodelist 'dm02db01,dm02db02,dm02db03,dm02db04' \ -characterSet AL32UTF8 \ -nationalCharacterSet AL16UTF16 \ -databaseType MULTIPURPOSE \ -responseFile NO_VALUE \ -asmsnmpPassword welcome1 \ -templateName dbfsDBTemplate.dbt \ -redoLogFileSize 4096 #############################################
- Criar Tablespaces (Como usuário SYS ou SYSTEM)
(oracle)$ export ORACLE_SID=dbfs (oracle)$ sqlplus / as sysdba SQL> create bigfile tablespace dbfsts datafile '+DBFS_DG' size 32g autoextend on next 8g maxsize 1600g NOLOGGING EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO ; SQL> create user dbfs identified by Welc0me1 default tablespace dbfsts quota unlimited on dbfsts; SQL> grant create session, create table, create view, create procedure, dbfs_role to dbfs;
- Criar Objetos
(oracle)$ cd $ORACLE_HOME/rdbms/admin (oracle)$ sqlplus dbfs/Welc0me1 SQL> start dbfs_create_filesystem dbfsts FS1
4. Definição do LIBRARY PATH
(Executar como root)
(root)# dcli -g dbs_group -l root mkdir -p /usr/local/lib (root)# dcli -g dbs_group -l root ln -s /u01/app/oracle/product/11.2.0.3/dbhome_1/lib/libnnz11.so /usr/local/lib/libnnz11.so (root)# dcli -g dbs_group -l root ln -s /u01/app/oracle/product/11.2.0.3/dbhome_1/lib/libclntsh.so.11.1 /usr/local/lib/libclntsh.so.11.1 (root)# dcli -g dbs_group -l root ln -s /lib64/libfuse.so.2 /usr/local/lib/libfuse.so.2 (root)# dcli -g dbs_group -l root 'echo /usr/local/lib >> /etc/ld.so.conf.d/usr_local_lib.conf' (root)# dcli -g dbs_group -l root ldconfig
5. Definição do TNS_ADMIN e WALLET
- Criar o TNS_ADMIN para o DBFS ($HOME/dbfs/tnsadmin) (Executar como oracle)
(oracle)$ dcli -g dbs_group -l oracle mkdir -p $HOME/dbfs/tnsadmin
- Criar o arquivo ( $HOME/dbfs/tnsadmin/tnsnames.ora) apenas no DBNODE 1
dbm.local = (DESCRIPTION = (ADDRESS = (PROTOCOL=BEQ) (PROGRAM=/u01/app/oracle/product/11.2.0.3/dbhome_1/bin/oracle) (ARGV0=oracledbm1) (ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=BEQ)))') (ENVS='ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1,ORACLE_SID=dbm1') ) (CONNECT_DATA=(SID=dbm1)) )
- Criar o arquivo ($HOME/dbfs/tnsadmin/sqlnet.ora) apenas no DBNODE 1
WALLET_LOCATION = (SOURCE=(METHOD=FILE) (METHOD_DATA=(DIRECTORY=/home/oracle/dbfs/wallet)) ) SQLNET.WALLET_OVERRIDE = TRUE
- Copiar arquivos para todos os DBNODES
(oracle)$ dcli -g ~/dbs_group -l oracle -d $HOME/dbfs/tnsadmin -f $HOME/dbfs/tnsadmin/sqlnet.ora (oracle)$ dcli -g ~/dbs_group -l oracle -d $HOME/dbfs/tnsadmin -f $HOME/dbfs/tnsadmin/tnsnames.ora
- Criar um diretório WALLET
(oracle)$ mkdir -p $HOME/dbfs/wallet
- Criar um auto-login vazio
(oracle)$ mkstore -wrl $HOME/dbfs/wallet -create
- Criar as credenciais para o Wallet
(oracle)$ mkstore -wrl $HOME/dbfs/wallet -createCredential dbm.local dbfs Welc0me1
- Copiar arquivos Wallet para todos os DBNODES
(oracle)$ dcli -g ~/dbs_group -l oracle mkdir -p $HOME/dbfs/wallet (oracle)$ dcli -g ~/dbs_group -l oracle -d $HOME/dbfs/wallet -f $HOME/dbfs/wallet/ewallet.p12 (oracle)$ dcli -g ~/dbs_group -l oracle -d $HOME/dbfs/wallet -f $HOME/dbfs/wallet/cwallet.sso
- Executar um teste TNSPING
(oracle)$ dcli -g ~/dbs_group -l oracle "export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1; export TNS_ADMIN=$HOME/dbfs/tnsadmin /u01/app/oracle/product/11.2.0.3/dbhome_1/bin/tnsping dbm.local | grep OK"
6. Adicionar serviço DBFS ao Cluster
- Configurar corretamente as varíaveis do script mount-dbfs.sh. Este script será utilizado pelo Cluster para realizar STOP/START do serviço DBFS.
DBNAME MOUNT_POINT DBFS_USER ORACLE_HOME (should be the RDBMS ORACLE_HOME directory) LOGGER_FACILITY (used by syslog to log the messages/output from this script) MOUNT_OPTIONS DBFS_PASSWD (used only if WALLET=false) DBFS_PWDFILE_BASE (used only if WALET=false) WALLET (must be true or false) TNS_ADMIN (used only if WALLET=true) DBFS_LOCAL_TNSALIAS
- Copiar o script (/tmp/mount-dbfs.sh) devidamente parametrizado para (GI_HOME/crs/script)
(root)# dcli -g ~/dbs_group -l root -d /u01/app/11.2.0.3/grid/crs/script -f /tmp/mount-dbfs.sh (root)# dcli -g ~/dbs_group -l root chown oracle:oinstall /u01/app/11.2.0.3/grid/crs/script/mount-dbfs.sh (root)# dcli -g ~/dbs_group -l root chmod 750 /u01/app/11.2.0.3/grid/crs/script/mount-dbfs.sh
- Registrar o serviço no cluster
##### start script add-dbfs-resource.sh #!/bin/bash ACTION_SCRIPT=/u01/app/11.2.0.3/grid/crs/script/mount-dbfs.sh RESNAME=dbfs_mount DBNAME=dbm DBNAMEL=`echo $DBNAME | tr A-Z a-z` ORACLE_HOME=/u01/app/11.2.0/grid PATH=$ORACLE_HOME/bin:$PATH export PATH ORACLE_HOME crsctl add resource $RESNAME \ -type local_resource \ -attr "ACTION_SCRIPT=$ACTION_SCRIPT, \ CHECK_INTERVAL=30,RESTART_ATTEMPTS=10, \ START_DEPENDENCIES='hard(ora.$DBNAMEL.db)pullup(ora.$DBNAMEL.db)',\ STOP_DEPENDENCIES='hard(ora.$DBNAMEL.db)',\ SCRIPT_TIMEOUT=300" ##### end script add-dbfs-resource.sh
(oracle)$ sh ./add-dbfs-resource.sh
(oracle)$: srvctl stop database -d dbm -f (oracle)$: srvctl start database -d dbm -f
- Verificar o status do serviço dbfs_mount
(oracle)$ $GRID_HOME/bin/crsctl stat res dbfs_mount -t -------------------------------------------------------------------------------- NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- dbfs_mount OFFLINE OFFLINE dm02db01 OFFLINE OFFLINE dm02db02 OFFLINE OFFLINE dm02db03 OFFLINE OFFLINE dm02db04
- Realizar start do serviço dbfs_mount
(oracle)$ <GI_HOME>/bin/crsctl start resource dbfs_mount CRS-2672: Attempting to start 'dbfs_mount' on 'dscbac05' CRS-2672: Attempting to start 'dbfs_mount' on 'dscbac06' CRS-2676: Start of 'dbfs_mount' on 'dscbac06' succeeded CRS-2676: Start of 'dbfs_mount' on 'dscbac05' succeeded (oracle)$ <GI_HOME>/bin/crsctl stat res dbfs_mount -t -------------------------------------------------------------------------------- NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- dbfs_mount ONLINE ONLINE dm02db01 ONLINE ONLINE dm02db02 ONLINE ONLINE dm02db03 ONLINE ONLINE dm02db04
- Verificar se o File System está online
(oracle)$ ssh dm02db01 df -h /u02 Filesystem Size Used Avail Use% Mounted on dbfs 1.5M 40K 1.4M 3% /u02 (oracle)$ ssh dm02db02 df -h /u02 Filesystem Size Used Avail Use% Mounted on dbfs 1.5M 40K 1.4M 3% /u02 (oracle)$ ssh dm02db03 df -h /u02 Filesystem Size Used Avail Use% Mounted on dbfs 1.5M 40K 1.4M 3% /u02 (oracle)$ ssh dm02db04 df -h /u02 Filesystem Size Used Avail Use% Mounted on dbfs 1.5M 40K 1.4M 3% /u02
A partir deste momento, o DBFS está configurado corretamente. Basta agora realizar alguns testes de escrita:
/u02/FS1> touch teste /u02/FS1> ls teste /u02/FS1> rm teste
(oracle)$ <GI_HOME>/bin/crsctl stop res dbfs_mount
Referências
Oracle® Database SecureFiles and Large Objects Developer’s Guide
11g Release 2 (11.2)
|