SlideShare ist ein Scribd-Unternehmen logo
1 von 120
CUBRIDDeveloper's Course Author: Bomyung Oh Team / Department: DBMS Development Lab Author(2): Kyungsik Seo Team / Department: DBMS Development Lab
Comparison of the featuredevelopment speed with MySQL CUBRID ,[object Object],Cluster R3.2 ,[object Object]
CUBRID FBOR3.1 R3.0 ,[object Object]
Hierarchical QueryR2.0 ,[object Object]
Triggers
Stored Procedure
AUTO_INCREMENT
Query Plan Cache
Query Result Cache
Replication
Partitioning
Click CounterR1.0 MySQL 5.5 5.4 5.1 5.0 ,[object Object]
Triggers
Stored Procedures
AUTO_INCREMENT
Query Cache
Replication
Full Text Indexing
Partitioning
Event scheduler
MySQL Cluster
XML Functions4.1 4.0 3.23 2003 2001 2002 2004 2005 2006 2007 2008 2009 2010
Who are using CUBRID  Over 100,000 Downloads
Introduction to CUBRID Overview and Architecture of CUBRID Using CUBRID Introduction to CUBRID HA
1.1 Overview and Architecture of CUBRID
What is CUBRID? ,[object Object],CUBRIDis a comprehensive open source relational database management system that is highly optimized for Web Applications, particularly those with Read-intensive transactions.  ,[object Object],http://dev.naver.com/projects/cubrid/ http://www.cubrid.com/online_manual/cubrid_830/index.htm http://www.cubrid.com http://devcafe.nhncorp.com/g_cubrid ,[object Object],http://www.cubrid.org/ http://wiki.cubrid.org/index.php/CUBRID_Manuals/cubrid_2008_R3.0_manual ,[object Object],http://www.youtube.com/user/cubrid
CUBRIDArchitecture (Simplified) ,[object Object],Broker : DB Server = 1 : N is possible Application Client Java Apps CUBRID Manager WAS WAS Query Editor DB Interface JDBC driver Manager port: 8001,8002 JDBC JDBC connect Broker port: 30000 Middleware cub_broker cub_auto Broker1 Broker2 cub_job cub_cas send_fd connect Server port: 1523 DBServer cub_master cub_auto connect Server port: 1523 send_fd cub_job cub_server DB Server2 DB Server1 Data Volume2 Data Volume1 volume file log file volume file log file
CUBRIDArchitecture (Detailed) CUBRID Manager GUI CUBRID Manager Interface ODBC CCI PHP OLE DB Python Ruby JDBC CM Server Broker Job Queuing Monitoring Connection Pooling Logging Client Library Native C API Parser Object Manager Schema Manager Transaction Manager Query Transform Workspace Manager Query Optimizer Memory Manager Plan Generation Communication Module Server Admin Utility Communication Module Create, Delete, Copy, Rename Transaction Manager Log Manager Lock Manager Query Manager Access Method B+Tree Module File Manager System Catalog Module Add Volume Buffer Manager Load / Unload Disk Manager Backup / Restore Active Log Compact / Optimize File Based Objects Data Volume Index Volume Temp Volume Check / Diag Archive Log
CUBRIDProcess (Detailed) JDBC driver CCI library API connect query & result port listening query & result File cub_broker cubrid_broker.conf fork parse descriptor pass Process cub_cas cub_cas shared memory csql cubridcs.so cubridcs.so Dynamic shared library connect cubridcs.so request & response TCP job queue multi-thread port listening parse descriptor pass parse cub_master cub_server cubrid.conf UDS cubrid.so mount (read/write) register read volume file log file databases.txt volume file log file cub_admin cubridsa.so
1.2 Using CUBRID
Prerequisites for Installation Download CUBRID http://sourceforge.net/projects/cubrid Check supported platforms (Linux/Windows) uname –r  rpm –qa | grepglibc Install JRE version 1.5 or higher and set up the environment variables(CUBRID Manager) http://java.sun.com/javase/downloads/index.jsp For Linux For Windows Visual C++ 2008 distribution pack installation Create DB users (multiple instances) http://www.microsoft.com/downloads/details.aspx?displaylang=ko&FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf Install and launch CUBRID
CUBRIDInstallation and Starting CUBRID Service ,[object Object]
For detailed information, see the manual provided at the following link:. Run the exe file to start the installation wizard.http://www.cubrid.org/manual/gs/gs_install_windows.htm
Starting CUBRID Service in the CUBRIDtray
How to install CUBRID and start CUBRID Service in the Linux environment
For detailed information, see the manual provided at the following link: http://www.cubrid.org/manual/gs/gs_install_linux.htm ,[object Object],For detailed information, see the manual provided at the following link: http://www.cubrid.org/manual/gs/gs_must_svcstart.htm ,[object Object],% sh CUBRID-8.3.0.0312-linux.x86_64.sh% . /home1/cub_user/.cubrid.sh % cubrid service start
DB Creation and DB Start ,[object Object],http://www.cubrid.org/manual/admin/admin_db_create_create.htm ,[object Object]
Starting an existing DB(demodb is included in the installation of CUBRID, by default)For detailed information, see the manual provided at the following link:http://www.cubrid.org/manual/gs/gs_must_svcstart.htm ,[object Object],% cubridcreatedbtestdb 	% cubrid server start testdb    % cubrid server start demodb
CUBRID Manager - Configuration ,[object Object]
CUBRID Manager is a tool used to control the functions of servers and brokers, andto monitor and analyze logs
CUBIRD Manager consists of the search pane to the left, the query edit pane to the right, the top menu, and the toolbar,[object Object]
CUBRID Manager - stop Stop DB Server Disconnect from the host Stop CUBRID Manager
1.3 Introduction to CUBRID HA
Introduction to CUBRID HA  ,[object Object]
No-Automatic Fail-over  No-Automatic Sync
HA
Automatic Fail-over  Automatic Sync,[object Object]
HA Configuration and Usage– Broker Redundancy AP Web Server AP Web Server JDBC Driver CCI Library Automatic failover Fail-back Fail-over Broker #2 Broker #1 Node Fail Active Server Standby Server Replication
Diagram of HA Architecture (Detailed) Async Update Select A-Node Active Server Node S1-Node Standby Server Node applylogdb coyplogdb applylogdb coyplogdb Server Active Replica Standby Semi-Sync Sync active log archive logs A-node’s active & archive logs S1-node’s active & archive logs active log archive logs Replication Log is not included Replication Log is included #Configurations# #A-Node’s log path S1-Node’s active & archive logs     = $CUBRID_DATABASES/database-name_S1-Node-hostname (ex. /home1/cubrid1/DB/tdb01_Snode1) copylogdb & applylogdberror logs      = $CUBRID/log #S1-Node’s log path A-Node’s active & archive logs     = $CUBRID_DATABASES/database-name_A-Node-hostname (ex. /home1/cubrid1/DB/tdb01_Anode1) copylogdb & applylogdberror logs      = $CUBRID/log #Configurations# A-node & S1-node’s <cubrid.conf> ha_mode=yes ha_node_list=hagrpname@A-node:S1-node A-node & S1-node’s <cubrid-ha> CUBRID_USER=username DB_LIST=‘dbname‘ broker node’s <databases.txt> dbnamevol_pathA-node:S1-nodelog_path
2. CUBRIDArchitecture CUBRIDVolume Structure CUBRIDParameters Broker Parameters Error Log File System Catalog
2.1 CUBRIDVolume Structure
CUBRIDVolume Structure ,[object Object]
**: A CUBRID file can be separated to multiple CUBRID volumes.File_1 File_2 File_3 Free_Pages Volumes
DB Volume Structure
DBVolume – InformationVolume ,[object Object]
Data volume
Saves the data of an application, such as tables or records
A record storage file, called heap, is created in a data volume
Index volume
A volume in which B+Tree indexes are saved for faster data access or queries
Temp volume
A volume in which intermediate results are saved to fetch result sets that exceed the size of the memory buffer, or to execute join queries
A temporary volume with an appropriate size must be created when creating a DB volume.
This is a permanent volume that is used for temporary purposes, and is different from temporary volumes that are used only temporarily.
Generic volume
The initial volume during DB creation, which can be used as the data, index, or temp volume.
If the usage of the volume (data, index, or temporary) is not specified, it can be used for general purposes.,[object Object]
The active log volume includes the most recent updates that have been applied to a database.
Records the status of a committed, aborted, or active transaction.
It is used to recover a DB from a storage media failure.
When the space allocated to an active log is completely used up, the content of the active log will be copied to and stored in a new log (archive log).
Example: demodb_lgat(active log), demodb_lgar*(arcive log),[object Object]
Volume Information
Includes the location information on DB volumes to be created or added
This file cannot be manually modified, deleted, or moved.
The name of the file is in {dbname}_vinf format.
Log Information
Records the information of the current logs and archive logs
Records the information on a new archive log file and unnecessary archive log file.
The name of the file is in {dbname}_lginf format-5 C:UBRIDatabasesemodbemodb_vinf -4 C:UBRIDatabasesemodbemodb_lginf -3 C:UBRIDatabasesemodbemodb_bkvinf -2 C:UBRIDatabasesemodbemodb_lgat 0 C:UBRIDatabasesemodbemodb 1 C:UBRIDATABA~1emodbemodb_x0010 COMMENT: CUBRID/LogInfo for database /CUBRID/databases/demodb ACTIVE: /CUBRID/databases/demodb_lgat 5000 pages ARCHIVE: 0  /CUBRID/databases/demodb_lgar000  0  4997 COMMENT: Log archive /CUBRID/databases/demodb_lgar000 is not needed any longer unless a database media crash occurs.
DB Volume – Backup Volume ,[object Object]
Records the location and backup information of a backup volume
Located in the same path in which log files are stored.
The name of the file is in {dbname}_bkvinf format.0  0  /Backup/demodb_bk000 	0 level full backup of the first file.  0  1  /Backup/demodb_bk001 	0 level full backup of the second file.  1  0  /Backup/demodb_bk100 	1 level incremental backup of the first file.  2  0  /Backup/demodb_bk200 	2 level incremental backup of the first file. The path information of a backup file Backup level information The sequence number of a backup volume per  level
DB Volume – $CUBRID/conf/databases.txt ,[object Object]
Contains the name, path, and the name of the built host of a DB.
Records the information related to the DB that is created in the databases.txt file upon the creation of a DB.
Saved to the path in which the $CUBRID_DATABASES environment variables are specified.
If it does not exist in the directory specified by the environment variable, the current directory will be used instead.
Caution
If a host name has been changed or a DB deleted by an OS command, this file must be modified as well.
As the user must be able to modify the databases.txt file during DB creation or deletion, the user must have the privilege to write to this file. If a user without the appropriate privilege attempts to create a DB, the DB creation will fail. For this reason, a DBA should enable the user-write privilege for the directory, or create a databases.txt file in the directory of each user and configure the environment variables.demodb   /CUBRID/databases/demodb  hostname /CUBRID/databases/demodb DB name DB path Host name DB log path
DB Volume Management An example of volume configuration disk1 disk3 disk2 db1 db1_temp db1_log db1_data db1_index db_backup ,[object Object]
Distributes data, index, temp, and log volume so that they are separated from each other
Avoids the disk bottlenecks and improves disk management
Distributes volumes that can be used simultaneously
data & log,  data & index,  data & temp
Configures a volume to an appropriate size to prevent it from adding more volumes while in service
Data, Index, Temp, Active Log: Page size and the number of pages must be considered
Backup: Backs up with the -r option, and then deletes unnecessary archive logs,[object Object]
Environment Configuration File - $CUBRID/conf/cubrid.conf ,[object Object]
A file in which the value of CUBRIDsystem parameters are saved.
The file is located in a subdirectory of $CUBRID/conf . You are recommended to specify different values from one DB to another DB  in the DB.
There are two types of parameters: DB server parameters and DB client parameters. If a parameter has been changed in a process, that process must be restarted.
SQL is used to change a client parameter.
Syntax for configuring parameters
Case-insensitive
The name and value of a parameter must be inserted on the same line.
An equals sign (=) can be used, and a blank character can be added at both sides of the sign..
If the value of a parameter is a string, insertthe string without quotation marks. If a blank character is included in the string, encase it with quotation marks. [commom] data_buffer_pages=250000 [demodb] data_buffer_pages=500000
[object Object]
Add CUBRID_ at the beginning of the parameter to configure it as an environment variable
Configuring with an SQL statement
Only client parameters can be configured
Use “;” for multiple configurationsEnvironment Configuration File- $CUBRID/conf/cubrid.conf set CUBRID_SORT_BUFFER_PAGE=512 SET SYSTEM PARAMETERS 'parameter_name=value [{; name=value}...]‘ SET SYSTEM PARAMETERS 'csql_history_num=70’ SET SYSTEM PARAMETERS 'csql_history_num=70; index_scan_in_oid_order=1'
Memory Related Configurations ,[object Object]
The number of data pages cached to the memory by a DB server
Requires an amount of memory equivalent to  num_data_buffers times database page size (the page size specified when the DB is initialized; default is 4KB). (The size of the required memory is 100MB if the default is 25,000)
The actual size of a DB, the size of the memory, and the number and size of other processes must be considered when determining the size
The larger the value, the more data needs to be cached to the memory, which means less disk I/O. However, a value that is too large will cause the full swapping of page buffers.

