2013年12月19日 星期四

Oracle system01.dbf空間過大, ORA-00604, ORA-01653, ORA-02002


1. 先看看sys.aud$的空間是否過大, 或是關閉oracle audit機制
alter system set audit_trail=none scope=spfile;
shutdown immediate;
truncate table sys.aud$;
startup;

2. 調整 system01.dbf的檔案大小
alter database datafile '/usr/local/oracle/oradata/ora11g2/system01.dbf' resize 2048M;
alter database datafile '/usr/local/oracle/oradata/ora11g2/system01.dbf' auto extend on next 10M maxsize unlimited;


ORA-28002 密碼過期


SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';

將預設180天改成無限制。
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

若不知密碼, 下面查出密碼,  再重新設定一次即可。
select password from $user where name='GS36_MSIG_POC_APP';
alter user GS36_MSIG_POC_APP identified by values '35EE9CA093003211';

2013年12月10日 星期二

Linux Boot Auto Start Oracle Oracle database & emctl

/etc/rc.d/rc.local 檔案內容
su - oracle -c "source /home/oracle/.bash_profile"
su - oracle -c "lsnrctl start"
sleep 5
su - oracle -c "echo startup |sqlplus \"/as sysdba\" "
su - oracle -c "lsnrctl set log_status off"
su - oracle -c " emctl start dbconsole"

2013年10月27日 星期日

SharePoint 2013 Backup Site

Set-ExecutionPolicy UnStricted
$ver = $host | select version
if ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home

$f = Get-Date -format "yyyyMMdd-HHmmss"
$f = "ins_"+$f+".bak";
Backup-SPSite http://sp2013.redirectme.net/sites/ins -Path \\wh01\SP2013Backup\$f
echo exit

2013年9月17日 星期二

Winodows 偵測網路線是否插上或拔下 .NET sample


using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Diagnostics;


namespace ConsoleApplication2
{


    class Program
    {
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        [System.Runtime.InteropServices.DllImport("User32.dll")]
        public static extern bool SetWindowText(IntPtr hwnd, string title);


     
        public static void callBatch(string batchcmd)
        {
           
            
            try
            {
  //              Process.Start(@"C:\\batch1.bat -option xmlfile.xml -text test");
                Process.Start(batchcmd);
            }
            catch (Exception ex)
            {
        //        MessageBox.Show(ex.ToString(), "Batch file failed" , MessageBoxButtons.OK);
                Console.WriteLine(ex.Message);
            }
        }
        private static void SetWindowText(string text)
        {
            var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
            IntPtr hWnd = currentProcess.MainWindowHandle;//FindWindow(null, "Your console windows caption"); //put your console window caption here
            if (hWnd != IntPtr.Zero)
            {
                //Hide the window
                SetWindowText(hWnd, text); // 0 = SW_HIDE
            }
        }
        private static void HideWindow()
        {
            var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
            IntPtr hWnd = currentProcess.MainWindowHandle;//FindWindow(null, "Your console windows caption"); //put your console window caption here
            if (hWnd != IntPtr.Zero)
            {
                //Hide the window
                ShowWindow(hWnd, 0); // 0 = SW_HIDE
            }
        }
        public static void Main(string[] args)
        {
            Console.Title = "DetectEthernet";
            SetWindowText("DetectEthernet");
            //String ethername = ConfigurationSettings.AppSettings["ethernet"];
            //string ethername=args[0];
            string batchcmd = args[0]; 
            
            // Network Interface: 乙太網路, Status: Up
            NetworkChange.NetworkAddressChanged += (s, e) =>
            {
                NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

                foreach (var item in nics)
                {
                    if(args.Contains(item.Name) && item.OperationalStatus==OperationalStatus.Up) // 乙太網路 && Up
                    {
                        callBatch(batchcmd);
                        break;
                    }
                    //Console.WriteLine("Network Interface: {0}, Status: {1}", item.Name, item.OperationalStatus.ToString());
                    
                }
            };

            string input = string.Empty;
            HideWindow();
            while (input != "quit")
            {
                input = Console.ReadLine();
            }

        }
    }
}

