2016年3月29日 星期二

Oracle 10g CENTOS 6.4

CENTOS 6.4 裝好 選 minial desktop
因為要有桌面環境才能跑 oracle 的 UI

然後依據
http://www.cnblogs.com/mchina/archive/2013/03/08/2934473.html
http://blog.itpub.net/21256317/viewspace-776791/

關防火牆
# chkconfig iptables off
# chkconfig ip6tables off
# service iptables stop
# service ip6tables stop

關 SELinux
# vi /etc/selinux/config
修改 SELINUX=disabled
不重開的話 下 # setenforce 0


安裝需要的套件

用 yum 安裝需要的軟體
# yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat

# yum install libXp
# yum -y install libXp.i686 --setopt=protected_multilib=false
# yum -y install libXt.i686 --setopt=protected_multilib=false
# yum -y install libXtst.i686 --setopt=protected_multilib=false
裝 .i686 的軟體的時候要加 --setopt=protected_multilib=false
因為這時候系統裡面同時有 i686 跟 x64 的版本 . 套件管理系統會警告這件事

裝一下 nautilus 可以按右鍵開終端機 非必要
$ sudo yum install nautilus-open-terminal

建好 oracle10 帳號跟 dba 群組
把 oracle10 帳號的主群組設為 dba . (把原本的oracle10 群組拿掉)
用 
# id oracle10 確認
[root@db3 ~]# id oracle10
uid=500(oracle10) gid=500(dba) groups=500(dba)


把 redhat-release 換掉
# vim /etc/redhat-release
改成
redhat-4

改sysctl.conf
# vi /etc/sysctl.conf

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096

fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144

然後用 sysctl -p 載入新設定


改 limits.conf
# vi /etc/security/limits.conf  加入
oracle10  soft nproc 2047
oracle10  hard nproc 16384
oracle10  soft nofile 1024
oracle10  hard nofile 65536


改 login
# vi /etc/pam.d/login  加入
session required /lib64/security/pam_limits.so
session required pam_limits.so




改/etc/profile
# vi /etc/profile

if [ $USER = "oracle10" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
fi 

改 /ets/hosts
新增自己的ip跟別名
192.168.200.33  db3 


建立 oracle 安裝資料夾
# mkdir /oracle10
# mkdir /oracle10/102
# chown -R oracle10:dba /oracle10


** 以 oracle10 身份登入設定環境變數
$ cd /home/oracle
$ vi .bash_profile

ORACLE_BASE=/oracle10 
ORACLE_HOME=$ORACLE_BASE/102
ORACLE_SID=hisspn
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH

重讀設定檔
$ source /home/oracle10/.bash_profile

上傳並解壓縮安裝檔
$ unzip 10201_database_linux_x86_64.cpio.gz
$ cpio -idmv < 10201_database_linux_x86_64.cpio

設定 huge_tlb
# id oracle
uid=500(oracle10) gid=500(dba) groups=500(dba)
echo "500" > /proc/sys/vm/hugetlb_shm_group

開始安裝
$ cd database
$ export LANG=en_US   <-- 其他語系顯示的時候字型可能會爛掉
$ ./runInstaller

如果看不到跳出來的視窗,用 root 下
# export DISPLAY=:0.0
# xhost +


===================
錯誤
Exception in ...... /lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
# yum -y install libXp.i686
Exception in ...... /lib/i386/libawt.so: libXt.so.6: cannot open shared object file: No such file or directory
# yum -y install libXt.i686
Exception in ...... /lib/i386/libawt.so: libXtst.so.6: cannot open shared object file: No such file or directory
# yum -y install libXtst.i686
====================













安裝到一半會出現這個錯誤 聽說是bug 可以不用管它
Error in invoking target 'collector' of makefile '/oracle10/102/sysman/lib/ins_emdb.mk'.



開一個 root shell 下
/oracle10/oraInventory/orainstRoot.sh
/oracle10/102/root.sh




=======================================
問題處理
ORA-27125:unable to create shared memory segment
# id oracle10
uid=500(oracle10) gid=500(dba) groups=500(dba)
echo "500" >/proc/sys/vm/hugetlb_shm_group
=======================================

安裝 patch 
裝完 oracle 軟體之後如果沒建資料庫應該都是關著的
SQL> SHUTDOWN IMMEDIATE
$ emctl stop dbconsole
$ isqlplusctl stop
$ lsnrctl stop

$ unzip p8202632_10205_Linux-x86-64.zip
$ cd Disk1
$ ./runInstaller -ignoreSysPrereqs   <-- 等等會抱怨 OS 版本不對







再開一個 root shell 來跑
會問是否要覆蓋現有檔案


安裝完成



如果有先開好的 instance 的話

a. 更新数据字典

$ sqlplus / as sysdba;
SQL> STARTUP UPGRADE
SQL> SPOOL patch.log
SQL> @?/rdbms/admin/catupgrd.sql

等跑完

SQL> SPOOL OFF

b. 关闭并重启数据库

SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP

c. 编译无效PL/SQL包



SQL> @?/rdbms/admin/utlrp.sql

d. 检查升级是否成功,如果所有组件的status都是valid表示升级成功。



SQL> SELECT COMP_NAME, VERSION, STATUS FROM SYS.DBA_REGISTRY;

e. 检查是否有升级错误



SQL> select * from utl_recomp_errors;

f. 修改系统兼容性参数

SQL> alter system set compatible='10.2.0.4.0' scope=spfile;

SQL> SHUTDOWN



SQL> STARTUP

升级完成。







建立資料庫 instance
先確認 listener.ora 跟 tnsnames.ora  不然 listener 不正確會一直出現 ORA-12514

ref :
http://alexlucy99.blogspot.tw/2015/02/ora-12514-tns.html
http://blog.itpub.net/18841027/viewspace-1059866/
http://stackoverflow.com/questions/10786782/ora-12514-tnslistener-does-not-currently-know-of-service-requested-in-connect-d

在 $ORACLE_HOME/network/admin/

處理 listener.ora

$ vim listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /oracle10/102)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = db3)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

