2012年12月18日 星期二

一種簡單觀察OS之監控工具

http://pkgs.repoforge.org/dstat/
[root@gs35db ebao]# rpm -Uvh dstat-0.7.2-1.el5.rfx.noarch.rpm
警告:dstat-0.7.2-1.el5.rfx.noarch.rpm: 表頭 V3 DSA 簽名:NOKEY, key ID 6b8d79e6
正在準備…             ########################################### [100%]
   1:dstat                  ########################################### [100%]
[root@gs35db ebao]#dstat -cdlmnpsy
Terminal width too small, trimming output.
----total-cpu-usage---- -dsk/total- ---load-avg--- ------memory-usage----->
usr sys idl wai hiq siq| read  writ| 1m   5m  15m | used  buff  cach  free>
  0   0  95   4   0   0| 167k   15k|   0    0    0| 142M 31.9M  321M 1514M>
  0   1  98   0   1   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0   168k|   0    0    0| 142M 31.9M  321M 1514M>
  0   1  99   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0  99   0   1   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   1  99   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0  99   0   1   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0   168k|   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   1  99   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0  99   0   0   1|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0  99   0   1   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   0 100   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>
  0   1  99   0   0   0|   0     0 |   0    0    0| 142M 31.9M  321M 1514M>

2012年12月14日 星期五

Unistall Oracle Database

rm -f /etc/oratab
rm -rf $ORACLE_HOME
rm -rf $ORACLE_BASE
rm -f /usr/local/bin/coraenv
rm -f /usr/local/bin/dbhome
rm -f /usr/local/bin/oraenv

2012年12月13日 星期四

oracle create user

drop user gsuser cascde;
drop user gsreaduser cascde;
drop user gsappuser cascde; 
drop role gs_read_role cascde;
drop role gs_app_role cascde;
CREATE USER gsuser IDENTIFIED BY gsuserpwd DEFAULT TABLESPACE GS_342_INIT_TBS TEMPORARY TABLESPACE GS_342_INIT_TBS_TMP profile DEFAULT quota unlimited on GS_342_INIT_TBS;
grant select on SYS.DBA_CONSTRAINTS to gsuser;
grant select on SYS.DBA_CONS_COLUMNS to gsuser;
grant select on SYS.DBA_DATA_FILES to gsuser;
grant select on SYS.DBA_OBJECTS to gsuser;
grant select on SYS.DBA_ERRORS to gsuser;
grant select on SYS.DBA_SOURCE to gsuser;
GRANT SELECT ON SYS.DBA_SEQUENCES to gsuser;  
grant select on SYS.DBA_SYNONYMS to gsuser;
grant select on SYS.DBA_TABLESPACES to gsuser;
grant select on SYS.DBA_TAB_COLUMNS to gsuser;
grant select on SYS.DBA_TAB_PRIVS to gsuser;
grant execute on SYS.DBMS_FLASHBACK to gsuser;
grant select on SYS.V_$MYSTAT to gsuser;
grant select on SYS.V_$PROCESS to gsuser;
grant select on SYS.V_$SESSION to gsuser;
grant select on sys.pending_trans$ to gsuser;
grant select on sys.dba_2pc_pending to gsuser;
grant select on sys.dba_pending_transactions to gsuser;
grant execute on sys.dbms_system to gsuser;
grant execute on sys.dbms_lock to gsuser;
grant execute on sys.dbms_lob to gsuser;
grant connect to gsuser;
grant javadebugpriv to gsuser;
grant javasyspriv to gsuser;
grant java_admin to gsuser;
grant alter session to gsuser;
grant create any synonym to gsuser;
grant drop any synonym to gsuser;
grant create cluster to gsuser;
grant create database link to gsuser;
grant create materialized view to gsuser;
grant create procedure to gsuser;
grant create sequence to gsuser;
grant create session to gsuser;
grant create table to gsuser;
grant create trigger to gsuser;
grant create type to gsuser;
grant create view to gsuser;
grant debug connect session to gsuser;
grant execute any procedure to gsuser;
CREATE USER gsreaduser IDENTIFIED BY gsreaduserpwd DEFAULT TABLESPACE GS_342_INIT_TBS TEMPORARY TABLESPACE GS_342_INIT_TBS_TMP profile DEFAULT;
create role gs_read_role;
grant alter session to gs_read_role;
grant create session to gs_read_role;
grant gs_read_role to gsreaduser;
CREATE USER gsappuser IDENTIFIED BY gsappuserpwd DEFAULT TABLESPACE GS_342_INIT_TBS TEMPORARY TABLESPACE GS_342_INIT_TBS_TMP profile DEFAULT;
create role gs_app_role;
grant gs_read_role to gs_app_role;
grant gs_app_role to gsappuser;
grant DBA to gsuser with admin option;

