2015年3月20日 星期五

Git Usage Example in Linux



[root@development-ricky git]# git init
Initialized empty Git repository in /home/ricky/NetBeansProjects/git/.git/
[root@development-ricky git]# git remote add eras git@10.32.26.205:eras/eras.git
[root@development-ricky git]# git pull eras development
remote: Counting objects: 6136, done.
remote: Compressing objects: 100% (3306/3306), done.
remote: Total 6136 (delta 3091), reused 5395 (delta 2529)
Receiving objects: 100% (6136/6136), 16.17 MiB | 30.23 MiB/s, done.
Resolving deltas: 100% (3091/3091), done.
From 10.32.26.205:eras/eras
 * branch            development -> FETCH_HEAD
[root@development-ricky git]# git branch
* master
[root@development-ricky git]# git checkout -b development
Switched to a new branch 'development'
[root@development-ricky git]# git branch
* development
  master

git commit -m 'temp commit'
git rebase -i HEAD~2

git push -f origin DEVELOPMENT


http://blog.gogojimmy.net/2012/02/29/git-scenario/


Git 情境劇

 | COMMENTS

Git 情境劇

這篇主要是給自己做個記錄,因為 Git 指令實在太多了…
  1. Git 教學(1):Git的基本使用
  2. Git 教學(2):Git Branch 的操作與基本工作流程
  3. 如何安裝 Git
    • Mac : 安裝 Homebrew
        brew install git
      
    • Linux(Debian) : apt-get install git-core
    • Linux(Fedora) : yum install git-core
    • Windows : 下載安裝 msysGit
  4. 如何設定 Git
  5. 如何開始一個 Git Respository
    • 在專案底下使用 git init 開始一個新的 Git repo.
    • 使用 git clone 複製一個專案
  6. 如何將檔案加入 Stage
    • 使用 git add 將想要的檔案加入 Stage.
    • git add . 會將所有編修過的檔案加入 Stage (新增但還沒 Commit 過的檔案並不會加入)
  7. 如何將檔案從 Stage 中移除(取消add)
    • git reset HEAD 檔案名稱
  8. 如何將檔案提交(commit)
    • 使用 git commit會將 Stage 狀態的檔案做 Commit 動作
    • git commit -m "commit訊息" 可以略過編輯器直接輸入 commit 訊息完成提交。
    • git commit -am "commit訊息" 等同於先git add .後略過編輯器提交 commit。
  9. 如何修改/取消上一次的 commit
    • git commit --amend 修改上一次的 commit 訊息。
    • git commit --amend 檔案1 檔案2... 將檔案1、檔案2加入上一次的 commit。
    • git reset HEAD^ --soft 取消剛剛的 commit,但保留修改過的檔案。
    • git reset HEAD^ --hard 取消剛剛的 commit,回到再上一次 commit的 乾淨狀態。
  10. 分支基本操作(branch)
    • git branch 列出所有本地端的 branch。
    • git branch -r 列出所有遠端的 branch。
    • git branch -a 列出所有本地及遠端的 branch。
    • git branch "branch名稱" 建立一個新的 branch。
    • git checkout -b "branch名稱" 建立一個新的 branch 並切換到該 branch。
    • git branch branch名稱 起始點 以起始點作為基準建立一個新的 branch,起始點可以是一個 tag,branch 或是 commit。
    • git branch --track branch名稱 遠端branch 建立一個 tracking 遠端 branch 的 branch,這樣以後 push/pull都會直接對應到該遠端的branch。
    • git branch --set-upstream branch 遠端branch 將一個已存在的 branch 設定成 tracking 遠端的branch。
    • git branch -d "branch 名稱" 刪除 branch。
    • git -r -d 遠端branch 刪除一個 tracking 的遠端 branch,例如git branch -r -d wycats/master
    • git push repository名稱 :遠端branch 刪除一個 repository 的 branch,通常用在刪除遠端的 branch,例如git push origin :old_branch_to_be_deleted
    • git checkout branch名稱 切換到另一個 branch(所有修改過程會被保留)。
  11. 遠端操作(remote)
    • git remote add remote名稱 remote網址 加入一個 remote repository,例如 git remote add github git://github.com/gogojimmy/test.git
    • git push remote名稱 :branch名稱 刪除遠端 branch,例如 git push origin :somebranch
    • git pull remote名稱 branch名稱 下載一個遠端的 branch 並合併(注意是下載遠端的 branch 合併到目前本地端所在的 branch)。
    • git push 類似於 pull 操作,將本地端的 branch 上傳到遠端。
  12. 合併操作(merge)
    • git merge branch名稱 合併指定的 branch 到目前的 branch。
    • git merge branch名稱 --no-commit 合併指定的 branch 到目前的 branch 但是不會產生合併的 commit。
    • git cherry-pick SHA 將某一個 commit 的內容合併到目前 branch,指定 commit 是使用該 commit 的 SHA 值,例如 git cherry-pick 7300a6130d9447e18a931e898b64eefedea19544
  13. 暫存操作(stash)
    • git stash 將目前所做的修改都暫存起來。
    • git stash apply 取出最新一次的暫存。
    • git stash pop 取出最新一次的暫存並將他從暫存清單中移除。
    • git stash list 顯示出所有的暫存清單。
    • git stash clear 清除所有暫存。
  14. 常見問題:
    • 我的 code 改爛了我想全部重來,我要如何快速回到乾淨的目錄?
      • git reset --hard 這指令會清除所有與最近一次 commit 不同的修改。
    • merge 過程中發生 confict 我想放棄 merge,要如何取消 merge?
      • 一樣使用 git reset --hard 可以取消這次的 merge。
    • 如何取消這次的 merge 回到 merge 前的狀態?
      • git reset --hard ORIG_HEAD 這指令會取消最近一次成功的 merge 以及所有你在這次 merge 後所做的修改。
    • 如何回復單獨檔案到原本 commit 的狀態?
      • git checkout 檔案名稱 這指令會將已經被修改過的檔案回復到最近一次 commit 的樣子。
  15. 其他連結:
  16. Git 教學(2):Git Branch 的操作與基本工作流程
  17. Git 情境劇:告訴你使用 Git 時什麼情況該下什麼指令

   git