Weitere ähnliche Inhalte

Was ist angesagt?

Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsGavin Roy
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scaleMydbops
 
MongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James BroadheadMongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James BroadheadMongoDB
 
MaxScale for Effective MySQL Meetup NYC - 14.01.21
MaxScale for Effective MySQL Meetup NYC - 14.01.21MaxScale for Effective MySQL Meetup NYC - 14.01.21
MaxScale for Effective MySQL Meetup NYC - 14.01.21Ivan Zoratti
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into CassandraBrian Hess
 
LibX 2.0
LibX 2.0LibX 2.0
LibX 2.0eby
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기OnGameServer
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?Mydbops
 
Practicing Continuous Deployment
Practicing Continuous DeploymentPracticing Continuous Deployment
Practicing Continuous Deploymentzeeg
 
Introduction to Mesos
Introduction to MesosIntroduction to Mesos
Introduction to Mesoskoboltmarky
 
Mysteries of the binary log
Mysteries of the binary logMysteries of the binary log
Mysteries of the binary logMats Kindahl
 
Using advanced options in MariaDB Connector/J
Using advanced options in MariaDB Connector/JUsing advanced options in MariaDB Connector/J
Using advanced options in MariaDB Connector/JMariaDB plc
 
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated Hadoop
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated HadoopHadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated Hadoop
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated HadoopYafang Chang
 
