Thứ Ba, 8 tháng 11, 2022

Triển khai MySQL Cluster trên Windows Server - Part 3

1. Kết nối tới MySQL Server: 



2. ENGINES:

So sánh ENGINES của MySQL Cluster và MySQL Community Server

MySQL Cluster có thêm ndbcluster và ndbinfo.

với Engine=ndbcluseter thì tables sẽ được đồng bộ và lưu trữ trên tất cả data node...


Code:

[TABLE="class: grid, width: 840"]

[TR]

[TD][COLOR=#000000][FONT=Verdana]Server version:5.6.11-ndb-7.3.2-cluster-commercial

-advanced MySQL Cluster Server - Advanced[/FONT][/COLOR][/TD]

[TD][COLOR=#000000][FONT=Verdana]Server version:5.5.15 MySQL Community Server (GPL)[/FONT][/COLOR][/TD]

[/TR]

[TR]

[TD][COLOR=#000000][FONT=Verdana]mysql> SHOW ENGINES\G[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]1. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#ff0000][B][FONT=Verdana]ndbcluster[/FONT][/B][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Clustered, fault-tolerant tables[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]Transactions: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]          XA: NO[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]  Savepoints: NO[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]2. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MRG_MYISAM[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Collection of identical MyISAM tables[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]3. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MyISAM[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: MyISAM storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]4. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#ff0000][B][FONT=Verdana]ndbinfo[/FONT][/B][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: MySQL Cluster system information 

storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]5. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]CSV[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: CSV storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]6. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]BLACKHOLE[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: /dev/null storage engine 

(anything you write to it disappears)[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]7. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]ARCHIVE[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Archive storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]8. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]FEDERATED[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: NO[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Federated MySQL storage engine[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]Transactions: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]          XA: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]  Savepoints: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]9. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]PERFORMANCE_SCHEMA[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Performance Schema[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]10. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]InnoDB[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: DEFAULT[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Supports transactions, 

row-level locking, and foreign keys[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]Transactions: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]          XA: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]  Savepoints: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]11. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MEMORY[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Hash based, stored in memory, 

useful for temporary tables[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]11 rows in set (0.00 sec)[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]mysql>[/FONT][/COLOR][/TD]

[TD][COLOR=#000000][FONT=Verdana]mysql> SHOW ENGINES\G[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]1. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]FEDERATED[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: NO[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Federated MySQL storage engine[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]Transactions: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]          XA: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]  Savepoints: NULL[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]2. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MRG_MYISAM[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Collection of identical MyISAM tables[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]3. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MyISAM[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: MyISAM storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]4. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]BLACKHOLE[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: /dev/null storage engine 

(anything you write to it disappears)[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]5. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]CSV[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: CSV storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]6. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]MEMORY[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Hash based, stored in memory, 

useful for temporary tables[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]7. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]ARCHIVE[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Archive storage engine[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]8. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]InnoDB[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: DEFAULT[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Supports transactions, row-level locking, 

and foreign keys[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]Transactions: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]          XA: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]  Savepoints: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]9. row ***************************[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]      Engine: [/FONT][/COLOR][COLOR=#000000][FONT=Verdana]PERFORMANCE_SCHEMA[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Support: YES[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]     Comment: Performance Schema[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]9 rows in set (0.00 sec)[/FONT][/COLOR]


[COLOR=#000000][FONT=Verdana]mysql>[/FONT][/COLOR]


[/TD]

[/TR]

[/TABLE]



3. import database:

http://downloads.mysql.com/docs/world_innodb.sql.gz


mysql -u root -p world < c:/mcm/world_innodb.sql

(Lưu ý để chạy được lệnh này bạn phải tạo trước database world... [mysql>create database world;])




4. Import lại database world:

mở file world_innodb.sql và sửa lại ENGINE=NDBCLUSTER

với ENGINE=NDBCLUSTER thì các table sẽ sẽ được đồng bộ và lưu trữ trên tất cả các data node:




5. CREATE TABLE:

Tạo một số table mẫu trong database test:

Code:

[COLOR=#000000][FONT=Verdana]CREATE TABLE svuit (id INT,data VARCHAR(100));[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]CREATE TABLE example (id INT,data VARCHAR(100));[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]CREATE TABLE example_innodb (id INT, data VARCHAR(100)) ENGINE=innodb;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]CREATE TABLE example_autoincrement (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, data VARCHAR(100));[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]INSERT INTO example_autoincrement (data) VALUES ('Hello world');[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]SELECT * FROM  example_autoincrement;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]CREATE TABLE example_timestamp (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, data VARCHAR(100), cur_timestamp TIMESTAMP(6)); [/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]INSERT INTO example_timestamp (data) VALUES ('The time of creation is:');[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]SELECT * FROM example_timestamp;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]UPDATE example_timestamp SET data='The current timestamp is: ' WHERE id=1;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]SELECT * FROM example_timestamp;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana]CREATE TABLE example_default_now ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, data VARCHAR(100), created TIMESTAMP DEFAULT NOW());[/FONT][/COLOR]


6. ALTER TABLE:

Sử dụng lệnh ALTER TABLE table_name ENGINE=NDBCLUSTER để chuyển thay đổi ENGINE của table thành NDBCLUSTER

Table svuit và example được thay đổi ENGINE=NDBLUSTER nên sẽ được đồng bộ và lưu trữ trên cả 2 data node:


=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,khóa học pl/sql, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, middleware, hoc solaris, hoc linux, hoc aix, unix, securecrt, xshell, mobaxterm, putty

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master