2015年3月17日 星期二

Mount Windows Shared Folder Under Linux


https://access.redhat.com/solutions/448263

  • Windows share can be mounted on RHEL system using cifs option of mount command as :
  • [root@host ~]# mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt


mount -t cifs -o username=UC171820,password=Welcome6 //10.32.30.89/pulsefolder /mnt/pulsefolder

VMware tools 安裝說明

http://ithelp.ithome.com.tw/question/10101225

VMware tools 安裝說明
在安裝VMware tools 時VM虛擬機要開機,才可安裝。

1. 先開啟VMware vSphere Client
然後開啟要安裝Tools VM主機的Console
[點選要安裝的VM右鍵] → [Open Console]


2. 請使用root權限登入


3. 安裝VMware tools
[VM] → [Guest] → [Install/Upgrade VMware Tools]


4. 提醒訊息
沒問題按OK就可以


5. 開始安裝VMWare Tools 
用Tarball的方式安裝
  1. [root@localhost ~]# mkdir /mnt/cdrom  
  2. [root@localhost ~]# mount /dev/cdrom /mnt/cdrom/  
  3. [root@localhost ~]# cd /mnt/cdrom  
  4. [root@localhost ~]# ls  
  5. VMwareTools-9.0.0-782409.tar.gz  
  6. [root@localhost ~]# cp VMwareTools-9.0.0-782409.tar.gz /opt/  
  7. [root@localhost ~]# cd /opt/  
  8. [root@localhost ~]# tar -zxvpf VMwareTools-9.0.0-782409.tar.gz  
  9. [root@localhost ~]#  cd vmware-tools-distrib  
  10. [root@localhost ~]# ./vmware-install.pl    
  11. #輸入./vmware-install.pl後請一直按ENTER到底就行了  
  12. [root@localhost ~]# rm -rf /opt/vmware-tools-distrib VMwareTools-9.0.0-782409.tar.gz  
  13. [root@localhost ~]# sync;sync;sync;reboot  #安裝完成後請重開機。  


6.檢查是否有安裝完成
  1. [root@localhost ~]#  /etc/init.d/vmware-tools status  #查看是否有在執行  
  2. vmtoolsd is running  