Oracle Ports for Network Services

Oracle Ports for Network Services

  • An asterisk * in the Notes field indicates that the ports are IANA registered.
Service TCP UDP Notes
sql*net 66 66 * Oracle SQL*NET. I think this is legacy. I haven't seen it used.
SQL*Net 2 1521 1521 Probably the most common Oracle port. Not registered to Oracle, IANA registered for ncube-lm, nCube License Manager.
SQL*Net 1 1525 1525 * Registered as orasrv. No longer used?
listener port 1526 1526 1526 is also a popular Oracle listener port, but it is also not IANA registered. In the IANA list, it is pdap-np, Prospero Data Access Prot non-priv.
tlisrv 1527 1527 *
coauthor 1529 1529 *
Oracle Remote Data Base 1571 1571 * rdb-dbs-disp
oraclenames 1575 1575 * Default and officially registered listening port for client connections to an Oracle Names server using TCP/IP or TCP/IP with SSL. Deprecated in 9i and above, you're supposed to use LDAP instead.
Oracle Net8 Cman 1630 1630 * oraclenet8cman. Default and officially registered listening port for client connections to Oracle Connection Manager
oracle-em1 1748 1748 *
oracle-em2 1754 1754 *
Oracle-VP2 1808 1808 *
Oracle-VP1 1809 1809 *
Oracle Net8 CMan Admin 1830 1830 * net8-cman. Default and officially registered listening port for administrative commands to Oracle Connection Manager
oracle?
2005 * registered as "berknet" for 2005 TCP, oracle for 2005 UDP
Oracle GIOP 2481 2481 * giop
Oracle GIOP SSL 2482 2482 * giop-ssl
Oracle TTC 2483 2483 * ttc. Oracle may use this port to replace 1521 in future.
Oracle TTC SSL 2484 2484 * ttc-ssl.
OEM Agent 3872 3872 * oem-agent
Oracle RTC-PM port 3891 3891 * rtc-pm-port
Oracle dbControl Agent 3938 3938 * dbcontrol_agent

Although incomplete, this is a pretty good article on the mess that is Oracle ports: Connecting with Oracle: Oracle Ports.
I also got some information from these copies of Oracle documentation Oracle9i Net Services Reference Guide Release 2 (9.2) and Oracle Database Net Services Reference Guide 10g Release 1 (10.1)
The Oracle Technology Network (OTN) should provide all the information you need, but I find it difficult to locate things there.

Oracle 9iAS TCP/IP Ports

9iAS is a port nightmare. A typical install may have dozens of ports open. Many of the ports are not IANA-registered.
The document Oracle® Collaboration Suite Installation and Configuration Guide Release 2 Default Port Numbers and Port Ranges was the best reference I could find to the many many Oracle ports used. I have only listed the HTTP parts in the table below.
Service default TCP Notes
Oracle HTTP Server SSL or Oracle9iAS Web Cache HTTP Listen SSL 4443 This port is IANA-registred for "Pharos".
Oracle HTTP Server SSL 4444 The HTTP server SSL will move to 4444 if the Web Cache is running on 4443. This port is IANA-registered for "KRB524".
Oracle HTTP Server non-SSL or Oracle9iAS Web Cache HTTP Listen non-SSL 7777 This port is IANA-registered for "cbt" by cs.ucl.ac.uk
Oracle HTTP Server non-SSL 7778 The HTTP server will move to 7778 if the Web Cache is running on 7777. This port is IANA-registered for "Interwise".

