顯示具有 DB 標籤的文章。 顯示所有文章
顯示具有 DB 標籤的文章。 顯示所有文章

2020年1月31日 星期五

Oracle DB - 如何完整關閉 AMM (Automatic Memory Management)



SQL> show parameter memory
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
memory_max_target                    big integer 2G
memory_target                        big integer 512M

SQL> show parameter sga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 2G
sga_target                           big integer 0

SQL> show parameter pga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 0

SQL> ALTER SYSTEM SET memory_target='0' SCOPE=BOTH;
System altered.

SQL> ALTER SYSTEM SET memory_max_target='0' SCOPE=spfile;
System altered.

SQL> ALTER SYSTEM SET sga_max_size = 786432000 SCOPE=SPFILE;
System altered.

SQL> ALTER SYSTEM SET sga_target = 524288000 SCOPE=BOTH;
System altered.

SQL> ALTER SYSTEM SET pga_aggregate_target=100288000 SCOPE=BOTH;
System altered.

SQL> show parameter memory
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
memory_max_target                    big integer 2G
memory_target                        big integer 0

SQL> show parameter sga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 2G
sga_target                           big integer 512M

SQL> show parameter pga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 100288000

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account
ORA-00849: SGA_TARGET 788529152 cannot be set to more than MEMORY_MAX_TARGET 0.





--如果不小心設了memory_max_target and memory_target,如何完整關閉 Automatic Memory Management

--僅用 ASMM(Automatic Shared Memory Management)


SQL> ALTER SYSTEM SET memory_target='0' SCOPE=BOTH;
System altered.

SQL> ALTER SYSTEM SET memory_max_target='0' SCOPE=spfile;
System altered.

SQL> ALTER SYSTEM SET sga_max_size = 786432000 SCOPE=SPFILE;
System altered.

SQL> ALTER SYSTEM SET sga_target = 524288000 SCOPE=BOTH;
System altered.

SQL> ALTER SYSTEM SET pga_aggregate_target=100288000 SCOPE=BOTH;
System altered.

SQL> create pfile='/tmp/my_pfile.ora' from spfile;
File created.

vi /tmp/my_pfile.ora

找到
*.memory_max_target
*.memory_target
刪除之

CREATE SPFILE = '/tmp/my_spfile.ora' FROM PFILE = '/tmp/my_pfile.ora';
shutdown immediate
cd $ORACLE_HOME/dbs
mv spfileSID.ora spfileSID.ora.bck
cp -p /tmp/my_spfile.ora spfileSID.ora
startup


SQL> startup
ORACLE instance started.

Total System Global Area  784998400 bytes
Fixed Size                  2257352 bytes
Variable Size             520097336 bytes
Database Buffers          255852544 bytes
Redo Buffers                6791168 bytes
Database mounted.
Database opened.

SQL> show parameter memory
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
memory_max_target                    big integer 0
memory_target                        big integer 0

SQL> show parameter sga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 752M
sga_target                           big integer 512M

SQL> show parameter pga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 100288000

2019年7月15日 星期一

Oracle DB - Database 版本與授權



  • Oracle產品版本

從2015年12月開始 Database 大致上分為2種版本:
企業版Enterprise Edition (EE)
價位高,全功能、無使用限制(譬如可用 RAC(extra cost), Data Guard, Online table redefinition, Flashback, Diagnostics Pack, Tuning Pack等功能)。
標準版Standard Edition 2 (SE2)
價位約為EE的三分之一,禁止安裝到支援超過2 Socket(CPU插槽)的機器上,最大支援 16 CPU threads per database instance。



  • Oracle的授權計算方式

採NUP(Named User Plus) 或 Processor(處理器/CPU),兩者擇一。

1. 採Processor計價
EE版 processor數=CPU*(Core數/每CPU)*CoreFactor,有小數時無條件進位。假設有1台DB Server,有1CPU,6核,CoreFactor=0.25。Processor數=1*6*0.25=1.5。小數點無條件進位 所以要買 2 Processors。

SE2版 processor數=occupied socket=主機版上有插CPU的socket數,也就是說直接依CPU數計算。


2. 採User計價
Oracle稱此User計價的方式為Named User Plus License,簡稱NUP,分成兩類:
設備: 自動運作,且存取Oracle DB。
真人: 有操作電腦並使用到Oracle DB的真人。

各版本的最低採購量。EE版:25 NUP/Processor,SE/SE1版:5 NUP/Customer。


  • 如果在虛擬機器上面安裝Oracle DB,譬如Oracle on VMware,可否用限制vCPU的方式節省license費用呢??

The answer is: Oracle on VMware要計算所有ESXi host cores (VM Cluster內都要買oracle license)

For example, let’s say we have a vSphere Cluster dedicated to run Oracle workloads called “OraCluster” with 3 ESXi servers, each ESXi server having 2 socket x 10 cores each. The processor is Intel Family.

Total no of effective cores for licensing Oracle workloads in “MyCluster” using Enterprise Edition (EE)
= Absolute number of cores in cluster * Processor Core Factor
= ( 3 servers * 2 sockets per server )  * ( 10 cores/socket )  * ( Processor Core Factor for Intel Family )
= 6 * 10 * 0.5
= 30 Effective cores liable for Oracle licensing