或是查看Summary 設定,會發現安裝後在VMware tools 的地方會變成綠色打勾圖示並且顯示Running
未安裝前


安裝後

2015年3月16日 星期一

Linux Curl Get Remote File Size



$ URL="http://api.twitter.com/1/statuses/public_timeline.json"
$ curl -sI $URL | grep Content-Length
Content-Length: 134


2015年3月9日 星期一

Use External Table

1. Set ORACLE_HOME environment variable

Unix & Linux

1. Check current value:
env | grep ORACLE_HOME
2. Change the ORACLE_HOME environment variable (valid for bash and ksh):
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=RMS
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib

PATH=$ORACLE_HOME/bin:$PATH
export PATH
echo $PATH
sqlplus / as sysdba


2. Use External Table

sqlplus / as sysdba
(no password)

1. SQLPLUS: connect sys/sys as sysdba

2. grant CREATE ANY DIRECTORY to pulseuser;
3. connect pulseuser
4. CREATE OR REPLACE DIRECTORY DATA_DIR AS '/home/oracle/ricky/universereport/20150304/';
CREATE OR REPLACE DIRECTORY dat_dir AS '/u01/pos_file/' ;
CREATE OR REPLACE DIRECTORY log_dir AS '/u01/pos_file/' ;
CREATE OR REPLACE DIRECTORY bad_dir AS '/u01/pos_file/' ;



You need to create an oracle directory called log_dir:
  (
            records delimited by newline LOAD WHEN (ID != ID)
            badfile BAD_DIR:'SAMPLE_EXT%a_%p.bad'
            logfile LOG_DIR:'SAMPLE_EXT%a_%p.log'
            fields terminated by ',' optionally enclosed by '"' LRTRIM
            MISSING FIELD VALUES ARE NULL 
   )

2015年3月5日 星期四

Oracle ORACLE_HOME, SQLPLUS, PLUSTRACE, and SQL query time measurement



1. Grant alter session
connect sys/sys as sysdba
SQL > startup
GRANT ALTER SESSION TO PULSEUSER;




1. Create trace role using sysdba role

SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

SET AUTOTRACE TRACEONLY command may sometimes fail with SP2-0618 and SP2-0611
exceptions. Which needs to be resolved by creating PLUSTRACE role and assigning
it to USER.

PROBLEM:

C:\> sqlplus scoot/tiger

SQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 13 17:37:25 2012

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

Connected to:
Oracle Database 11g Release 11.2.0.3.0 - Production

SQL> set autotrace traceonly;
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report



SOLUTION:

For execution AUTOTRACE the users needs to have the PLUSTRACE role, which does not
exist by default. PLUSTRACE role can be created using SYS user by executing
ORACLE_HOME\sqlplus\admin\plustrce.sql

The plustrace.sql creates the PLUSTRACE role and grants SELECT on V_$SESSTAT,
V_$STATNME and V_$MYSTAT. PLUSTRACE is granted to the DBA role with ADMIN OPTION.

For 9i and eariler databases you may also need to create the plan table by
executing following script
ORACLE_HOME\rdbms\admin\utlxplan.sql

The PLAN_TABLE already exists on database version 10g and higher.

SQL> connect sys/sys as sysdba
Connected.

SQL> @%oracle_home%\sqlplus\admin\plustrce.sql;
SQL>
SQL> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist

SQL> create role plustrace;
Role created.

SQL> grant select on v_$sesstat to plustrace;
Grant succeeded.

SQL> grant select on v_$statname to plustrace;
Grant succeeded.

SQL> grant select on v_$mystat to plustrace;
Grant succeeded.

SQL> grant plustrace to dba with admin option;
Grant succeeded.


After executing ORACLE_HOME\sqlplus\admin\plustrce.sql, we need to grant the
PLUSTRACE role to the user.

SQL> grant plustrace to scott;
Grant succeeded.

SQL> connect scott/tiger
Connected.

SQL> set autotrace trace

SQL> select user from dual;
Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953
-----------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Cost (%CPU)| Time     |
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL       |      |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          0  consistent gets
          0  physical reads
          0  redo size
        421  bytes sent via SQL*Net to client
        415  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed



NOTE: For UNIX/LINUX environments ORACLE_HOME should be written as $ORACLE_HOME
%oracle_home% as is this post is for windows environments.
3. Run your query to get the execution plan. There will be no returned rows but only the execution plan with elapsed time.

SQL> set timing on;
SQL> set autotrace traceonly;
SQL> SELECT DOMAIN, NAME, DDS_DSO_ID, PE FROM DHG WHERE (SPS_SP_RIC = '.[SPSIDN02015' and MC_LABEL = 3015 and HashValue = 4);

52082 rows selected.

Elapsed: 00:00:00.27

Execution Plan
----------------------------------------------------------
Plan hash value: 4059394150

--------------------------------------------------------------------------------
----------------

| Id  | Operation        | Name                        | Rows  | Bytes | Cost (%
CPU)| Time     |

--------------------------------------------------------------------------------
----------------

|   0 | SELECT STATEMENT |                             |     1 |    56 |     4
 (0)| 00:00:01 |

|*  1 |  INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL |     1 |    56 |     4
 (0)| 00:00:01 |

--------------------------------------------------------------------------------
----------------


Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("SPS_SP_RIC"='.[SPSIDN02015' AND "MC_LABEL"=3015 AND "HASHVALUE"=4
)



Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       3884  consistent gets
          0  physical reads
          0  redo size
    1833556  bytes sent via SQL*Net to client
      38716  bytes received via SQL*Net from client
       3474  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      52082  rows processed

SQL> SELECT DOMAIN, NAME, DDS_DSO_ID, PE FROM DHG WHERE (SPS_SP_RIC = '.[SPSIDN02015' and MC_LABEL = 3015 and HashValue = 4) OR (SPS_SP_RIC = '.[SPSSBSVAE3' AND MC_LABEL=2905);

52443 rows selected.

Elapsed: 00:00:00.26

Execution Plan
----------------------------------------------------------
Plan hash value: 2271364969

--------------------------------------------------------------------------------
-----------------

| Id  | Operation         | Name                        | Rows  | Bytes | Cost (
%CPU)| Time     |

--------------------------------------------------------------------------------
-----------------

|   0 | SELECT STATEMENT  |                             |  1351 | 75656 |    19
  (0)| 00:00:01 |

|   1 |  CONCATENATION    |                             |       |       |
     |          |

|*  2 |   INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL |     1 |    56 |     4
  (0)| 00:00:01 |

|*  3 |   INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL |  1350 | 75600 |    15
  (0)| 00:00:01 |

--------------------------------------------------------------------------------
-----------------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("SPS_SP_RIC"='.[SPSIDN02015' AND "MC_LABEL"=3015 AND "HASHVALUE"=4
)

   3 - access("SPS_SP_RIC"='.[SPSSBSVAE3' AND "MC_LABEL"=2905)
       filter(LNNVL("SPS_SP_RIC"='.[SPSIDN02015') OR LNNVL("HASHVALUE"=4) OR
              LNNVL("MC_LABEL"=3015))


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
       3915  consistent gets
          0  physical reads
          0  redo size
    1847024  bytes sent via SQL*Net to client
      38980  bytes received via SQL*Net from client
       3498  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      52443  rows processed

SQL> SELECT DOMAIN, NAME, DDS_DSO_ID, PE FROM DHG WHERE (SPS_SP_RIC = '.[SPSIDN02015' and MC_LABEL = 3015 and HashValue = 4) OR (SPS_SP_RIC = '.[SPSSBSVAE3' AND MC_LABEL=2905)  OR (SPS_SP_RIC = '.[SPSIDN01020');


417018 rows selected.

Elapsed: 00:00:02.11

Execution Plan
----------------------------------------------------------
Plan hash value: 3621106669

--------------------------------------------------------------------------------
-----------------

| Id  | Operation         | Name                        | Rows  | Bytes | Cost (
%CPU)| Time     |

--------------------------------------------------------------------------------
-----------------

|   0 | SELECT STATEMENT  |                             | 74129 |  4053K|   623
  (1)| 00:00:08 |

|   1 |  CONCATENATION    |                             |       |       |
     |          |