An Introduction to Using PostgreSQL with Docker & Kubernetes
An Introduction to Using PostgreSQL with Docker & KubernetesAn Introduction to Using PostgreSQL with Docker & Kubernetes
An Introduction to Using PostgreSQL with Docker & KubernetesJonathan Katz
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"IT Event
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Cassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupCassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupMichael Wynholds
 
Kubernetes #4 volume &amp; stateful set
Kubernetes #4   volume &amp; stateful setKubernetes #4   volume &amp; stateful set
Kubernetes #4 volume &amp; stateful setTerry Cho
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMakerKris Buytaert
 

Was ist angesagt? (20)

Scaling PostgreSQL with Skytools
Scaling PostgreSQL with SkytoolsScaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scale
 
MongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James BroadheadMongoDB Ops Manager and Kubernetes - James Broadhead
MongoDB Ops Manager and Kubernetes - James Broadhead
 
MaxScale for Effective MySQL Meetup NYC - 14.01.21
MaxScale for Effective MySQL Meetup NYC - 14.01.21MaxScale for Effective MySQL Meetup NYC - 14.01.21
MaxScale for Effective MySQL Meetup NYC - 14.01.21
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into Cassandra
 
LibX 2.0
LibX 2.0LibX 2.0
LibX 2.0
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
Practicing Continuous Deployment
Practicing Continuous DeploymentPracticing Continuous Deployment
Practicing Continuous Deployment
 
Introduction to Mesos
Introduction to MesosIntroduction to Mesos
Introduction to Mesos
 
Mysteries of the binary log
Mysteries of the binary logMysteries of the binary log
Mysteries of the binary log
 
Using advanced options in MariaDB Connector/J
Using advanced options in MariaDB Connector/JUsing advanced options in MariaDB Connector/J
Using advanced options in MariaDB Connector/J
 
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated Hadoop
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated HadoopHadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated Hadoop
HadoopCon2015 Multi-Cluster Live Synchronization with Kerberos Federated Hadoop
 
An Introduction to Using PostgreSQL with Docker & Kubernetes
An Introduction to Using PostgreSQL with Docker & KubernetesAn Introduction to Using PostgreSQL with Docker & Kubernetes
An Introduction to Using PostgreSQL with Docker & Kubernetes
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Cassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupCassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL Meetup
 
Kubernetes #4 volume &amp; stateful set
Kubernetes #4   volume &amp; stateful setKubernetes #4   volume &amp; stateful set
Kubernetes #4 volume &amp; stateful set
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
 
Hadoop security
Hadoop securityHadoop security
Hadoop security
 

Andere mochten auch

CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011
CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011
CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011CUBRID
 
Cubrid Inside 5th Session 2 Ha Implementation
Cubrid Inside 5th Session 2 Ha ImplementationCubrid Inside 5th Session 2 Ha Implementation
Cubrid Inside 5th Session 2 Ha ImplementationCUBRID
 
Cubrid Inside 5th Session 3 Migration
Cubrid Inside 5th Session 3 MigrationCubrid Inside 5th Session 3 Migration
Cubrid Inside 5th Session 3 MigrationCUBRID
 
Cubrid Inside 5th Session 4 Replication
Cubrid Inside 5th Session 4 ReplicationCubrid Inside 5th Session 4 Replication
Cubrid Inside 5th Session 4 ReplicationCUBRID
 
Installing CUBRID Database and CUBRID Manager on Windows
Installing CUBRID Database and CUBRID Manager on WindowsInstalling CUBRID Database and CUBRID Manager on Windows
Installing CUBRID Database and CUBRID Manager on WindowsCUBRID
 
Installing CUBRID on Windows
Installing CUBRID on WindowsInstalling CUBRID on Windows
Installing CUBRID on WindowsCUBRID
 
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...CUBRID
 
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...CUBRID
 

Andere mochten auch (8)

CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011
CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011
CUBRID HA - Guaranteed Way to Never-Die Web Services - OSCON 2011
 
Cubrid Inside 5th Session 2 Ha Implementation
Cubrid Inside 5th Session 2 Ha ImplementationCubrid Inside 5th Session 2 Ha Implementation
Cubrid Inside 5th Session 2 Ha Implementation
 
Cubrid Inside 5th Session 3 Migration
Cubrid Inside 5th Session 3 MigrationCubrid Inside 5th Session 3 Migration
Cubrid Inside 5th Session 3 Migration
 
Cubrid Inside 5th Session 4 Replication
Cubrid Inside 5th Session 4 ReplicationCubrid Inside 5th Session 4 Replication
Cubrid Inside 5th Session 4 Replication
 
Installing CUBRID Database and CUBRID Manager on Windows
Installing CUBRID Database and CUBRID Manager on WindowsInstalling CUBRID Database and CUBRID Manager on Windows
Installing CUBRID Database and CUBRID Manager on Windows
 
Installing CUBRID on Windows
Installing CUBRID on WindowsInstalling CUBRID on Windows
Installing CUBRID on Windows
 
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...
Быстрый и простой способ шардирования MySQL с помощью CUBRID SHARD - 2013 R...
 
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...
Database Sharding the Right Way: Easy, Reliable, and Open source - HighLoad++...
 