2013年7月26日 星期五

Configure Windows Server 2008/2012 To Sync With Internet Time Servers

net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"time-a.nist.gov, time-b.nist.gov, time-c.nist.gov, time-d.nist.gov"
w32tm /config /reliable:yes
net start w32time
w32tm /query /configuration

2013年7月25日 星期四

Linux Uninstal Oracle

Uninstalling all products from UNIX is a lot more consistent. If you do need to resort to a manual uninstall you should do something like:

* Uninstall all Oracle components using the Oracle Universal Installer (OUI).
* Stop any outstanding processes using the appropriate utilities:

# oemctl stop oms user/password
# agentctl stop
# lsnrctl stop

Alternatively you can kill them using the kill -9 pid command as the root user.
* Delete the files and directories below the $ORACLE_HOME:

# cd $ORACLE_HOME
# rm -Rf *

* With the exception of the product directory, delete directories below the $ORACLE_BASE.

# cd $ORACLE_BASE
# rm -Rf admin doc jre o*

* Delete the /etc/oratab file. If using 9iAS delete the /etc/emtab file also.

# rm /etc/oratab /etc/emtab
#rm -rf /usr/local/oracle
#rm -rf /etc/oraInst.loc

2013年7月24日 星期三

/etc/ntp.conf

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.

restrict time.stdtime.gov.tw
restrict tock.stdtime.gov.tw
restrict tick.stdtime.gov.tw
restrict clock.stdtime.gov.tw
restrict watch.stdtime.gov.tw 
restrict 127.0.0.1 
restrict -6 ::1
restrict 192.168.9.0 mask 255.255.255.0 nomodify
restrict 10.144.82.0 mask 255.255.255.0 nomodify
restrict 192.168.100.0 mask 255.255.255.0 nomodify

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server tick.stdtime.gov.tw prefer
server tock.stdtime.gov.tw prefer
server time.stdtime.gov.tw prefer
server clock.stdtime.gov.tw
server watch.stdtime.gov.tw

#broadcast 192.168.1.255 key 42  # broadcast server
#broadcastclient   # broadcast client
#broadcast 224.0.1.1 key 42  # multicast server
#multicastclient 224.0.1.1  # multicast client
#manycastserver 239.255.254.254  # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. 
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10 

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography. 
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8
啟動 ntp 伺服器
#service ntpd start

設定開機自動啟動
#chkconfig ntpd on

等候數分鐘後檢查是否有連上伺服器
#ntpstat

列出 NTP 和上層 NTP 的狀態
#ntpq -p
Client 端設定
#vi /etc/ntp.conf
restrict 192.168.*.*(server 端 ip)
server 192.168.*.*

設定開機自動啟動
#chkconfig ntpd on

OR

設定 crontab 方式
#vi /etc/crontab
0 * * * * root ntpdate time.stdtime.gov.tw
每小時0分對時一次

Linux 手動設定日期時間

date --set="23 June 1988 10:00:00"
date --set="10:00:00"

2013年7月23日 星期二

Android 4.0.4 compile

python2.7 ~bin/repo init -u http://git.android-x86.org/manifest -b ics-x86
repo sync
lunch eeepc-eng
make iso_img
裝 Python 2.7.3, 這個版本才能執行 repo
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2 
cd Python-2.7.3
./configure --prefix=/usr/local
make && make altinstall
/usr/local/bin/python2.7
curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo
python2.7 ~/bin/repo init