|*  2 |   INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL |     1 |    56 |     4
  (0)| 00:00:01 |

|*  3 |   INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL |  1350 | 75600 |    15
  (0)| 00:00:01 |

|*  4 |   INDEX RANGE SCAN| IX_DHG_ID_MCLABEL_HASH_FULL | 72778 |  3980K|   604
  (1)| 00:00:08 |

--------------------------------------------------------------------------------
-----------------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("SPS_SP_RIC"='.[SPSIDN02015' AND "MC_LABEL"=3015 AND "HASHVALUE"=4
)

   3 - access("SPS_SP_RIC"='.[SPSSBSVAE3' AND "MC_LABEL"=2905)
       filter(LNNVL("SPS_SP_RIC"='.[SPSIDN02015') OR LNNVL("HASHVALUE"=4) OR
              LNNVL("MC_LABEL"=3015))
   4 - access("SPS_SP_RIC"='.[SPSIDN01020')
       filter((LNNVL("SPS_SP_RIC"='.[SPSSBSVAE3') OR LNNVL("MC_LABEL"=2905)) AND


              (LNNVL("SPS_SP_RIC"='.[SPSIDN02015') OR LNNVL("HASHVALUE"=4) OR LN
NVL("MC_LABEL"=3015)))



Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      31050  consistent gets
          0  physical reads
          0  redo size
   14681768  bytes sent via SQL*Net to client
     306335  bytes received via SQL*Net from client
      27803  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
     417018  rows processed




End


2015年3月4日 星期三

Oracle DB Redo Log


Oracle DB Redo Log

SELECT 
to_char(first_time,'YYYY-MON-DD') day,
to_char(sum(decode(to_char(first_time,'HH24'),'00',1,0)),'99') "00",
to_char(sum(decode(to_char(first_time,'HH24'),'01',1,0)),'99') "01",
to_char(sum(decode(to_char(first_time,'HH24'),'02',1,0)),'99') "02",
to_char(sum(decode(to_char(first_time,'HH24'),'03',1,0)),'99') "03",
to_char(sum(decode(to_char(first_time,'HH24'),'04',1,0)),'99') "04",
to_char(sum(decode(to_char(first_time,'HH24'),'05',1,0)),'99') "05",
to_char(sum(decode(to_char(first_time,'HH24'),'06',1,0)),'99') "06",
to_char(sum(decode(to_char(first_time,'HH24'),'07',1,0)),'99') "07",
to_char(sum(decode(to_char(first_time,'HH24'),'08',1,0)),'99') "08",
to_char(sum(decode(to_char(first_time,'HH24'),'09',1,0)),'99') "09",
to_char(sum(decode(to_char(first_time,'HH24'),'10',1,0)),'99') "10",
to_char(sum(decode(to_char(first_time,'HH24'),'11',1,0)),'99') "11",
to_char(sum(decode(to_char(first_time,'HH24'),'12',1,0)),'99') "12",
to_char(sum(decode(to_char(first_time,'HH24'),'13',1,0)),'99') "13",
to_char(sum(decode(to_char(first_time,'HH24'),'14',1,0)),'99') "14",
to_char(sum(decode(to_char(first_time,'HH24'),'15',1,0)),'99') "15",
to_char(sum(decode(to_char(first_time,'HH24'),'16',1,0)),'99') "16",
to_char(sum(decode(to_char(first_time,'HH24'),'17',1,0)),'99') "17",
to_char(sum(decode(to_char(first_time,'HH24'),'18',1,0)),'99') "18",
to_char(sum(decode(to_char(first_time,'HH24'),'19',1,0)),'99') "19",
to_char(sum(decode(to_char(first_time,'HH24'),'20',1,0)),'99') "20",
to_char(sum(decode(to_char(first_time,'HH24'),'21',1,0)),'99') "21",
to_char(sum(decode(to_char(first_time,'HH24'),'22',1,0)),'99') "22",
to_char(sum(decode(to_char(first_time,'HH24'),'23',1,0)),'99') "23"
from
   v$log_history
   where to_char(first_time,'YYYY-MON-DD') = '2015-FEB-26'
GROUP by 
   to_char(first_time,'YYYY-MON-DD');

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...