terça-feira, 22 de outubro de 2013

RAPIDINHAS SQL ORACLE



// GERAR O SQL PARA DELETAR TODAS AS TABELAS DE UM USUÁRIO
select 'drop table '||table_name||' cascade constraints;' from user_tables;


// grant select para usuário específico
grant select on dono_da_tabela.tabela to usuario_que_recebe_a_permissao;


//  grant synonym para usuário específico
grant create synonym to usuario_que_recebe_a_permissao;

// criar sinônimo
create or replace synonym nome_do_sinonimo for dono_da_tabela.tabela;




// consulta lock


set heading on
       set pages 70
       set lines 150
       col wu format A18 head "USER aguardando..."
       col ws format A17 head "SID Aguardando... "
       col ws1 format A17 head "Serial Aguardando... "
       col wp format A17 head "PID Aguardando... "
       col hu format A17 head "-- USER Lockador --"
       col hs format A17 head "-- SID Lockador -- "
       col hs1 format A17 head "-- Serial Lockador -- "
       col hp format A17 head "-- PID Lockador --"


SELECT /*+ RULE */
 rpad(substr(A.USERNAME, 1, 15), 15, ' ') wu,
 rpad(substr(to_char(W.SID), 1, 12), 12, ' ') ws,
 rpad(substr(to_char(a.serial#), 1, 12), 12, ' ') ws1,
 rpad(substr(to_char(p1.spid), 1, 12), 12, ' ') wp,
 rpad(substr(B.USERNAME, 1, 15), 15, ' ') hu,
 rpad(substr(to_char(H.SID), 1, 12), 12, ' ') hs,
 rpad(substr(to_char(b.serial#), 1, 12), 12, ' ') hs1,
 rpad(substr(to_char(p2.spid), 1, 12), 12, ' ') hp
  FROM GV$SESSION B,
       GV$LOCK    H,
       GV$LOCK    W,
       GV$SESSION A,
       GV$process p1,
       GV$process p2
 WHERE H.LMODE <> 0
   AND H.LMODE <> 1
   AND W.REQUEST <> 0
   AND H.CTIME > 60
   AND B.USERNAME NOT IN ('PERFANALYSIS')
   AND H.TYPE = W.TYPE
   AND H.ID1 = W.ID1
   AND H.ID2 = W.ID2
   AND B.SID = H.SID
   AND B.INST_ID = H.INST_ID
   AND W.SID = A.SID
   AND W.INST_ID = A.INST_ID
   AND A.paddr = P1.addr
   AND B.paddr = P2.addr
 ORDER BY H.ctime desc;

//LISTAR PERMISSÕES USUÁRIOS ORACLE

select * from (
select 'GRANT '||privilege||' TO '||grantee||';' from dba_sys_privs
where grantee in (SELECT USERNAME FROM DBA_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','SYSMAN','DBSNMP'))
union all
select 'grant '||privilege||' on '||grantor||'.'||table_name||' to '||grantee||';' from dba_tab_privs
where grantee in (SELECT USERNAME FROM DBA_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','SYSMAN','DBSNMP'))
union all
select 'GRANT '||GRANTED_ROLE||' TO '||grantee||';' from dba_role_privs
where grantee in (SELECT USERNAME FROM DBA_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','SYSMAN','DBSNMP')));



// VERIFICA INSTANCIA

SELECT * FROM GLOBAL_NAME;


// VERIFICAR QUAIS SÃO OS USUÁRIOS DO SISTEMA

SELECT USERNAME FROM DBA_USERS WHERE USERNAME LIKE ‘USER%‘;


//VERIFICAR SE TEM ALGUM USUÁRIO USANDO O SISTEMA

SELECT SADDR, SID, USERNAME, LOGON_TIME, STATUS, OSUSER, MACHINE, PROGRAM FROM V$SESSION WHERE USERNAME LIKE 'USER%';



quarta-feira, 21 de agosto de 2013

ALTERAR DOMÍNIO WORDPRESS

UPDATE wp_options SET option_value = replace(option_value, 'http://SiteAtual.com.br/', 'http://novaurl/') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://SiteAtual.com.br/','http://novaurl/');

UPDATE wp_posts SET post_content = replace(post_content, 'http://SiteAtual.com.br/', 'http://novaurl/');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://SiteAtual.com.br/', 'http://novaurl/');

sexta-feira, 9 de agosto de 2013

CRIAR TABLESPACE E USUÁRIO ORACLE 10G

CREATE TABLESPACE meutablespace LOGGING DATAFILE ‘/oracle10/oradata/minhabase/meutablespace.dbf‘ SIZE 32m AUTOEXTEND ON NEXT 32m EXTENT MANAGEMENT LOCAL;


CREATE USER meuusuario IDENTIFIED BY minhasenha DEFAULT TABLESPACE MEUTABLESPACE QUOTA UNLIMITED ON  MEUTABLESPACE;

GRANT create session, alter session, select_catalog_role, execute_catalog_role, create table, create procedure, create view, create materialized view, create trigger, create sequence, create any directory, create type, create synonym, administer database trigger TO meuusuario;


sexta-feira, 14 de setembro de 2012

MONTAR COMPARTILHAMENTO WINDOWS COM LINUX

sudo apt-get install smbfs

mapear com usuário do domínio

editar /etc/sudoers

ALL ALL=(ALL) NOPASSWD:ALL




#!/bin/bash
mount -t smbfs -o username=foo,password=bar,workgroup=nomedominio,gid=foo,uid=foo //servidor/compartilhamento/ /pontodemontagem

terça-feira, 11 de setembro de 2012

INSTALAÇÃO ORACLE 11G


Manual Instalação oracle 11G Release 2
Sistema Operacional: Red Hat Enterprise 5
Autor: Artur Ferreira da Silva


Asianux Server 3, Oracle
Linux 5, and Red Hat
Enterprise Linux 5


yum install binutils.x86_64 compat-db.x86_64  compat-libstdc++-33.i386 compat-libstdc++-33.x86_64 elfutils-libelf.i386 elfutils-libelf.x86_64 gcc-c++.x86_64 gcc.x86_64 gdbm.x86_64 glibc-devel.i386 glibc-devel.x86_64 glibc-headers.x86_64 glibc.i686 glibc.x86_64 ksh.x86_64 libaio-devel.i386 libaio-devel.x86_64 libaio.i386 libaio.x86_64 libstdc++.i386 libstdc++.x86_64 libXp.i386 libXtst.i386 libXtst.x86_64 make.x86_64 setarch.x86_64 sysstat.x86_64 unixODBC.i386 unixODBC.x86_64 xorg-x11-utils.x86_64





#entrar como root e criar os grupos e usuários

useradd oracle
groupadd dba
groupadd oinstall
usermod -g oinstall -G dba oracle


2. configurar parametos do kernel

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

você precisa reiniciar ou sysctl -p

Edit the /etc/pam.d/login file and add following line:
session required pam_limits.so

Edit the /etc/security/limits.conf file and add following lines:

oracle    soft  nproc  2047
oracle    hard  nproc  16384
oracle    soft  nofile 1024
oracle    hard  nofile 65536
oracle    soft  stack  10240



# mkdir -p /u01/app/
# chown -R oracle:oinstall /u01/app/
# chmod -R 775 /u01/app/



3. Creating oracle directories
# mkdir /opt/oracle
# chown -R oracle:dba /opt/oracle

4. Setting Oracle Enviroment
Edit the /home/oracle/.bash_profile file and add following lines:

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/112
ORACLE_SID=crmdsv
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin



export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH

Save the .bash_profile and execute following commands for load new enviroment:
cd /home/oracle
. .bash_profile

Check current status of SELinux:
/usr/sbin/getenforce

If output is "Enforcing" then change mode to "Permissive" using following command:
/usr/sbin/setenforce 0

To prevent Enforcing mode restore after next reboots or to disable SELinux modify the /etc/sysconfig/selinux change value of SELINUX variable to permissive or disabled:
SELINUX=permissive


Important steps/workarounds for Centos 5 only!
# cp /etc/redhat-release /etc/redhat-release.old
# echo "Red Hat Enterprise Linux Server release 5 (Tikanga)" > /etc/redhat-release
#Â cp /etc/issue /etc/issue.old
# echo "Red Hat Enterprise Linux Server release 5 (Tikanga)" > /etc/issue
# echo "Kernel \r on an \m" >> /etc/issue
# echo "" >> /etc/issue
# echo "redhat-release-5Server-5" > /tmp/.linux_release


quarta-feira, 2 de maio de 2012

SQUID + AD 2008

redirect_program /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf

access_log /var/log/squid/access.log squid


auth_param basic children 5
auth_param basic realm  Proxy Server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
auth_param basic program /usr/lib/squid/squid_ldap_auth -R -b "dc=dominio,dc=net" -D "cn=Administrador,cn=Users,dc=dominio,dc=net" -w "senha" -f sAMAccountName=%s -h ipdoad
external_acl_type ldap_group %LOGIN /usr/lib/squid/squid_ldap_group -R -b "dc=MJV,dc=net" -D "cn=Administrador,cn=Users,dc=dominio,dc=net" -w "senha" -f "(&(objectclass=person)(sAMAccountName=%v)(memberof=cn=%a,ou=internet,dc=dominio,dc=net))" -h ipdoad




#Recommended minimum configuration:
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
acl localnet src 172.21.0.0/24  # RFC1918 possible internal network
#acl localnet src 192.168.0.0/24        # RFC1918 possible internal network
#
acl rh external ldap_group rh
acl inovar external ldap_group inovar
acl AcessoFull external ldap_group AcessoFull

acl autenticacao proxy_auth REQUIRED
http_access allow localnet autenticacao
                                                                                                                  1,0-1         Top

sexta-feira, 26 de agosto de 2011

ENVIAR EMAIL COM ANEXO EM MODO TEXTO COM AUTENTICAÇÃO DO GMAIL

Primeiro é necessário ter um servidor de email instalado e configurado.




# yum install ssmtp
# yum remove sendmail

# vim /etc/ssmtp/ssmtp.conf

root=postmaster
mailhub=smtp.gmail.com:587
AuthUser=emaildogmail@gmail.com
AuthPass=senha
UseSTARTTLS=YES


# yum install sharutils

Ok! Instalamos o pacote sharutils e agora vamos usar o comando uuencode:

# uuencode /home/arq.conf arq.conf | mail -s "Conf Arq" euartur_silva@hotmail.com