/etc/rc.d/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#KERNEL PARAMETER CONFIG BEGIN
echo 250 32000 100 128 > /proc/sys/kernel/sem
echo 4294967224 > /proc/sys/kernel/shmmax
echo 4096 > /proc/sys/kernel/shmmni
echo 2097152 > /proc/sys/kernel/shmall
echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
echo 262144 > /proc/sys/net/core/rmem_default
echo 262144 > /proc/sys/net/core/rmem_max
echo 262144 > /proc/sys/net/core/wmem_default
echo 262144 > /proc/sys/net/core/wmem_max
#KERNEL PARAMETER CONFIG END
#IP CONFIG BEGIN
#IP CONFIG END
#ENV STARTUP BEGIN
su - oracle -c "lsnrctl start"
sleep 5
su - oracle -c "echo startup |sqlplus \"/as sysdba\" "

su - oracle -c "lsnrctl set log_status off"
#/usr/local/gs36_gs_demo/IBM/HTTPServer/bin/apachectl start
#su - gs36_msig_poc -c 'cd /usr/local/gs36_gs_demo/IBM/WebSphere/AppServer/profiles/gs36_gs_demo;sh restart.sh'

#mount -t cifs //192.168.9.129/document /usr/local/gs36_gs_demo/IBM/WebSphere/AppServer/profiles/gs36_gs_demo/EBAO_ARCH_HOME/print_archive_data -o username=administrator,password=Ebaotech250,Domain=WIN-44TQ501NLG3,mode=777,uid=503,gid=504
mount -t cifs //192.168.9.129/print_archive_data  /home/ls36/domains/base_domain/ls36/EBAO_ARCH_HOME/document -o username=administrator,password=Ebaotech250,Domain=WORKGROUP,mode=777,uid=505,gid=505
su - ls36 -c 'source /home/ls36/.bash_profile;cd $BATCH_HOME;sh batch_manage.sh start; cd $DOMAIN_HOME; sh startWebLogic.sh'
#ENV STARTUP END

Linux Install Git

$ yum install curl-devel expat-devel gettext-devel \
  openssl-devel zlib-devel

$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
  libz-dev
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
tar xzvf git-latest.tar.gz
cd git-2013-07-3230 #您的目錄可能不是這個 
autoconf
./configure
make
sudo make install

2013年7月18日 星期四

VMWare Date Sync

xxxx.vmx tools.syncTime改為 True
usb:1.parent = "-1"
tools.syncTime = "TRUE"
ide1:0.autodetect = "TRUE"

2013年7月17日 星期三

eBao PASSWORD

eBao1234
3c4eee78457e3c9b0d2fa9ed9693e1dc
GS
 
?
ed06be42ae579b86a407a949b238021b
LS
ADMIN
?
c5718d5d761ef62b8e76c90864e93063
 
 


update t_user set password_change=sysdate where user_name='ADMIN';

Linux mount Windows共享目錄

mount -t cifs //192.168.9.129/print_archive_data  /home/ls36/domains/base_domain/ls36/EBAO_ARCH_HOME/document -o username=administrator,password=Ebaotech250,Domain=WORKGROUP,mode=777,uid=505,gid=505

2013年7月15日 星期一

LS 3.6 create user

sqlplus "/as sysdba"
SQL> @create_user.sql

CENTOS Install GNOME Desktop Environment

yum groupinstall 'GNOME Desktop Environment' -y

Install Oracle 11.2.0.3 /usr/local/oraInvetory

mkdir -p /usr/local/oracle /usr/local/oraInventory   /usr/local/oradata/
chown -R oracle:oinstall /usr/local/oracle /usr/local/oraInventory   /usr/local/oradata/
chmod -R 775 /usr/local/oracle 
chmod -R 775   /usr/local/oraInventory 
chmod -R 775   /usr/local/oradata/

2013年5月17日 星期五

解決 CLOSE_WAIT問題


netstat -n | awk '/^tcp/ {++S[$NF]}END{for(a in S) print a, S[a]}'

sysctl -w net.ipv4.tcp_keepalive_time=7200
sysctl -w net.ipv4.tcp_keepalive_probes=9
sysctl -w net.ipv4.tcp_keepalive_intvl=75