參考資訊:
https://blogs.vmware.com/apps/2017/01/oracle-vmware-vsan-dispelling-licensing-myths.html
https://blog.xuite.net/chiouchienchung/twblog/174429884-%E7%94%B2%E9%AA%A8%E6%96%87Oracle%E7%9A%84%E7%89%88%E6%9C%AC%E8%88%87%E6%8E%88%E6%AC%8A%EF%BC%8C%E4%BB%A5DB%E7%82%BA%E4%BE%8B
https://jaychu649.blogspot.com/2018/03/oracle-on-vmware.html



2019年7月9日 星期二

Oracle DB - 現行版本生命週期與支援說明




Oracle Database 現行版本
1. 11gR1(11.2) - 11.2.0.4
2. 12cR1(12.1) - 12.1.0.2
3. 12cR2(12.2) - 12.2.0.1
4. 18c - 12.2.0.2
5. 19c - 12.2.0.3

以目前使用的11.2.0.4 版本來說,是2009年9月released。
2019/09~2014/12 - Premier Support 期
2015/01~2020/12 - Extended Support 期
2021/01~ - Sustaining Support 期

簡單來說:
1. Premier Support 可以獲得完整的支援。
2. Extended Support 除了無法獲得對大部分3rd party產品的相容性,可以獲得完整的支援。 但必須留意Extended Support是必須另外購買的,不包含在Premier Support 合約中。
如果沒有購買Extended Support,則Oracle只提供Sustaining Support相關服務。
3. Sustaining Support 可以access KB,可以開SR,但無法使用最新的軟體更新與Patch,只能使用Premier Suppport期(Pre-existing)的。


參考資訊:

2018年1月2日 星期二

SQL Server Express 2012


Express版是入門級的免費數據庫,非常適合學習和構建桌面和小型服務器數據驅動的應用程序。對於建立客戶端應用程序的獨立軟件供應商,開發人員和愛好者來說,這是最好的選擇。如果您需要更高級的數據庫功能,則可以將SQL Server Express無縫升級到其他更高版本的SQL Server。SQL Server Express LocalDB是Express的輕量級版本,具有所有可編程功能,但仍以用戶模式運行,並具有快速的零配置安裝和一系列必備軟件。


SQL Server 2012 Express 分三個版本:

1. SQL Server Express

2. SQL Server Express with Tools = 1 + SQL Server Management Studio

3. SQL Server Express with Advanced Services = 2+  Reporting Services、BI Development Studio、全文檢索搜尋。

Express 版本的特點與限制,可以參考:

  1.  https://zh.wikipedia.org/wiki/SQL_Server_Express
  2. https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2016

2014年9月21日 星期日

Dropbox - cloud storage 用途

該想一下如何利用這xxTB的空間
1. File Server安裝dropbox,就不用做備份了,因為會直接同步到雲端,缺點是還原後windows ACL會跑掉。
2. 之前放在硬碟裡面的軟體installation files,好幾TB,就直接丟到dropbox去了,需要用的時候再開啟該目錄的同步。
3. 用來做跨國際的DR initial sync檔案傳送。

2014年9月3日 星期三

Oracle DB- Using the Oracle KEEP pool (Caching)




Oracle Automating Script for KEEP Pool Caching Tables & Indexes db_keep_cache_size
http://www.dba-oracle.com/t_script_automate_keep_pool_tables_indexes.htm

Using the Oracle KEEP pool
http://www.dba-oracle.com/oracle_tips_cache_small_fts.htm

Using the KEEP and RECYCLE Pool
http://www.toadworld.com/platforms/oracle/w/wiki/1347.using-the-keep-and-recycle-pool.aspx


Sometimes, data blocks are read in the database, and are infrequently reused. Often in a database we also have data blocks that are of frequent use (hot blocks). It is for these types of database blocks (and the objects associated with them) that Oracle offers the keep and recycle buffer pools. In this topic we will quickly review the database buffer cache, what the keep and recycle pools are, how to determine which objects to put in the keep pool, how to enable the buffer pool features, and finally how to assign objects to the buffer pools.

Buffer Cache Overview
Introducing the Keep and Recycle Pools
Analyze the Buffer Cache Usage
Enabling Multiple Buffer Pools
Dynamic Memory Allocation in Oracle9i
Guidelines for Initialization Parameters For Oracle8i
Allocating Segments to Different Pools

--Dell to Acquire Quest Software

2014年8月21日 星期四

Oracle DB - Use flashback database to recover the database to the point in time before failover. Physical Standby Database

1. 在DGTEST_S_US,Enable Flashback Database
2. 抄下DGTEST_P SCN  select to_char(current_scn) from v$database;   7316107016
3. 在DGTEST_P做一些交易,確認有被寫到DGTEST_S_US
4. 停止testdb1, testdb2, testdb3, make snapshot of testdb3
5. 開啟testdb3做測試
select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;
READ ONLY WITH APPLY, DGTEST_S_US, PHYSICAL STANDBY, 7316107470