** 這樣是動態監聽 可以用
SQL> alter system register; 
進行手動註冊
靜態監聽則要把 SID 記在 listener.ora 裡

查詢 :
select value from v$parameter where name='service_names';
select instance_name from v_$instance;


處理 tnsnames.ora
$ vim tnsnames.ora

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

listener_hisspn =
 (ADDRESS = (PROTOCOL = TCP)(HOST = db3)(PORT = 1521))

hisspn =
(DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = db3)(PORT = 1521))
  (CONNECT_DATA =
    (SERVER = dedicated)
    (SERVICE_NAME = hisspn)
  )
)

然後用 dbca 建立新的 instance

ref : http://docs.oracle.com/cd/B16276_01/doc/server.102/b14196/install003.htm#BABJBDIF

$ export LANG=en_US
$ dbca



要自訂項目所以選 custom

這邊是設定 service name 跟 sid
依照需要設定 不一定要 host.domain


設定共同密碼 或是可以分開設
先單純用 FileSystem 

FlashRecovery 關掉
設定 archive log (這個可以在建起來之後再改)
這邊要依情況改 SGA
改 processes 

改 CHARSET 跟 NATIONAL CHARSET

這邊要改檔案位置到需要的地方




如果剛剛沒弄好 tnsnames.ora 跟 listener.ora 的話會出現這個 


2016年3月22日 星期二

CDS 自動掛載到一半

CDS做到一半死掉

會在 $ORACLE_HOME/dbs  底下有 pfile
(btw 掛載過後的 pfile 不會刪, 要自己去砍)

因為原始機器記憶體太大 掛載機用同樣的設定會把 mem + pgsp 都吃光

所以比照掛載機的 pfile 改記憶體相關設定

( 用 create pfile='檔案位置' from spfile; 建立 pfile)
ref : http://weicheng331.blogspot.tw/2009/05/oracle-spfile-pfile.html

-- 應該要開ticket回原廠 : 不只 SGA 其他的記憶體參數都應該要調?

改完記憶體設定值之後可以開 然後出現需要recovery

在掛載點上面有archivelog 可是不曉得怎樣用recovery指令下
參考 RMAN 的做法