Ähnlich wie CUBRID Developer's Course Overview and Architecture

How to scale your web app
How to scale your web appHow to scale your web app
How to scale your web appGeorgio_1999
 
Ppdg Robust File Replication
Ppdg Robust File ReplicationPpdg Robust File Replication
Ppdg Robust File Replicationguestbdd02b
 
Ppdg Robust File Replication
Ppdg Robust File ReplicationPpdg Robust File Replication
Ppdg Robust File Replicationtest98
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Mydbops
 
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryEffective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryKaren Broughton-Mabbitt
 
CUBRID presentation at Programatica Conference 2010
CUBRID presentation at Programatica Conference 2010CUBRID presentation at Programatica Conference 2010
CUBRID presentation at Programatica Conference 2010ArniaSoftware
 
Arnia-Cubrid - Programatica2010
Arnia-Cubrid - Programatica2010Arnia-Cubrid - Programatica2010
Arnia-Cubrid - Programatica2010Agora Group
 
Continuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data ManagementContinuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data Managementguest2e11e8
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017Dave Stokes
 
Apache httpd-2.4 : Watch out cloud!
Apache httpd-2.4 : Watch out cloud!Apache httpd-2.4 : Watch out cloud!
Apache httpd-2.4 : Watch out cloud!Jim Jagielski
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012Colin Charles
 
Cloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfCloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfLeah Cole
 
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning GuideWebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning GuideTan Nguyen Phi
 
Percona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryPercona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryRam Gautam
 
Directory Write Leases in MagFS
Directory Write Leases in MagFSDirectory Write Leases in MagFS
Directory Write Leases in MagFSMaginatics
 
Why to upgrade to SQLServer 2012?
Why to upgrade to SQLServer 2012?Why to upgrade to SQLServer 2012?
Why to upgrade to SQLServer 2012?Sarabpreet Anand
 
How to Contribute Code to MySQL?
How to Contribute Code to MySQL?How to Contribute Code to MySQL?
How to Contribute Code to MySQL?Thava Alagu
 

Ähnlich wie CUBRID Developer's Course Overview and Architecture (20)

How to scale your web app
How to scale your web appHow to scale your web app
How to scale your web app
 
Ppdg Robust File Replication
Ppdg Robust File ReplicationPpdg Robust File Replication
Ppdg Robust File Replication
 
Ppdg Robust File Replication
Ppdg Robust File ReplicationPpdg Robust File Replication
Ppdg Robust File Replication
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
 
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryEffective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
 
Designer 2000 Tuning
Designer 2000 TuningDesigner 2000 Tuning
Designer 2000 Tuning
 
How To Scale v2
How To Scale v2How To Scale v2
How To Scale v2
 
CUBRID presentation at Programatica Conference 2010
CUBRID presentation at Programatica Conference 2010CUBRID presentation at Programatica Conference 2010
CUBRID presentation at Programatica Conference 2010
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Arnia-Cubrid - Programatica2010
Arnia-Cubrid - Programatica2010Arnia-Cubrid - Programatica2010
Arnia-Cubrid - Programatica2010
 
Continuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data ManagementContinuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data Management
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
 
Apache httpd-2.4 : Watch out cloud!
Apache httpd-2.4 : Watch out cloud!Apache httpd-2.4 : Watch out cloud!
Apache httpd-2.4 : Watch out cloud!
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 
Cloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfCloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdf
 
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning GuideWebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
 
Percona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryPercona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster Recovery
 
Directory Write Leases in MagFS
Directory Write Leases in MagFSDirectory Write Leases in MagFS
Directory Write Leases in MagFS
 
Why to upgrade to SQLServer 2012?
Why to upgrade to SQLServer 2012?Why to upgrade to SQLServer 2012?
Why to upgrade to SQLServer 2012?
 
How to Contribute Code to MySQL?
How to Contribute Code to MySQL?How to Contribute Code to MySQL?
How to Contribute Code to MySQL?
 

