This presentation reveals many important aspects of the CUBRID Database, including its unique features, future roadmap, comparison with other databases, architecture, etc.
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
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
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).
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.
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
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
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.
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
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.
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.
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.
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)
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
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
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
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
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 );
331. Schema management Modifying a table according to the following conditions Re-creating after deleting a primary key Changing type Title: charvarcharor 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
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
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')