2018年6月5日 星期二

Oracle SCN 轉 Timestamp

REF:  http://www.eygle.com/archives/2007/01/scntimestamp_function.html


首先通过dbms_flashback.get_system_change_number 可以获得系统当前的SCN值:
SQL> col scn for 9999999999999
SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
--------------
8908390522972
通过scn_to_timestamp函数可以将SCN转换为时间戳:
SQL> select scn_to_timestamp(8908390522972) scn from dual;
SCN
---------------------------------------------------------------------------
05-JAN-07 10.56.30.000000000 AM
再通过timestamp_to_scn可以将时间戳转换为SCN:
SQL> select timestamp_to_scn(scn_to_timestamp(8908390522972)) scn from dual;
SCN
--------------
8908390522972
通过这两个函数,最终Oracle将SCN和时间的关系建立起来,在Oracle10g之前,是没有办法通过函数转换得到SCN和时间的对应关系的,一般可以通过logmnr分析日志获得。
但是这种转换要依赖于数据库内部的数据记录,对于久远的SCN则不能转换,请看以下举例:
SQL> select min(FIRST_CHANGE#) scn,max(FIRST_CHANGE#) scn from v$archived_log;
SCN SCN
------------------ ------------------
8907349093953 8908393582271
SQL> select scn_to_timestamp(8907349093953) scn from dual;
select scn_to_timestamp(8907349093953) scn from dual
*
ERROR at line 1:
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1
ORA-06512: at line 1

SQL> select scn_to_timestamp(8908393582271) scn from dual;
SCN
---------------------------------------------------------------------------
05-JAN-07 11.45.50.000000000 AM
-The End-

2018年5月30日 星期三

Excel 使用 KB/MB/GB/TB 進位

參考

https://social.technet.microsoft.com/Forums/en-US/1063a039-f26b-4bfe-a9eb-2704ae0575dc/format-for-kbmbgbtb?forum=excel

=IF(A1>1024*1024*1024,TRUNC(A1/1024/1024/1024,2)&" GB", IF(A1>1024*1024, ROUND(A1/1024/1024,0)&" MB", ROUND(A1/1024,0)&" KB"))

或是

Function ConvertByte(ByVal Value As Range) As String
Dim UOM As Variant
Dim i As Long
ConvertByte = Value.Value
UOM = Array("B", "KB", "GB", "TB", "PB", "EB", "ZB", "YB")
Do While CDbl(ConvertByte) >= 1024
  ConvertByte = ConvertByte / 1024
  i = i + 1
Loop
ConvertByte = Application.WorksheetFunction.RoundDown(ConvertByte, 2) & " " & Choose(i + 1, "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
End Function

要餵進去的是位置( A1 A2 A3 ... ) 不是數值 ( 1024,2048,4096 ... )

啟用

檔案  選項  自訂功能區 自訂功能區  啟用"開發人員"

點 "Visual Basic" 點  要的檔案  插入  模組   然後把FUNCTION貼上
就可以在函數那邊 = 使用





2018年4月3日 星期二

SAN Switch with JRE/JDK 8

問題:  “Failed to validate certificate. The application will not be executed”  

RSA < 1024 Key 強度不足被拒絕

參考
https://michlstechblog.info/blog/java-error-failed-to-validate-certificate-the-application-will-not-be-executed/

https://www.java.com/zh_TW/download/faq/release_changes.xml

在  java.security 把
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024

RSA keysize < 1024 這個註解掉


 問題 : com.brocade.web.secsan.SecureSANException: white space not allowed

https://community.brocade.com/t5/Fibre-Channel-SAN/Switch-Explorer-java-exceptions/td-p/60140/page/3

javaws http://[your switch ip address]/switchExplorer_installed.html

切到  jre 1.6 (1.5 跟 1.8 不支援 ) \bin\ 然後直接下 javaws

** 控制台\JAVA 要把 1.6 打開




2018年3月30日 星期五

sql server firewall

@echo =========  SQL Server Ports  ===================
@echo Enabling SQLServer default instance port 1433
netsh firewall set portopening TCP 1433 "SQLServer"
@echo Enabling Dedicated Admin Connection port 1434
netsh firewall set portopening TCP 1434 "SQL Admin Connection"
@echo Enabling conventional SQL Server Service Broker port 4022 
netsh firewall set portopening TCP 4022 "SQL Service Broker"
@echo Enabling Transact-SQL Debugger/RPC port 135
netsh firewall set portopening TCP 135 "SQL Debugger/RPC"
@echo =========  Analysis Services Ports  ==============
@echo Enabling SSAS Default Instance port 2383
netsh firewall set portopening TCP 2383 "Analysis Services"
@echo Enabling SQL Server Browser Service port 2382
netsh firewall set portopening TCP 2382 "SQL Browser"
@echo =========  Misc Applications  ==============
@echo Enabling HTTP port 80
netsh firewall set portopening TCP 80 "HTTP"
@echo Enabling SSL port 443
netsh firewall set portopening TCP 443 "SSL"
@echo Enabling port for SQL Server Browser Service's 'Browse' Button
netsh firewall set portopening UDP 1434 "SQL Browser"
@echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh firewall set multicastbroadcastresponse ENABLE


https://dotblogs.com.tw/rockchang/2014/04/14/144730

2018年3月9日 星期五

CentOS7 Oracle11 try 2




hostnamectl set-hostname oracle11
hostname oracle11

vim /etc/hosts
127.0.0.1   oracle11 localhost localhost.localdomain localhost4 localhost4.localdomain4

/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/groupadd -g 503 oper

/usr/sbin/useradd -u 502 -g oinstall -G dba,oper oracle


/etc/sysctl.conf
kernel.shmmni = 4096
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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


/etc/security/limits.conf
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000




#oracle .bash_profile
# ORACLE_HOME 跟 ORACLE_BASE 相同的話會擋下
export TMP=/worktmp
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/11g
export ORACLE_SID=hissp1
PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
alias cdob='cd $ORACLE_BASE'
alias cdoh='cd $ORACLE_HOME'
alias tns='cd $ORACLE_HOME/network/admin'
alias envo='env | grep ORACLE'

umask 022


-----------------------------------------------------------
yum install binutils -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libXext -y
yum install libXext.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y
yum install zlib-devel -y
yum install elfutils-libelf-devel -y


yum install unzip -y
yum install telnet -y
yum install  nfs-utils.x86_64 -y
yum install xorg-x11-utils-7.5-22.el7.x86_64 -y
yum install mksh.x86_64 -y
yum install epel-release.noarch -y
yum install rlwrap.x86_64 -y
-----------------------------------------------------------
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE}(%{ARCH})\n' binutils \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel
------------------------------------------------------------
  197  mkdir -p /oracle11
  199  chown oracle:oinstall /oracle11
  200  chmod 775 /oracle11

/etc/selinux/config
SELINUX=permissive

--------------------------------------------------------------
mkdir /oraInventory
chown -R oracle /oraInventory

----------------------------------------------------------------
安装oracle时报错memcpy@GLIBC_2.14未找到:

INFO: /lib64/libstdc++.so.5: undefined reference to `memcpy@GLIBC_2.14'
collect2: error: ld returned 1 exit status
INFO: make: *** [ctxhx] Error 1
INFO: End output from spawned process.
解决办法,先查看 /usr/lib64/libc.a是否存在:

ls /usr/lib64 | grep libc.a

如果查找不到先安装:glibc-static,如果有则略过此步

yum -y install glibc-static

修改oracle安装目录下 $ORACLE_HOME/ctx/lib/ins_ctx.mk
将

    ctxhx: $(CTXHXOBJ)
        $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK)
修改为:

    ctxhx: $(CTXHXOBJ)
        -static $(LINK_CTXHX) $(CTXHXOBJ) $(INSO_LINK) /usr/lib64/libc.a
然后点击retry通过

安装oracle时报错Error in invoking target 'agent nmhs':

Error in invoking target 'agent nmhs' of makefile '/data2/oracle/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'
解决办法:修改 $ORACLE_HOME/sysman/lib/ins_emagent.mk
将

$(MK_EMAGENT_NMECTL)

修改为

$(MK_EMAGENT_NMECTL) -lnnz11

然后点击retry通过

https://www.jianshu.com/p/2fda26a7edf1
----------------------------------------------------------------
/oraInventory/orainstRoot.sh
/oracle/11g/root.sh
---------------------------------------------------------------
vim /oracle/11203/sysman/lib/ins_emagent.mk
---------------------------------------------------------------
/oracle/11203/root.sh
--------------------------------------------------------------