Summary

For the HTTP web server bits, Oracle likes to use 7777, 7778 and 7779. For SSL ("secure" encrypted communications, you may know it as HTTPs) they like to use 4443, 4444, 4445, 4446. These ports are already IANA assigned for other things.
An important security point that you should be aware of is that by default Oracle will create a helpful Ports page on your 9iAS server, listing all the ports it has assigned for everything. The URL will be /portlist Locally on your system, there will also be a file $ORACLE_HOME/install/portlist.ini listing all the port assignments made.
I link to the IANA list on my main TCP/IP ports page.

/etc/sysconfig/iptables

常用的 iptables 服務參數
 /etc/rc.d/init.d/iptables start           //啟動 iptables 服務
                           stop            //停止 iptables 服務
                           restart         //重新啟動 iptables 服務
                           status          //查看目前 iptables 規則
                           save            //將目前規則存入 iptables 設定檔
規則語法如下 [-io 網路介面] [-p 協定] [-m 模組] [-s 來源] [-d 目的地] [-j 政策]
    -i 網路介面:-i 為 in 網路介面就填 eth0... (用於 PREROUTING、INPUT、FORWARD)
    -o 網路介面:-o 為 out 網路介面就填 eth0... (用於 POSTROUTING、OUTPUT、FORWARD)
    -m 模組:state、mac、limit、owner、multiport...
    -p 協定:tcp、upd、icmp...
    -s 來源:可為 IP Address、IP 網段、網域名稱
        --sport:指定封包來源 Port、Port Range (配合 -p tcp、-p udp)
    -d 目的地:可為 IP、IP 網段、網域名稱
        --dport:指定封包目的地 Port、Port Range (配合 -p tcp、-p udp)
    -j 政策 / 目標:ACCEPT、DROP、REJECT、SNAT、DNAT、MASQUERADE、REDIRECT、RETURN...

Hyper-V Guest RHEL 6.3找不到 /dev/cdrom時

insmod /lib/modules/$(uname -r)/kernel/drivers/ata/ata_piix.ko

2012年12月12日 星期三

Oracle 11.2.01



# 11.2.0.1 Create the new groups and users.
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmadmin oracle
passwd oracle
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
/etc/sysctl.conf
fs.suid_dumpable = 1
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 = 1048586
[root@gs35db Oracle 11g]# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
fs.suid_dumpable = 1
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 = 1048586
[root@gs35db Oracle 11g]# /sbin/sysctl -a | grep net.core.wmem_max
net.core.wmem_max = 1048586
[root@gs35db Oracle 11g]#
/etc/security/limits.conf
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  4096
oracle              hard    nofile  65536
oracle              soft    stack   10240
# From Oracle Linux 5 DVD
cd /mnt/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh compat-libstdc++-33*.i386.rpm
rpm -Uvh elfutils-libelf*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgomp-4.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-libs*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
rpm -Uvh numactl-devel-*
/etc/selinux/config
SELINUX=disabled
mkdir -p /home/oracle/oracledb/u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /home/oracle/oracledb/u01
chmod -R 775 /home/oracle/oracledb/u01
/home/oracle/.bash_profile
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=gs35db; export ORACLE_HOSTNAME
ORACLE_UNQNAME=gs35db; export ORACLE_UNQNAME
ORACLE_BASE=/home/oracle/oracledb/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=gs35db; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
開始安裝
./runInstaller 
 

vi /etc/sysconfig/iptables
/etc/rc.d/init.d/iptables restart
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1158 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
https://10.144.82.137:1158/em/console