SQL> alter database activate physical standby database;
alter database activate physical standby database
*
ERROR at line 1:
ORA-10457: cannot close standby database due to active media recovery

SQL> recover managed standby database cancel; 

SQL> alter database activate physical standby database;

Database altered.

SQL> select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;

OPEN_MODE
------------------------------------------------------------
DB_UNIQUE_NAME
--------------------------------------------------------------------------------
DATABASE_ROLE
------------------------------------------------
TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
MOUNTED
DGTEST_S_US
PRIMARY
0

SQL> alter database open;


--測試

create table scott.emp_copy as select * from scott.emp;


--回復 standby db

6. 做FLASHBACK DATABASE 到Activate前的SCN

SQL> select to_char(current_scn) from v$database;

TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
7316107953

SQL> select standby_became_primary_scn from v$database;

STANDBY_BECAME_PRIMARY_SCN
--------------------------
                7316107470
                
select to_char(standby_became_primary_scn) from v$database;

SQL> flashback database to scn 12841128892;
flashback database to scn 7316107470
*
ERROR at line 1:
ORA-38757: Database must be mounted and not open to FLASHBACK.


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size                  2214936 bytes
Variable Size             318768104 bytes
Database Buffers          192937984 bytes
Redo Buffers                8015872 bytes
Database mounted.
SQL> flashback database to scn 12841128892;

Flashback complete.

SQL> select to_char(current_scn) from v$database;

TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
0

SQL> alter database convert to physical standby;

Database altered.

SQL> select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;
select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database
                                                                           *
ERROR at line 1:
ORA-01507: database not mounted


SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  521936896 bytes
Fixed Size                  2214936 bytes
Variable Size             318768104 bytes
Database Buffers          192937984 bytes
Redo Buffers                8015872 bytes
Database mounted.
SQL> select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;

OPEN_MODE
------------------------------------------------------------
DB_UNIQUE_NAME
--------------------------------------------------------------------------------
DATABASE_ROLE
------------------------------------------------
TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
MOUNTED
DGTEST_S_US
PHYSICAL STANDBY
7316107470

SQL> alter database open;

Database altered.

SQL> select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;

OPEN_MODE
------------------------------------------------------------
DB_UNIQUE_NAME
--------------------------------------------------------------------------------
DATABASE_ROLE
------------------------------------------------
TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
READ ONLY
DGTEST_S_US
PHYSICAL STANDBY
7316107470

7. 開啟testdb1 and testdb2
8. 啟動 DGTEST_P and DGTEST_S
9. DGMGRL會自動帶起DETEST_S_US的 managed standby recovery.

Thu Aug 21 10:45:31 2014
Data Guard: Database open completed; restarting redo-apply ...
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Attempt to start background Managed Standby Recovery process (DGTEST)

SQL> select OPEN_MODE, DB_UNIQUE_NAME, database_role, to_char(current_scn) from v$database;

OPEN_MODE
------------------------------------------------------------
DB_UNIQUE_NAME
--------------------------------------------------------------------------------
DATABASE_ROLE
------------------------------------------------
TO_CHAR(CURRENT_SCN)
--------------------------------------------------------------------------------
READ ONLY WITH APPLY
DGTEST_S_US
PHYSICAL STANDBY
7316108323

SQL> create table scott.emp_copy2 as select * from scott.emp_copy;
SQL> select * from scott.emp_copy2;
SQL> alter system switch logfile;

10.用Data Guard Broker 再次確認

oracle_DGTEST_testdb1.rgp.raritan.com$dgmgrl
DGMGRL for Linux: Version 11.2.0.1.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected.
DGMGRL> show configuration;

Configuration - DGTEST_P

  Protection Mode: MaxPerformance
  Databases:
    DGTEST_P    - Primary database
    DGTEST_S    - Physical standby database
    DGTEST_S_US - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

2014年6月12日 星期四

Oracle DB - Purge Oracle alert log file




HOSTNAME=`/bin/uname -n`; export HOSTNAME
WHO_AM_I=`who am i | awk '{print $1}'`; export WHO_AM_I
TODAY=`date '+%d-%b-%Y:%H:%M'`; export TODAY

cd /u01/oracle/diag/rdbms/dgtest_p/DGTEST/trace
cp ./alert_$ORACLE_SID.log ./alert_$ORACLE_SID.log.$TODAY
cat /dev/null > ./alert_$ORACLE_SID.log

or just

mv ./alert_$ORACLE_SID.log ./alert_$ORACLE_SID.log.$TODAY

2014年3月5日 星期三

Oracle DB - Purge listener.log onlile

1)停止定期監聽器,那麼你可以簡單地在操作系統級別重命名該文件,然後在接下來的監聽器啟動時,一個新的將被創建。

或

2)如果你有一個24X7的環境和聽者不能停止,那麼你可以使用下列步驟來重命名/移動文件,而無需重新啟動它:


LSNRCTL> set current_listener LISTENER

LSNRCTL> set log_status off

在另外一個工作室更名 listener.log  # mv listener.log listener.log.20140305.bak
LSNRCTL> set log_status on
會產生一個新的 listener.log file which will continue logging.