export ORACLE_SID=hisspb
rman target /
set DBID=174216940
startup mount;
run { catalog start with '/hisspb/archivelog' noprompt; recover database; }

出現

RMAN> run { catalog start with '/hisspb/archivelog' noprompt; recover database; }

searching for all files that match the pattern /hisspb/archivelog
no files found to be unknown to the database

Starting recover at 16-03-22 09:46:57
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=2413 devtype=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:15

Finished recover at 16-03-22 09:49:12

然後

rman target /    

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Mar 22 09:50:31 2016

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: HISSPB (DBID=174216940, not open)

RMAN> run { catalog start with '/hisspb/archivelog' noprompt; recover database; }

using target database control file instead of recovery catalog
searching for all files that match the pattern /hisspb/archivelog
no files found to be unknown to the database

Starting recover at 16-03-22 09:50:45
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=2415 devtype=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:04

Finished recover at 16-03-22 09:51:12

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 03/22/2016 09:51:33
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

RMAN> alter database open ;                

database opened

RMAN>

-------------
DBID可以從原本那個DB 下 rman target /

rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Mar 22 09:47:01 2016

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: HISSP1 (DBID=174216940)

---------------
需要留意的

*.db_cache_size=0
*.db_files=10000
*.db_keep_cache_size=1577058304
*.java_pool_size=0
*.large_pool_size=0
*.pga_aggregate_target=105906176
*.sga_max_size=15101579312
*.sga_target=15101579312
*.shared_pool_size=0
*.sort_area_size=1024000
*.streams_pool_size=50331648

ref
http://docs.oracle.com/cd/A87860_01/doc/server.817/a76990/rmanreco.htm

https://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams193.htm#REFRN10256

http://oraclequirks.blogspot.tw/2008/04/ora-00821-specified-value-of-sgatarget.html

--------------------------
錯誤
LRM-00101: unknown parameter name 'memory_target'
LRM-00101: unknown parameter name 'memory_target'
ORA-00093: _shared_pool_reserved_min_alloc must be between 4000 and 0
ORA-01078: failure in processing system parameters

只設了 MEM 跟 SGA, 看起來其他的參數不會跟著動

stty: tcgetattr: A specified file does not support the ioctl system call.
這個不曉得為什麼




2016年3月2日 星期三

ArcSight 查詢方式

-- LTM LOG
登入->分析->搜尋

選查詢時間範圍
在搜尋欄填入條件

資料放在 name 及 message 欄
例
"172.22.206.12" AND NOT message ENDSWITH "js" AND NOT message ENDSWITH "css" AND NOT message ENDSWITH "gif" AND NOT message ENDSWITH "/" AND NOT message ENDSWITH "jpg"

2015年10月1日 星期四

CentOS 6 udev 改 NIC 名稱

see http://www.ichiayi.com/wiki/tech/udev

/etc/udev/rules.d/70-presistent-net.rules
會記錄 MAC ADDRESS 與 eth* 的對應

在 VM Template 可以
移掉 
 /etc/sysconfig/network-scripts/ifcfg-eth0 內的 UUID 以及 HWADDR
刪除 /etc/udev/rules.d/70-persistent-net.rules 這個檔案


臨時使用

ifconfig eth0 192.168.1.x netmask 255.255.255.0
ifconfig eth0 up
route add default gw 192.168.1.254

2015年9月17日 星期四

tomcat 改 content.xml 之後壞掉


Cannot create JDBC driver of class '' for connect URL 'null'



As answered above, one solution is to move the entries to $CATALINA_BASE/conf/context.xml
In particular, "Copy the Context.xml file to tomcat/conf/Catalina/localhost folder and renaming it to <web_app_name>.xml"
The underlying cause could be due to a problem with file permissions: "The user under which tomcat was running did not have permission to write to these folders. So we changed the group ownership of tomcat and /etc/tomcat folder to the same group to which the tomcat user belonged and magically everything started working as before."
This solution seems 'cleaner' to me because you can then have your entire web app including database connection properties wrapped up in a .war file.











ref
http://stackoverflow.com/questions/7274722/cannot-create-jdbc-driver-of-class-for-connect-url-null