28 grudnia 2010
Oracle notki, startup, shutdown.
Oracle notki – struktura fizyczna i logiczna
Oracle notki
Oracle notki – installation.
Oracle – notki, SQL, PL/SQL
Oracle (i)
Baza:
Oracle 11gR2 EE with RAC, Partitioning, Spatial (active/active)
Zarządzanie procesami biznesowymi:
Oracle Unified Business Process Management Suite. (active/active)
Repozytorium dokumentów:
Oracle Universal Content Management.
Portal:
Oracle WebLogic Portal.
Infrastruktura cache:
Oracle Coherence EE
Opis:
Oracle BPM Suite:
- Oracle WebCenter Suite
- Oracle Universal Content Management
Oracle WebCenter Suite:
- Oracle WebCenter Services
- Oracle WebCenter Interaction
- Oracle WebLogic Portal
- Oracle WebCenter Suite Spaces Component
BPEL – Business Proces Execution Language
27 grudnia 2010
Oracle Architecture (K1)
The term database refers to the physical storage of information, and the
term instance refers to the software executing on the server that provides access to
the information in the database.
Oracle’s database structures include tablespaces, control files, redo log files, archived
logs, block change tracking files, Flashback logs, and recovery backup (RMAN) files.
A tablespace is a logical structure. Each tablespace is composed of physical structures called datafiles.
Oracle9i introduced the concept of Oracle Managed Files (OMFs), which enable
your database to automatically create, name, and delete, where appropriate, all the
files that make up your database.
The control file contains locations for other physical files that form the database: the
datafiles and redo log files.
It also contains key information about the contents and
state of the database, including:
• The name of the database
• When the database was created
• Names and locations of datafiles and redo log files
• Tablespace information
• Datafile offline ranges
• The log history and current log sequence information
• Archived log information
• Backup set, pieces, datafile, and redo log information
• Datafile copy information
• Checkpoint information
Datafiles contain the actual data stored in the database, the tables and indexes that
store data, the data dictionary that maintains information about these data structures,
and the rollback segments used to implement concurrency.
The first block of each datafile is called the datafile header (checkpoint structure).
From a physical point of view, a datafile is stored as operating system blocks.
From alogical point of view, datafiles have three intermediate organizational levels:
datablocks, extents, and segments. An extent is a set of data blocks that are contiguouswithin
an Oracle datafile. A segment is an object that takes up space in an Oracledatabase,
such as a table or an index that is composed of one or more extents.
OracleDatabase 10g added a Segment Advisor that greatly simplifies reclaiming
unusedspace in current database versions.
Redo log files contain a “recording” of the changes made to the database as a
resultof transactions and internal Oracle activities. In addition, redo log files are used
for “undo” operations when a ROLLBACK statementis issued.
If you do decide to suppress redo logging for certain operations, you would
include theNOLOGGING keyword in the SQL statement (index creation, podczas
odtwarzania nie będzie utworzony – trzeba będzie utworzyć go ponownie).
In addition tousing the NOLOGGING keyword in certain commands, you can also mark
a tableor an entire tablespace with the NOLOGGING attribute. This will suppress redoinformation
for all applicable operations on the table or for all tables in thetablespace.
Oracle writes synchronously to all redo log members.
ALTER DATABASE ARCHIVELOG (od Oracle 10g)
LOG_ARCHIVE_START = TRUE (w initialization file, do 10g)
LOG_ARCHIVE_DEST = C:\ORANT\DATABASE\ARCHIVE
LOG_ARCHIVE_FORMAT = ORCL%t_%s_%r.arc
An Oracle instance can be defined as an area of shared memory and a collection of
background processes.
The area of shared memory for an instance is called the SystemGlobal Area, or SGA.
Oracle Database 10g introduced Automatic Shared Memory Management (ASM).
Whenever the MEMORY_TARGET (new to Oracle Database11g) or SGA_TARGET initialization
parameter is set, the database automatically distributesthe memory among various SGA
components providing optimal memory management.
The database buffer cache holds blocks of data retrieved from the database.
The shared pool caches various constructs that can be shared among users. Forexample, SQL queries
and query fragments issued by users and results are cached sothey can be reused if the same statement
is submitted again. PL/SQL functions arealso loaded into the shared pool for execution.
The sharedpool is also used for caching information from the Oracle data dictionary, which isthe
metadata that describes the structure and content of the database itself.
The redo log buffer caches redo information until it is written to the physical redolog files stored on a disk.
Large pool provides memory allocation for various I/O server processes, backup, and recovery,
and provides session memory where shared servers and Oracle XA for transactionprocessing are used.
Java pool provides memory allocation for Java objects and Java execution, including datain the
Java Virtual Machine in the database.
Streams pool provides memory allocation used to buffer Oracle Streams queued messages in the SGA
instead of in database tables and provides memory for capture and apply.
Dynamic initialization parameters available for these pools include LARGE_POOL_SIZE, JAVA_POOL_SIZE,
and STREAMS_POOL_SIZE. These are automatically setif MEMORY_TARGET or SGA_TARGET is specified.
The PGA (Process Global Area) consists of session memory and a private SQL area. Thememory amount can
be controlled by setting the PGA_AGGREGATE_TARGET initializationparameter. (automatyczne zarządzanie
od 10g) As of OracleDatabase 11g, PGA memory allocation is automatically tuned along with the SGA memory
allocations by setting MEMORY_TARGET.
Background Processes:
Database Writer (DBWn)
Writes database blocks from the database buffer cache in the SGA to the datafileson disk.
Log Writer (LGWR)
Writes the redo information from the log buffer in the SGA to all copies of thecurrent redo
log file on disk.
System Monitor (SMON)
SMON performscrash recovery when the instance is started after a failure and coordinates
andperforms recovery for a failed instance when youhave more than one instanceaccessing
the same database, as with Real Application Clusters. SMON alsocleans up adjacent pieces of
free space in the datafiles by merging them into onepiece and gets rid of space used for sorting
rows when that space is no longer needed.
Process Monitor (PMON)
Watches over the user processes that access the database.
Archiver (ARCn)
Reads the redo log files once Oracle has filled them and writes a copy of the usedredo log files
to the specified archive log destination(s).
Checkpoint (CKPT)
Updates datafile headers whenever a checkpoint is performed.
Recover (RECO)
Automatically cleans up failed or suspended distributed transactions.
Dispatcher
Optional background processes used when shared server configurations aredeployed.
Global Cache Service (LMS)
Manages resources for Real Application Clusters and interinstance resourcecontrol.
Job Queue
Provides a scheduler service used to schedule user PL/SQL statements or proceduresin batch.
Queue Monitor (QMNn)
Monitors Oracle Streams message queues with up to 10 monitoring processessupported.
Automatic Storage Management (ASM) processes
RBAL coordinates rebalancing of activities for disk groups. ORBn performs theactual rebalancing.
ASMB provides communication between the database andthe ASM instance.
The Data Dictionary
A set of metadata that describes the data structureincluding table definitions and integrity constraints.
25 grudnia 2010
MySQL – podstawy
mysql> SELECT * FROM Cars INTO OUTFILE '/tmp/cars.csv' -> FIELDS TERMINATED BY ','; http://zetcode.com/databases/mysqltutorial/exportimport/łączenie do MySQL mysql przetargi --host=153.19.105.4 -p sql> grant all privileges on nazwabazy.* to user@localhost identified by "jakieshaslo";
mysql> set character_set_client=latin2; mysql> set character_set_connection=utf8; mysql> load data infile "/tmp/przyswajalne" into table strony fields terminated by ';' LINES TERMINATED BY '\r\n' (nazwa_html,zawartosc); mysql> CREATE DATABASE akw_baza_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; mysql> create table produkty (nr INT NOT NULL AUTO_INCREMENT, kategoria VARCHAR(20), jednostka VARCHAR(10), iloscp INT, wstog FLOAT, odchylenie FLOAT, co VARCHAR(50), rodzaj VARCHAR(50), podrodzaj VARCHAR(50), sklasnik VARCHAR(60), PRIMARY KEY (nr)) default character set utf8; mysql> alter table produkty add column skladnik VARCHAR(60); mysql> load data infile "d:\\jacek\\pierdoly\\trans\\1.csv" into table produkty character set cp1250 fields terminated by ';' LINES TERMINATED BY '\r\n' (skladnik, jednostka, iloscp, wstog, odchylenie); sql> update produkty set kategoria="konserwa" where nr<12; character_set_client = the character set data from the client is encoded in character_set_connection = MySQL converts incoming data to. It converts from character_set_client character_set_results = MySQL converts outgoing data to character_set_server = character set for the new database character_set_database = character set for the new tables character_set_system = the character set for meta data: database, table, column names aby ustawić: set character_set_results = latin2; (lub utf8, lub iso-8859-2) show variables like "%char%"; show variables like "%collation%"; aby poprawnie wpisywać z windowsowej konsoli trzeba ustawić: set character_set_client = cp852; również aby poprawnie zobaczyć w konsoli jakie są zapisy w kolumnach trzeba ustawić set character_set_results = cp852; aby na stronie WWW wyświetlało się poprawnie należy ustawić: mysql_query("SET character_set_results=utf8"); lub latin2 tuż przed zadaniem zapytania mysqldump --user=root --password=haslo --default-character-set=utf8 --opt -all badania > badania.sql mysql db_name < backup-file.sql create table opla_pass (numer int NOT NULL auto_increment, user varchar(100), haslo varchar(100), ip varchar(30), nazwa_komputera varchar(40), PRIMARY KEY (numer)); create table skany (porzadkowy int not null auto_increment, numer int, skan blob, primary key (porzadkowy)); grant select,insert,update,delete on faktury.* to 'fakt'@'localhost' identified by 'haslo'; alter table skany modify column skan longblob; alter table skany drop column data_dodania; logowanie do pliku zewnętrznego: mysql> tee mysql.out Logging to file 'mysql.out' echo "select * from customer;" | mysql {required options} custdb > customer.txt mysql> insert into produkty (kategoria, jednostka, iloscp, wstog, odchylenie, co, rodzaj, podrodzaj, skladnik, medium, coi d) values ("", "miligramy", "10", "6490.5" , NULL, "szprot w oleju", "kwasy tłuszczowe", "nasycone", "", "", "2");
/usr/local/mysql/bin/mysqldump --user=root --password=haslo --max_allowed_packet=99M --opt --all spamassassin > spamassassin.sql
24 grudnia 2010
Oracle wprowadzenie (K1)
- Oracle 8 – 1997
- Oracle 8i – 1999
- Oracle 9i – 2001
- Oracle 10g – 2003
- Oracle 11g – 2007
Rodzaje baz danych:
- Oracle Express Edition
1GB RAM, 4 GB Dysk - Oracle Personal Edition
dla developerów. Wymagana licencja. Funkcjonalność SE - Oracle Standard Edition One
do 2 CPU, brak wsparcia dla RAC - Oracle Standard Edition
do 4 CPU na pojedynczym systemie lub klastrze RAC - Oracle Enterprise Edition
ODBC – Open DataBase Connectivity standard.
JDBC – Java DataBase Connectivity open standard.
OCI – Oracle Call Interface – interfejs programistyczny – tworzenie zaawansowanych i wydajnych programów.
Oracle Internet Directory – OID pozwala na połączenie z serwerem bez plików konfiguracyjnych po stronie klienta. OID jest implementacją LDAP
(Lightweight Directory Access Protocol)
Oracle Connection Manager – CMAN – pozwala na ograniczenie połączeń typu Oracle Net poprzez użycie koncentratorów.
Oracle Application Server
- BPEL Business Process Execution Language (BPEL) – tool is designed for
Service-Oriented Architecture (SOA) environments and used for creating, managing,
and deploying cross-application business processes. - Business Activity Monitoring (BAM)
- WebCenter – portal framework used for deploying portlets and
Ajax-based components.
The Fusion Middleware SOA Suite serves as the basis for Oracle’s Application
Integration Architecture (AIA).
Distributed Queries and Transactions
Distributed queries can retrieve data from multiple databases.
Distributed transactions can insert, update, or delete data on distributed databases.
Oracle’s two-phase commit mechanism.
Transportable Tablespaces
Database Parallelization
Bitmap indexes
Bitmap indexes typically work best for columns that have few different values relative to the overall number of rows in a table.
A bitmap index uses an individual bit for each
potential value with the bit either “on” (set to 1) to indicate that the row contains the
value or “off” (set to 0) to indicate that the row does not contain the value.
OLAP
Online Analytical Processing.
Za wikipedią: Kostka OLAP (ang. OLAP cube) – wielowymiarowa baza danych, która przechowuje dane w sposób bardziej
przypominający wielowymiarowe arkusze kalkulacyjne niż tradycyjną, relacyjną bazę danych. Kostka umożliwia
wyświetlanie i oglądanie danych z różnych punktów widzenia. Do jej budowy potrzeba dowolnego źródła danych
opartego na relacjach. Ze względów wydajnościowych zaleca się stosowanie źródeł opartych na języku SQL i
technologii hurtowni danych.
The OLAP Option physically stores dimensionally aware cubes in the Oracle relational
database. These cubes are most frequently accessed using SQL, although a
22 | Chapter 1: Introducing Oracle
Java API is also supported.
Data Mining Option.
Business intelligence tools.
Database Management Features.
Starting with Oracle Database 10g, statistics are automatically gathered to an Automatic
Workload Repository (AWR) within the database.
Oracle’s Automatic Database
Diagnostic Monitor (ADDM) evaluates the statistics on a regular basis and sends alerts
of potential problem conditions to Oracle Enterprise Manager.
Some of the newer fully automated features, such as Automatic Memory Management, also leverage
data gathered in the AWR.
Oracle Enterprise Manager.
EM provides a database management tool framework and an
HTML-based interface used to manage database users, instances, and features. EM
can also manage Oracle Application Server, Oracle Applications, Oracle’s Linux
release, and software products from other vendors.
Data Guard.
The standby database
provides a copy of the production database to be used if the primary database is lost.
Oracle Real Application Clusters.
Cache Fusion that greatly minimizes the amount of writing to disk
that was formerly used to control data locks.
Oracle Database 10g introduced a new
level of RAC portability and Oracle support by providing integrated “clusterware”
for the supported RAC platforms.
Applications can leverage the Oracle Call Interface (OCI) to provide failover to a
second instance transparently to the user.
Automated Storage Management.
Oracle Portal.
Servlety to technologia skryptów Java wykonywanych po stronie serwera.
Portlet jest to niezależny komponent stworzony najczęściej w języku Java do umieszczenia
na stronie www. Są to programy wyświetlające jedną funkcjonalność na stronie. Portlet jest
umieszczany w kontenerze portletów, który agreguje zawartość prezentowanej strony.
Celem portletów jest stworzenie programu, który będzie uniezależniony od kontenera,
na którym będzie uruchamiany, co stwarza możliwość jego wielokrotnego użycia.
Oracle TimesTen.
Oracle TimesTen is a relational database that is stored in physical memory and is
typically used where very high-performance transaction-processing workloads are
present.
MySQL – zwiększenie rozmiaru bazy danych
mysql> show engines; mysql> show table status; aby dodać miejsce (INNODB) trzeba zamknąć bazę: mysqladmin -u root -p shutdown a następnie w /etc/my.cnf trzeba dodać kolejny plik innodb_data_file_path = dbdata1:200M;dbdata2:200M;dbdata3:512M i uruchomić bazę ponownie.
23 grudnia 2010
Oracle – sesje użytkowników.
Aby wyświetlić aktywne sesje użytkowników w bazie danych Oracle:
select b.Username, b.Osuser, b.Process, b.Machine, a.Spid, b.Program, b.Sid, b.Serial# from v$process a, v$session b where a.Addr = b.Paddr ORDER BY b.Machine /