CUBRID Developer's Course Overview and Architecture

  • 1. CUBRIDDeveloper's Course Author: Bomyung Oh Team / Department: DBMS Development Lab Author(2): Kyungsik Seo Team / Department: DBMS Development Lab
  • 2.
  • 3.
  • 4.
  • 12.
  • 22. XML Functions4.1 4.0 3.23 2003 2001 2002 2004 2005 2006 2007 2008 2009 2010
  • 23. Who are using CUBRID Over 100,000 Downloads
  • 24. Introduction to CUBRID Overview and Architecture of CUBRID Using CUBRID Introduction to CUBRID HA
  • 25. 1.1 Overview and Architecture of CUBRID
  • 26.
  • 27.
  • 28. CUBRIDArchitecture (Detailed) CUBRID Manager GUI CUBRID Manager Interface ODBC CCI PHP OLE DB Python Ruby JDBC CM Server Broker Job Queuing Monitoring Connection Pooling Logging Client Library Native C API Parser Object Manager Schema Manager Transaction Manager Query Transform Workspace Manager Query Optimizer Memory Manager Plan Generation Communication Module Server Admin Utility Communication Module Create, Delete, Copy, Rename Transaction Manager Log Manager Lock Manager Query Manager Access Method B+Tree Module File Manager System Catalog Module Add Volume Buffer Manager Load / Unload Disk Manager Backup / Restore Active Log Compact / Optimize File Based Objects Data Volume Index Volume Temp Volume Check / Diag Archive Log
  • 29. CUBRIDProcess (Detailed) JDBC driver CCI library API connect query & result port listening query & result File cub_broker cubrid_broker.conf fork parse descriptor pass Process cub_cas cub_cas shared memory csql cubridcs.so cubridcs.so Dynamic shared library connect cubridcs.so request & response TCP job queue multi-thread port listening parse descriptor pass parse cub_master cub_server cubrid.conf UDS cubrid.so mount (read/write) register read volume file log file databases.txt volume file log file cub_admin cubridsa.so
  • 31. Prerequisites for Installation Download CUBRID http://sourceforge.net/projects/cubrid Check supported platforms (Linux/Windows) uname –r rpm –qa | grepglibc Install JRE version 1.5 or higher and set up the environment variables(CUBRID Manager) http://java.sun.com/javase/downloads/index.jsp For Linux For Windows Visual C++ 2008 distribution pack installation Create DB users (multiple instances) http://www.microsoft.com/downloads/details.aspx?displaylang=ko&FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf Install and launch CUBRID
  • 32.
  • 33. For detailed information, see the manual provided at the following link:. Run the exe file to start the installation wizard.http://www.cubrid.org/manual/gs/gs_install_windows.htm
  • 34. Starting CUBRID Service in the CUBRIDtray
  • 35. How to install CUBRID and start CUBRID Service in the Linux environment
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. CUBRID Manager is a tool used to control the functions of servers and brokers, andto monitor and analyze logs
  • 41.
  • 42. CUBRID Manager - stop Stop DB Server Disconnect from the host Stop CUBRID Manager
  • 43. 1.3 Introduction to CUBRID HA
  • 44.
  • 45. No-Automatic Fail-over  No-Automatic Sync
  • 46. HA
  • 47.
  • 48. HA Configuration and Usage– Broker Redundancy AP Web Server AP Web Server JDBC Driver CCI Library Automatic failover Fail-back Fail-over Broker #2 Broker #1 Node Fail Active Server Standby Server Replication
  • 49. Diagram of HA Architecture (Detailed) Async Update Select A-Node Active Server Node S1-Node Standby Server Node applylogdb coyplogdb applylogdb coyplogdb Server Active Replica Standby Semi-Sync Sync active log archive logs A-node’s active & archive logs S1-node’s active & archive logs active log archive logs Replication Log is not included Replication Log is included #Configurations# #A-Node’s log path S1-Node’s active & archive logs = $CUBRID_DATABASES/database-name_S1-Node-hostname (ex. /home1/cubrid1/DB/tdb01_Snode1) copylogdb & applylogdberror logs = $CUBRID/log #S1-Node’s log path A-Node’s active & archive logs = $CUBRID_DATABASES/database-name_A-Node-hostname (ex. /home1/cubrid1/DB/tdb01_Anode1) copylogdb & applylogdberror logs = $CUBRID/log #Configurations# A-node & S1-node’s <cubrid.conf> ha_mode=yes ha_node_list=hagrpname@A-node:S1-node A-node & S1-node’s <cubrid-ha> CUBRID_USER=username DB_LIST=‘dbname‘ broker node’s <databases.txt> dbnamevol_pathA-node:S1-nodelog_path
  • 50. 2. CUBRIDArchitecture CUBRIDVolume Structure CUBRIDParameters Broker Parameters Error Log File System Catalog
  • 52.
  • 53. **: A CUBRID file can be separated to multiple CUBRID volumes.File_1 File_2 File_3 Free_Pages Volumes
  • 55.
  • 57. Saves the data of an application, such as tables or records
  • 58. A record storage file, called heap, is created in a data volume
  • 60. A volume in which B+Tree indexes are saved for faster data access or queries
  • 62. A volume in which intermediate results are saved to fetch result sets that exceed the size of the memory buffer, or to execute join queries
  • 63. A temporary volume with an appropriate size must be created when creating a DB volume.
  • 64. This is a permanent volume that is used for temporary purposes, and is different from temporary volumes that are used only temporarily.
  • 66. The initial volume during DB creation, which can be used as the data, index, or temp volume.
  • 67.
  • 68. The active log volume includes the most recent updates that have been applied to a database.
  • 69. Records the status of a committed, aborted, or active transaction.
  • 70. It is used to recover a DB from a storage media failure.
  • 71. When the space allocated to an active log is completely used up, the content of the active log will be copied to and stored in a new log (archive log).
  • 72.
  • 74. Includes the location information on DB volumes to be created or added
  • 75. This file cannot be manually modified, deleted, or moved.
  • 76. The name of the file is in {dbname}_vinf format.
  • 78. Records the information of the current logs and archive logs
  • 79. Records the information on a new archive log file and unnecessary archive log file.
  • 80. The name of the file is in {dbname}_lginf format-5 C:UBRIDatabasesemodbemodb_vinf -4 C:UBRIDatabasesemodbemodb_lginf -3 C:UBRIDatabasesemodbemodb_bkvinf -2 C:UBRIDatabasesemodbemodb_lgat 0 C:UBRIDatabasesemodbemodb 1 C:UBRIDATABA~1emodbemodb_x0010 COMMENT: CUBRID/LogInfo for database /CUBRID/databases/demodb ACTIVE: /CUBRID/databases/demodb_lgat 5000 pages ARCHIVE: 0 /CUBRID/databases/demodb_lgar000 0 4997 COMMENT: Log archive /CUBRID/databases/demodb_lgar000 is not needed any longer unless a database media crash occurs.
  • 81.
  • 82. Records the location and backup information of a backup volume
  • 83. Located in the same path in which log files are stored.
  • 84. The name of the file is in {dbname}_bkvinf format.0 0 /Backup/demodb_bk000 0 level full backup of the first file. 0 1 /Backup/demodb_bk001 0 level full backup of the second file. 1 0 /Backup/demodb_bk100 1 level incremental backup of the first file. 2 0 /Backup/demodb_bk200 2 level incremental backup of the first file. The path information of a backup file Backup level information The sequence number of a backup volume per level
  • 85.
  • 86. Contains the name, path, and the name of the built host of a DB.
  • 87. Records the information related to the DB that is created in the databases.txt file upon the creation of a DB.
  • 88. Saved to the path in which the $CUBRID_DATABASES environment variables are specified.
  • 89. If it does not exist in the directory specified by the environment variable, the current directory will be used instead.
  • 91. If a host name has been changed or a DB deleted by an OS command, this file must be modified as well.
  • 92. As the user must be able to modify the databases.txt file during DB creation or deletion, the user must have the privilege to write to this file. If a user without the appropriate privilege attempts to create a DB, the DB creation will fail. For this reason, a DBA should enable the user-write privilege for the directory, or create a databases.txt file in the directory of each user and configure the environment variables.demodb /CUBRID/databases/demodb hostname /CUBRID/databases/demodb DB name DB path Host name DB log path
  • 93.
  • 94. Distributes data, index, temp, and log volume so that they are separated from each other
  • 95. Avoids the disk bottlenecks and improves disk management
  • 96. Distributes volumes that can be used simultaneously
  • 97. data & log, data & index, data & temp
  • 98. Configures a volume to an appropriate size to prevent it from adding more volumes while in service
  • 99. Data, Index, Temp, Active Log: Page size and the number of pages must be considered
  • 100.
  • 101.
  • 102. A file in which the value of CUBRIDsystem parameters are saved.
  • 103. The file is located in a subdirectory of $CUBRID/conf . You are recommended to specify different values from one DB to another DB in the DB.
  • 104. There are two types of parameters: DB server parameters and DB client parameters. If a parameter has been changed in a process, that process must be restarted.
  • 105. SQL is used to change a client parameter.
  • 108. The name and value of a parameter must be inserted on the same line.
  • 109. An equals sign (=) can be used, and a blank character can be added at both sides of the sign..
  • 110. If the value of a parameter is a string, insertthe string without quotation marks. If a blank character is included in the string, encase it with quotation marks. [commom] data_buffer_pages=250000 [demodb] data_buffer_pages=500000
  • 111.
  • 112. Add CUBRID_ at the beginning of the parameter to configure it as an environment variable
  • 113. Configuring with an SQL statement
  • 114. Only client parameters can be configured
  • 115. Use “;” for multiple configurationsEnvironment Configuration File- $CUBRID/conf/cubrid.conf set CUBRID_SORT_BUFFER_PAGE=512 SET SYSTEM PARAMETERS 'parameter_name=value [{; name=value}...]‘ SET SYSTEM PARAMETERS 'csql_history_num=70’ SET SYSTEM PARAMETERS 'csql_history_num=70; index_scan_in_oid_order=1'
  • 116.
  • 117. The number of data pages cached to the memory by a DB server
  • 118. Requires an amount of memory equivalent to num_data_buffers times database page size (the page size specified when the DB is initialized; default is 4KB). (The size of the required memory is 100MB if the default is 25,000)
  • 119. The actual size of a DB, the size of the memory, and the number and size of other processes must be considered when determining the size
  • 120. The larger the value, the more data needs to be cached to the memory, which means less disk I/O. However, a value that is too large will cause the full swapping of page buffers.
  • 122. Configure the number of buffer pages in which the OID list is to be temporarily stored when scanning indexes
  • 123.
  • 124. The number of pages used to process queries that require sorting.
  • 125. One sort buffer is allocated to each active client request.
  • 126. The allocated memory is released upon the completion of sorting.
  • 127. A value between 16 and 500 is recommended.
  • 129. Determines the number of buffer pages that cache the temporary results of a query
  • 130.
  • 131. Configures the interval of a checkpoint execution in min./page
  • 132. The larger the value, the more time it takes to recover a DB.
  • 134. Configures whether to keep an archive log in the event of a storage media failure
  • 135. If it is configured to the default value (yes), all active logs will be copied to and stored in an archive log when changes are made to a transaction while the active logs are full.
  • 136.
  • 137. A parameter used to manage transaction concurrency
  • 138. It must be an integer from 1 to 6 or a character string (Default: 3)
  • 139. The larger the value of the parameter, the lower the concurrency
  • 140. SERIALIZABLE: Inaccessible until transaction is complete
  • 141. REPEATABLE: S_LOCK is maintained until the transaction is complete at SELECT
  • 142. READ UNCOMMITTED: Allows incomplete transactions to be read
  • 143.
  • 144. Configures the interval, in seconds, of deadlock detection for stopped transactions.
  • 145. Resolves deadlock by rolling back one of the deadlocked transactions
  • 146. The default value is 1sec.Be sure not to set the interval to a large number, as doing so will allow deadlocks remain undetected for that length of time.
  • 148. Converts to table lock if the number of row locks belonging to a table is greater than the specified value.
  • 149. The default value is 100,000.
  • 150. If this value is small, the table management overhead will be reduced, but the concurrency will be decreased.
  • 151. If this value is large, thetable management overhead is will be increased, but the concurrency will be improved.
  • 153. Specifies the waiting time of a lock
  • 154. If the lock has not been allowed within the specified period of time, the transaction is cancelled, and an error is returned.
  • 155.
  • 156. Configures the maximum number of query plans to be cached to the memory (Default: 1,000)
  • 157. If this value is lower than 1, it will not work - it works only when the value is at least 1.
  • 158. Configures the hint so that query execution plans are created without using cache
  • 159. Use /*+ RECOMPILE +/ in queriesselect /*+ RECOMPILE */ * from record where …
  • 160.
  • 161. Limits Data Definition Language (as known as DDL)
  • 162. The default value should not be no.
  • 164. It does not execute queries if there are no WHERE clauses in an UPDATE/DELETE statement.
  • 165. The default value should not be no.
  • 167. When comparing strings, set it so that it will compare the strings by a single byte.When using Unicode, set it to Yes (for UTF-8).
  • 168.
  • 172. If 1523 is already in use, the parameter must be changed to another port number.
  • 175. This number represents maximum number of DB clients that can be connected to a DB server at the same time, which by extension also means the total number of concurrent transactions. (Defaultvalue:50)
  • 176. The actual number of concurrent users must be considered
  • 177. DB Server restart configuration
  • 179. Automatically restarts a DB server that has been stopped due to a failure
  • 180. The default value when restarting the DB is yes.
  • 181.
  • 183. Enables the asynchronous commit function (Default value: must not be set to no)
  • 184. Returns a commit to a client before the commit log is flushed to a disk
  • 185. When a failure occurs in a DB server, all commit transactions that have not been flushed to a disk will not be able to be recovered.
  • 187. Collects commits that have occurred during the setting in a group, and executes them (Default value: no need to configure)
  • 188.
  • 189.
  • 191. The file can be modified in an editor. Any changes made will be applied when the Broker restarts.
  • 192. To modify the configuration without a restart, use the following command:
  • 196. If an environment variable and its value are incorrect, an error will occur during the restart, which will prevent the restart.% broker_changer <br-name> <conf-name> <conf-value> % broker_changerbroker1sql_log on OK
  • 197. Introduction to Broker Parameters
  • 198. Introduction to Broker Parameters
  • 199. Introduction to Broker Parameters
  • 200. 2.4 Error Log File $CUBRID/log/ $CUBRID/log/server/ $CUBRID/log/broker/ $CUBRID/log/broker/sql_log $CUBRID/log/broker/error_log CUBRRENT_DIRECTORY, $HOME
  • 201.
  • 202. The connection log is a record of the time it takes for each CAS to process a request by Broker.
  • 203. This log has the name of "<broker name>.access" and resides in a directory specified in the ACCESS_LOG of cubrid_broker.conf.1 192.168.100.201 - - 1158198049.151 1158198049.246 2008/09/14 10:40:49 ~ 2008/09/14 10:40:49 29438 - -1 2 192.168.100.201 - - 1158198049.401 1158198049.406 2008/09/14 10:40:49 ~ 2008/09/14 10:40:49 29438 - -1
  • 204.
  • 205. Records the information about an error that has occurred while processing the request from an application client into the broker_name_app_server_num.err fileTime: 02/04/09 13:45:17.687 - SYNTAX ERROR *** ERROR CODE = -493, Tran = 1, EID = 38 Syntax: Unknown class "unknown_tbl". select * from unknown_tbl
  • 206.
  • 207.
  • 208. (39) : The sequence number of the SQL statement group, for prepared statement pooling
  • 209. (PC) : Uses the content stored in the plan cache
  • 210.
  • 212.
  • 218. Important fields: class_name, attr_name, and attr_type
  • 219. Other
  • 226.
  • 227.
  • 228. 3.1 Types, Operators, and Functions
  • 235. 3.2 Comparison of Major SQLs
  • 236.
  • 237. Saves and displays the character set configured in an application as it is.
  • 238. Can specify a character set via the JDBC connection url.
  • 239. Does not support multi-byte characters.
  • 240. Column sizes must be defined to allow sufficient space for multi-byte characters.
  • 241. The length or position value in a string function is processed byte by byte.
  • 242. Functions for joining DBs are not supported.
  • 243. Cannot change the column size by using the ALTER TABLE statement.
  • 244. This will be fixed in a future version.
  • 245. If the prepare statement pooling is used, only one result set can be handled per connection.
  • 246.
  • 247. Pagination(LIMIT RESULT SET) ROWNUM SELECT select_list FROM TABLE1 T1 WHERE T1.A = 'test' AND ROWNUM <= 100 ORDER BY ORDER_COLUMN; ORDERBY_NUM() SELECT select_list FROM TABLE1 T1 WHERE T1.A = 'test' ORDER BY ORDER_COLUMN FOR ORDERBY_NUM() <= 100; LIMIT (from R3.0) SELECT select_list FROM TABLE1 T1 WHERE T1.A = 'test' ORDER BY ORDER_COLUMN LIMIT 1,100;
  • 248. AUTO_INCREMENT and SERIAL SERIAL CREATE SERIAL SERIAL_NAME START WITH 1 MAXVALUE 1000 NOCYCLE; CREATE TABLE TABLE1( seqnumINT, name VARCHAR); INSERT INTO TABLE1 VALUES (SERIAL_NAME.next_value, 'test'); //seqnum=1 AUTO_INCREMENT CREATE TABLE TABLE1( seqnum INT AUTO_INCREMENT(1,1000) NOT NULL, name VARCHAR); INSERT INTO TABLE1 (name) VALUES ('test'); //seqnum=1
  • 249.
  • 250.
  • 251. Configure an index for columns with a good distribution (narrow range), basic keys, and columns which are the connection point for a join.
  • 252.
  • 253. If no index name has been specified, it will be automatically created.
  • 254.
  • 255. Scans indexes only when the cost of index scan specified in the USING INDEX clause is lower than the sequential scan.
  • 256. USING INDEX The index scan is executed unconditionally in the case of index_name(+).
  • 257. For USING INDEX NONE, the sequential scan is executed unconditionally.
  • 258. If more than two index names are specified behind the USING INDEX clause, the appropriate index will be selected by the optimizer.
  • 259.
  • 260. When comparing the value of an index column to NULL,there will be no index scan.Modifying query
  • 261. Create an index to be able to cover search conditions
  • 262. Create an index to be able to cover the ORDER BY sorting condition
  • 263.
  • 264.
  • 265.
  • 266. card: Number of records in an expected result set
  • 267. page#: Expected number of page accesses
  • 268. sel(selectivity): Expected selectivity that satisfies search conditions(card, page#) sel
  • 269.
  • 270.
  • 271. Example of a Display Query Plan (m-join) SELECT/*+ USE_MERGE */ * FROM game, athlete WHEREgame.athlete_code=athlete.code;
  • 272. 4 JDBCandOther Management JDBC Programming Transaction Management
  • 274. The SQL Type and the Java Type
  • 275.
  • 276.
  • 277.
  • 278.
  • 280. Send SQL statement Fetch row Get columns Yes More columns No Yes More rows No ResultSet ... … Connection myConnection = DriverManager.getConnection(url,”user”,”passwd”); Statement myStatement = myConnection.createStatement(); ResultSetrs = myStatement.executeQuery(“SELECT name, title, salary FROM employee”); int I = 0; while (rs.next()) { I++; String empName = rs.getString(“name”); String empTitle = rs.getString(“title”); long empSalary = rs.getLong(“salary”); System.out.println(“Employee ” + empName + ” is “ + empTitle + “ and earns $” + empSalary); } … ...
  • 281.
  • 282. Make sure to return a DB object such as ResultSet or Statement,Connection after it is used.
  • 283. Return occurs when the close() method is called for a corresponding object.
  • 284. If AutoCommit False is used, return occurs after the transaction for a connection(Commit/Rollback) is explicitly finished.
  • 285. If you execute inner query statements, you must allocate a different connection object to each of them.
  • 286. When other transactions occur in a cycle statement that uses retrieved data
  • 287.
  • 288.
  • 289. Lockis managed for each transaction, for tables and records
  • 290. For a record, S-lock is acquired for reading, and X-lock is acquired for writing.
  • 291. To get S-lock for a record, you must get IS-lock for the corresponding table.
  • 292. To get S-lock for a record, you must get IX-lock for the corresponding table.
  • 294. Configuring SIX-lock for a table
  • 295. When a transaction that has S-lock for a table requests X-lock
  • 297. X-lock : The time a transaction is finished (i.e., confirmation or withdrawal time)
  • 298.
  • 299. When reading the schema of a corresponding table
  • 300. When reading the higher-tier or lower-tier table of a corresponding table
  • 301. When the number of records a transaction reads is greater than the lock_escalationvalue
  • 302. Configuring X-lock for a table
  • 303. When modifying a corresponding table
  • 304.
  • 305. Creates an object for lock object unit: table, record)
  • 308. Lock related configuration of a DB server
  • 309. Information of DB clients connected to a DB server
  • 310.
  • 311.
  • 312.
  • 313.
  • 314.
  • 315.
  • 316. For CAS, check its information in the CUBRID broker.
  • 317. Check the order of ID in a broker by using a processID.
  • 318. As the process IDs in the above example are 2908 and 2980, they correspond to ID1 and ID2 of query_editor broker.
  • 319. As 2980is occupying X_LOCK, the corresponding transaction (ID2)must be forced to stop, if necessary.
  • 320. For an application, logic change, etc. may be necessary for the application.
  • 321.
  • 322. Forcibly stop the corresponding transaction (rollback) by using the Killtran command% usage: cubridkilltran [OPTION] database-name valid options: -i, --kill-transaction-index=INDEX kill transaction with transaction INDEX --kill-user-name=ID kill all transactions with user ID --kill-host-name=HOST kill all transactions with client HOST --kill-program-name=NAME kill all transactions with client program NAME -p, --dba-password=PASS password of the DBA user; will prompt if don't specify -d, --display-information display information about active transactions -f, --force kill the transaction without a prompt for verification
  • 324. CUBRID Installation Installing CUBRID (for Windows) Downloading and installing CUBRID. Creating demodb Checking if the CUBRID service tray has started Checking if the CUBRID service has started service, process
  • 325. CUBRID Installation CUBRID manager client Checking if DB is created Starting DB server Checking if there is aJAVA related error message during start Using the Query Editor Executing a simple query: select * from db_class
  • 326. CUBRID Installation Stopping DB Server Stopping CUBRID service Checking process Starting CUBRID service
  • 327. DB creation Creating a DB that satisfies the following conditions Creation location and size of each volume Page size: 4Kb First volume: 5,000p, C:UBRIDatabaseslt;DB name> Log volume: 100,000p, C:UBRIDatabaseslt;DB name>og Data volume: 500,000p, C:UBRIDatabaseslt;DB name> Index volume: 250,000p, C:UBRIDatabaseslt;DB name> Temp volume: 250,000p, C:UBRIDatabaseslt;DB name>
  • 328. DB creation Checking the created volume Checking the content of databases.txt Checking the files in each directory by referring to the volume information file control volumes information volumes log volumes Computer name
  • 329. Schema management Creating a table that satisfies the following conditions Company table (company) Company ID (integer): primary key, company name (string) Customer table (client) CustomerID (integer): not duplicated Customer name, title, email, telephone no., address: Character string create table company ( comp_idint primary key, // company ID comp_namevarchar(200) // company name ); create table client ( client_idint primary key, // customer ID comp_idint, // company ID client_namevarchar(20), // customer name title varchar(10), // title email varchar(100), // email phone varchar(20), // phone no. address varchar(200), // address );
  • 330. Schema management Viewing table information in a CUBRID Manager client
  • 331. Schema management Modifying a table according to the following conditions Re-creating after deleting a primary key Changing type Title: charvarcharor varchar char Adding/changing an initial value Title: Specifying an initial value to ‘new staff’ and deleting it alter class client drop constraint pk_client_client_id alter class client add primary key(client_id) // or (possible to assign PKname),alter class client add constraint pk_id primary key (client_id) alter class client rename attribute title as old_title alter class client add attribute title char(20) update client set title = cast(old_title as char(20)) alter class client drop attribute old_title alter class client change title default 'new staff' alter class client change title default NULL
  • 332. Schema management Index Client A customer name is unique. Add an index whose name is u_name. Title is in reverse order. Add an index whose name is idx1to sort customer names in forward direction. Searching table information by using a catalog Checking the information of a created table Table name, column information, index information create unique index u_name on client(client_name) create index idx1 on client(title desc, client_name) select * from db_class select * from db_attribute where class_name = 'client' select * from db_index where class_name = 'client'
  • 333. Data search and manipulation Insertingdata Insert (10,’company10’), (20,’company20’) into the company table. Insert an arbitrary id,name, and the company ID whose comp_id is 20 into a client table in the insert-select format. Check inserteddata information by selecting rows from the client table. insert into company values (10, 'company10'); insert into company values (10, 'company10'),(20, 'company20'); insert into company (comp_id, comp_name) values (20, 'company20'); insert into client (comp_id, client_id, client_name) select comp_id, 20, 'new staff20'from company where comp_id = 20
  • 334. Data search and manipulation Modifying data insert an arbitraryid and name into a client table. Check the inserted data information by searching for the client table. Change the comp_id to 10 for the data inserted in the client table. Check inserted data information by searching for the client table. insert into client (client_id, client_name) values (30, 'new staff30') update client set comp_id = 10 where client_id = 30
  • 335. Data search and manipulation Data search Retrieve the countries that achieved medals in the 1988 Olympics from the participants and their medal information Table where participants are listed: participant Medal information table : game - Retrievemedal information of the participants in the 1988 Olympics select (select name from nation where code = a.nation_code), medal from participant a, game b where a.host_year = 1988 and a.nation_code = b.nation_code and a.host_year = b.host_year select (select name from nation where code = a.nation_code), medal from participant a left outer join game b on a.nation_code = b.nation_code and a.host_year = b.host_year where a.host_year = 1988
  • 336. Data search and manipulation Usingindex Sorting the cities that have hosted the Olympics in chronological order Table in which the names of cities that have hosted the Olympics are listed: olympic Sorting the cities that have hosted the Olympics, so that the most recent ones appear at the front select host_year,host_nation,host_city from olympic where host_year > '' using index pk_olympic_host_year(+) create index r_year on olympic(host_yeardesc) select host_year, host_nation, host_city from olympic where host_year > '' using index r_year(+) order by host_yeardesc
  • 337.
  • 338. Operators and functions Function Finding an arbitrary number between 1 and 100 Rounding 3.141592653 to the nearest millionth Finding out the number of bus stops where you can catch the No. 10 bus Length of the following string (‘substring xyzxxy’), position of ‘str’, extracting 6 characters from the 4th character, removing ‘xy’ from the string, replacing ‘s’ with ‘S’ select mod(rand(), 100) + 1 from db_root select round(3.141592653, 6), trunc(3.141592653, 6) from db_root select count(sation_id) from bus where bus_num = '10' select length('substring xyzxxy'), instr ('substring xyzxxy', 'str'), substr('substring xyzxxy', 4, 6), rtrim('substring xyzxxy', 'xy'), replace(('substring xyzxxy', 's', 'S')from db_root
  • 339. Operators and functions For the Olympic medals, use 'G' for a 'gold medal,' 'S' for a 'silver medal,' and 'B' for a 'bronze medal.' Olympic medal table : game Use '1900s' for the Olympics held in the 1900s, '2000s' for 2000s, and 'Other' for other years, and calculate the number Olympics held. Table showing Olympics years: olympic select decode(medal, 'G'. 'gold medal', 'S', 'silver medal', 'B', 'bronze medal') from game select case when host_year between 1900 and 1999 then '1900s' when host_year between 2000 and 2999then '2000s' else 'other years'end as years, count(*) from olympic group by case when host_year between 1900 and 1999 then '1900s' when host_year between 2000 and 2999then '2000s' else 'other years'end
  • 340.
  • 341. Modifying the above query using index hint
  • 342. Grouping by host_nation columnselect * from olympic where rownum between 11 and 20 select * from olympic order by host_year for orderby_num() between 11 and 20; select * from olympic order by host_year limit 11, 20; select * from olympic where host_year > 0 and rownum between 11 and 20 using index pk_olympic_host_year(+) select host_nation from olympicwhere rownum between 11 and 20 group by host_nation
  • 343.
  • 344.
  • 345. Insertdata to the autoincrement column
  • 346. Insert no date to the auto increment column
  • 347. Select rows and check the auto increment column values
  • 348. Delete rows and re-insertdatacreate table bbs ( id intauto_increment, title string, cntint default 0 ) insert into bbs(id, title) values(5, 'arbitrary inserting for auto increment') insert into bbs(title) values('auto inserting for auto increment') select * from bbs delete from bbs insert into bbs(title) values('auto inserting for auto increment')