2013年4月18日 星期四

Linux ACL設定sample

userdel guest
useradd -g oinstall guest
passwd guest
setfacl -R -m g:oinstall:rxw /home/oracle
setfacl -R -m u:guest:rx /home/oracle

2013年4月11日 星期四

SQLPlus環境變數設定


將檔案Copy到一個目錄下,例如 c:\oracle10
然後設定以下環境變數:
PATH=%PATH%:c:\oracle10g   (PATH加上c:\oracle10g)
SQLPATH=c:\oracle10g
TNS_ADMIN=c:\oracle10g
NLS_LANG=AMERICAN_AMERICA.ZHT16BIG5

2013年3月18日 星期一

linux<->windows text file format

*.css;*.xpdl;*.tld;*.java;*.xspdl;*.xsd;*.xsl;*.xslt;*.esb;*.xhtml;*.xpdl*.xml; *.jsp; *.properties; *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; 

2013年2月21日 星期四

2013年2月17日 星期日

RHEL install Git

wget http://git-core.googlecode.com/files/git-1.8.1.3.tar.gz
tar xvsf git-*.gz  
yum install gcc
yum install zlib-devel
./configure
make
make install
vi ~/.wgetrc
.wgetrc 內容

    http_proxy = http://proxy.hinet.net:80/
    use_proxy = on
    wait = 15

2013年2月8日 星期五

JDBC url

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.144.82.137)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))

2013年2月7日 星期四

oracle expose from 11.2.0.1, import to 11.2.0.3

grant DBA to gsuser with admin option;
oracle 11.2.0.1
exp gsuser/gsuserpwd@orcl buffer=12800000 statistics=none consistent=y full=y file=./GS_342_INIT_TBS.dmp log=./exp_GS_342_INIT_TBS.log

oracle 11.2.0.3
imp gsuser/gsuserpwd@orcl buffer=12800000 statistics=none fromuser=gsuser touser=gsuser FULL IGNORE=y file=GS_342_INIT_TBS.dmp log=exp_GS_342_INIT_TBS.log
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@orcl ebao]$ echo $LANG
en_US.UTF-8
[oracle@orcl ebao]$ echo $NLS_LANG
AMERICAN_AMERICA.AL32UTF8
[oracle@orcl ebao]$
當有些table無法exp出來時, 該table可能是延遲建立 另外可以用下面的指令來避免table無法export的問題
select 'alter table '||table_name||' allocate extent;' from user_tables where SEGMENT_CREATED='NO';
打開/關閉 deferred segment creation
set deferred_segment_creation = [TRUE | FALSE]

2013年2月5日 星期二

Join的方法比較, inner join, left join, right join, outer join








準備資料

create table test1
(
 id number(1),
 name nvarchar2(10),
 phone nvarchar2(10)
);

create table test2
(
 id number(1),
 pid nvarchar2(10),
 country nvarchar2(10)
);


insert into test1 values(1, 'Mr.Wu', '0931123xxx');
insert into test1 values(2, 'Mr.Wang', '0932123xxx');
insert into test1 values(3, 'Mr.Lin', '0933123xxx');

insert into test2 values(1, '1', 'TW');
insert into test2 values(2, '1', 'US');
insert into test2 values(3, '2', 'Kaohsiung');
insert into test2 values(4, '3', 'Taipei');

2013年2月4日 星期一

Oracle系統環境有改時都要執行

exec dbms_stats.gather_system_stats('noworkload'); select * from sys.aux_stats$; exec dbms_stats.set_system_stats.. 可以設定 11g alter database backup controlfile to trace; -- trace select value from v$diag_info where name='Default Trace File'; -- 查詢 log file的位置 10g select spid from v$process where addr=(select paddr from v$session where sid = (select ...)); show parameter user_dump_dest;

Oracle 將 disable所有tables的constraint

先將 FK移除, 再移除其他的 constraint(如 primary key, null constraint等)
set pages 0
set echo off
spool 'c:\temp\disableConstranits.sql'
select 'Alter Table ' || table_name || ' disable constraint ' || constraint_name||';'  from DBA_constraints where constraint_type='R' and owner='DWUSER';
select 'Alter Table ' || table_name || ' disable constraint ' || constraint_name||';'  from DBA_constraints where constraint_type<>'R' and owner='DWUSER';
spool off
還原 constraint
set pages 0
set echo off
spool 'c:\temp\enableConstranits.sql'
select 'Alter Table ' || table_name || ' enable constraint ' || constraint_name||';'  from DBA_constraints where constraint_type<>'R' and owner='DWUSER';
select 'Alter Table ' || table_name || ' enable constraint ' || constraint_name||';'  from DBA_constraints where constraint_type='R' and owner='DWUSER';
spool off
查看執行的 processes
select * from V$PROCESS;

2013年1月23日 星期三

安裝 oracle 11.2.0.3 找不到 WFMLRSVCApp.ear

因只解壓 p10404530_112030_Linux-x86-64_1of7.zip 不會自動解壓 p10404530_112030_Linux-x86-64_2of7.zip 在 ./database的空間佔 2,639,787,887 bytes

Linux 作業系統(OS)版本

[root@ebao352 ~]# uname -a
Linux ebao352 2.6.18-339.el5 #1 SMP Mon Aug 27 15:42:17 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@ebao352 ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.9 Beta (Tikanga)
Kernel \r on an \m

[root@ebao352 ~]#

2013年1月16日 星期三

git 中文檔名問題

git config --global core.quotepath false
Warning: Your console font probably doesn't support Unicode. If you experience strange characters in the output, consider switching to a TrueType font such as Lucida Console!
git config --global core.autocrlf true
命令行中不能输入中文:修改 /etc/inputrc:
set output-meta on
set convert-meta off

2013年1月8日 星期二

Oracle RAC

Oracle Clusterware Network
  • 至少要二張網卡
  • intra網段與 inter網段要分開(

Interconnect網卡注意事項
  • 愈快愈好
  • NIC網卡要求命名要一致(否則可能會安裝失敗)
  • florcontrol: receive=on, transmit=off
  • 要支援  802.3ad
  • MTU要一致
  • UDP socket buffer
  • Jumbo frame:不是IEEE標準協定, 可能不同的網卡設定方式不同,主要是用在 NAS/iSCSI storage.
Oracle Clusterware Architecture
透過 OS init daemon
  • /etc/init.d/init.ohasd
  • ohasd.bin(啟動 ora root agent, cssd agent, ora agent)
  • /etc/inittab to restart ohasd
RAC 2~3用 Admin-Managed, 3~以上用 Policy Managed

1 server 只能在一個 server pool



2013年1月7日 星期一

EA SVN設定

svn checkout  /
C:\Program Files (x86)\WANdisco\Subversion>svn checkout svn://localhost:701/EA d
:\svn\ea
Checked out revision 4.

C:\Program Files (x86)\WANdisco\Subversion>

2013年1月6日 星期日

總帳

易保 Payment voucher 傳票 SunAccount 要交易檔+傳票 SunAccount回沖 vocher1

SVN

svnadmin create --fs-type fsfs "c:\Users\well\Documents\My Dropbox\svn\701"
svnserve.exe --listen-port 701 --listen-host localhost -d -r "c:\Users\well\Documents\My Dropbox\svn\701"
svn://localhost:701/ 
另一種啟動方式
svnserve.exe --service --listen-port 80 --listen-host 10.144.82.147 -r D:\repositories\repos1\" displayname= "SVN Service" depend=Tcpip start= auto
c:\Users\well\Documents\My Dropbox\svn\701\conf\svnserve.conf
anon-access = none
auth-access = write
password-db = passwd
c:\Users\well\Documents\My Dropbox\svn\701\conf\passwd
[users]
admin=adminpwd