Night Goddess – Hare Moon – Goddess Art – Pagan – Wiccan – Mystical

Merhaba;

Bugün birlikte MySQL Cluster 8.0.23 sürümünü RHEL 8.3 ortamına kuracağız. Aşağıda kurulumu yapacağımız sistem bilgileri yer almaktadır.

Yapıda 1x “Management Node”, 1x”SQL Node” ve 2x”Data Node” olacaktır. Bu yapı, test ve eğitim amaçlı olduğu için Vmware üzerinde sanal makineler olarak çalışmaktadır.

Management Node (mgmd):

[root@zero ~]# uname -a

Linux zero 4.18.0-240.15.1.el8_3.x86_64 #1 SMP Wed Feb 3 03:12:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

[root@zero ~]# rpm -qa redhat-release

redhat-release-8.3-1.0.el8.x86_64

[root@zero ~]#

SQL Node (mysqld):

[root@shiina ~]# uname -a

Linux shiina 4.18.0-240.15.1.el8_3.x86_64 #1 SMP Wed Feb 3 03:12:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

[root@shiina ~]# rpm -qa redhat-release

redhat-release-8.3-1.0.el8.x86_64

[root@shiina ~]#

Data Node “A” (ndbd):

[root@nami ~]# uname -a

Linux nami 4.18.0-240.15.1.el8_3.x86_64 #1 SMP Wed Feb 3 03:12:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

[ [root@nami ~]# rpm -qa redhat-release

redhat-release-8.3-1.0.el8.x86_64

[root@nami ~]#

Data Node “B” (ndbd):

[root@tsunade ~]# uname -a

Linux tsunade 4.18.0-240.15.1.el8_3.x86_64 #1 SMP Wed Feb 3 03:12:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

[root@tsunade ~]# rpm -qa redhat-release

redhat-release-8.3-1.0.el8.x86_64

[root@tsunade ~]#

https://dev.mysql.com/downloads/cluster/ adresinden mysql-cluster-community-8.0.23-1.el8.x86_64.rpm-bundle.tar dosyasını indirdik. Tüm sunucularda, bu dosyayı /var/tmp altına kopyaladık. Bu dosyayı açtıktan sonra, aşağıda olan dosyaların geldiğini görüyoruz. Kurulum için https://dev.mysql.com/doc/mysql-cluster-excerpt/8.0/en/mysql-cluster-install-linux-rpm.html linkini takip edeceğim.

[root@tsunade ~]# cd /var/tmp

[root@tsunade tmp]# tar xvf mysql-cluster-community-8.0.23-1.el8.x86_64.rpm-bundle.tar

mysql-cluster-community-client-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-client-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-client-plugins-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-client-plugins-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-common-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-data-node-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-data-node-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-debugsource-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-devel-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-java-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-libs-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-libs-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-management-server-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-management-server-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-ndbclient-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-ndbclient-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-ndbclient-devel-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-nodejs-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-nodejs-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-server-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-server-debug-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-server-debug-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-server-debuginfo-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-test-8.0.23-1.el8.x86_64.rpm

mysql-cluster-community-test-debuginfo-8.0.23-1.el8.x86_64.rpm

[root@tsunade tmp]#

“Data node”lar, “name” ve “tsunade”. Bu iki sisteme aşağıda olan paketleri kurdum.

[root@nami ~]# rpm -qa | grep -i mysql-cluster

mysql-cluster-community-data-node-8.0.23-1.el8.x86_64

mysql-cluster-community-common-8.0.23-1.el8.x86_64

mysql-cluster-community-debuginfo-8.0.23-1.el8.x86_64

mysql-cluster-community-data-node-debuginfo-8.0.23-1.el8.x86_64

[root@nami ~]#

[root@tsunade tmp]# rpm -qa | grep -i mysql-cluster

mysql-cluster-community-data-node-8.0.23-1.el8.x86_64

mysql-cluster-community-data-node-debuginfo-8.0.23-1.el8.x86_64

mysql-cluster-community-common-8.0.23-1.el8.x86_64

mysql-cluster-community-debuginfo-8.0.23-1.el8.x86_64

[root@tsunade tmp]#

“SQL node” shiina. “SQL node”a aşağıda olan paketleri kurdum.

[root@shiina tmp]# rpm -qa | grep -i mysql-cluster

mysql-cluster-community-libs-8.0.23-1.el8.x86_64

mysql-cluster-community-debuginfo-8.0.23-1.el8.x86_64

mysql-cluster-community-server-8.0.23-1.el8.x86_64

mysql-cluster-community-client-8.0.23-1.el8.x86_64

mysql-cluster-community-common-8.0.23-1.el8.x86_64

mysql-cluster-community-client-plugins-8.0.23-1.el8.x86_64

mysql-cluster-community-libs-debuginfo-8.0.23-1.el8.x86_64

[root@shiina tmp]#

“Management node”umuz, zero. Bu “node”a aşağıda olan paketleri kurdum.

[root@zero tmp]# rpm -qa | grep mysql-cluster

mysql-cluster-community-common-8.0.23-1.el8.x86_64

mysql-cluster-community-management-server-debuginfo-8.0.23-1.el8.x86_64

mysql-cluster-community-management-server-8.0.23-1.el8.x86_64

mysql-cluster-community-debuginfo-8.0.23-1.el8.x86_64

[root@zero tmp]#

“Data” ve “SQL” “node”larda “/etc/my.cnf” dosyasına aşağıda olan girişleri eklememiz gerekiyor. Bizim konfigürasyonumuzda, shiina, nami ve tsunade’ye gerekli eklemeleri yaptık.

[mysqld]

# Options for mysqld process:

ndbcluster                     # run NDB storage engine

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[mysql_cluster]

# Options for NDB Cluster processes:

ndb-connectstring=10.1.1.72 # location of management server

zero “management node” üzerinde aşağıda olan konfigürasyonu yaptık.

[root@zero tmp]# mkdir /var/lib/mysql-cluster

[root@zero tmp]# cd /var/lib/mysql-cluster

[root@zero mysql-cluster]#

[root@zero mysql-cluster]# more config.ini

[ndbd default]

# Options affecting ndbd processes on all data nodes:

NoOfReplicas=2   # Number of fragment replicas

DataMemory=98M   # How much memory to allocate for data storage

[ndb_mgmd]

# Management process options:

HostName=10.1.1.72         # Hostname or IP address of management node

DataDir=/var/lib/mysql-cluster # Directory for management node log files

[ndbd]

# Options for data node “A”:

                               # (one [ndbd] section per data node)

HostName=10.1.1.74         # Hostname or IP address

NodeId=2                       # Node ID for this data node

DataDir=/usr/local/mysql/data  # Directory for this data node’s data files

[ndbd]

# Options for data node “B”:

HostName=10.1.1.141         # Hostname or IP address

NodeId=3                       # Node ID for this data node

DataDir=/usr/local/mysql/data  # Directory for this data node’s data files

[mysqld]

# SQL node options:

HostName=10.1.1.73         # Hostname or IP address

                               # (additional mysqld connections can be

                               # specified for this node for various

                               # purposes such as running ndb_restore)

[root@zero mysql-cluster]#

Bu Konfigürasyon tamamlandıktan sonra, artık “mysql cluster”ı açabiliriz. İlk olarak “management node” açılmalı. Ardından “data node”ları açmamız gerekir. En son olarakta “SQL” node’un açılması gerekiyor.

O halde, zero “management node”da aşağıdaki işlemleri yapalım.

[root@zero mysql-cluster]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini

MySQL Cluster Management Server mysql-8.0.23 ndb-8.0.23

2021-03-31 15:01:49 [MgmtSrvr] INFO    — The default config directory ‘/usr/mysql-cluster’ does not exist. Trying to create it…

2021-03-31 15:01:49 [MgmtSrvr] INFO    — Sucessfully created config directory

[root@zero mysql-cluster]#

Her “data node” üzerinde, ndbd prosesini başlatalım. “Data node”larımız nami ve tsunade.

[root@nami mysql]# ndbd

2021-03-31 12:57:28 [ndbd] INFO    — Angel connected to ‘10.1.1.72:1186’

2021-03-31 12:57:28 [ndbd] INFO    — Angel allocated nodeid: 2

[root@nami mysql]#

“ndbd”yi ilk başlattığımda, aşağıda olan hataları verdi. İlgili dizinleri oluşturduktan sonra yukardaki gibi başarılı bir şekilde başladı.

2021-03-31 12:52:12 [ndbd] WARNING — Cannot change directory to ‘/usr/local/mysql/data’, error: 2

2021-03-31 12:52:12 [ndbd] ERROR   — Couldn’t start as daemon, error: ‘Failed to open logfile ‘/usr/local/mysql/data/ndb_2_out.log’ for write, errno: 2′

[root@tsunade ~]# mkdir -p /usr/local/mysql/data

[root@tsunade ~]#

[root@tsunade ~]# ndbd

2021-03-31 15:14:26 [ndbd] INFO    — Angel connected to ‘10.1.1.72:1186’

2021-03-31 15:14:26 [ndbd] INFO    — Angel allocated nodeid: 3

[root@tsunade ~]#

En son adım olarakta, “MySQL node”u başlatmamız gerekiyor. Aşağıdaki şekilde başlatabiliriz.

[root@shiina init.d]# systemctl start mysqld

 [root@shiina init.d]#

[root@shiina init.d]# systemctl status mysqld

● mysqld.service – MySQL Server

  Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

  Active: active (running) since Wed 2021-03-31 15:26:29 +03; 12s ago

    Docs: man:mysqld(8)

          http://dev.mysql.com/doc/refman/en/using-systemd.html

 Process: 116653 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

 Main PID: 116732 (mysqld)

  Status: “Server is operational”

   Tasks: 47 (limit: 49368)

  Memory: 492.3M

  CGroup: /system.slice/mysqld.service

          â””─116732 /usr/sbin/mysqld

Mar 31 15:25:44 shiina systemd[1]: Starting MySQL Server…

Mar 31 15:26:29 shiina systemd[1]: Started MySQL Server.

[root@shiina init.d]#

Aşağıda “MySQL Cluster”ın çalıştığını görüyoruz.

[root@shiina init.d]# ndb_mgm

— NDB Cluster — Management Client —

ndb_mgm> show

Connected to Management Server at: 10.1.1.72:1186

Cluster Configuration

———————

[ndbd(NDB)]    2 node(s)

id=2   @10.1.1.74 (mysql-8.0.23 ndb-8.0.23, Nodegroup: 0, *)

id=3   @10.1.1.141 (mysql-8.0.23 ndb-8.0.23, Nodegroup: 0)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1   @10.1.1.72 (mysql-8.0.23 ndb-8.0.23)

[mysqld(API)]  1 node(s)

id=4 (not connected, accepting connect from 10.1.1.73)

ndb_mgm>

Şimdi, https://dev.mysql.com/doc/world-x-setup/en/ kılavuzunu takip ederek örnek world_x veritabanının konfigürasyonunu yapalım. Bu örnek veritabanını https://dev.mysql.com/doc/index-other.html sayfasından indirebilirsiniz.

MySQL’e bağlanmak için /var/log/mysqld.log dosyasında bize verilen geçici şifreyi öğrenmemiz gerekiyor.

[root@shiina ~]# grep ‘temporary password’ /var/log/mysqld.log

2021-03-31T12:25:53.495420Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 3MindUocHe+;

[root@shiina ~]#

Şifreyi belirledikten sonra aşağıdaki şekilde MySQL’e bağlanabilirsiniz.

[root@shiina ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 17

Server version: 8.0.23-cluster

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

Geçici şifrenizi, ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘New_Password’; komutu ile değiştirebilirsiniz. Ardından, FLUSH PRIVILEGES; çalıştırmanız yeterli. Aşağıda komutları görebilirsiniz.

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ”New_Password ‘;

Query OK, 0 rows affected (0.02 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.01 sec)

mysql>

mysql> SELECT VERSION()\G

*************************** 1. row ***************************

VERSION(): 8.0.23-cluster

1 row in set (0.00 sec)

mysql>

Şimdi; indirdiğimiz veritabanını aşağıdaki şekilde ekleyebiliriz.

mysql> SOURCE /sample_mysql_DB/world_x-db/world_x.sql;

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Aşağıdaki çıktılarda veritabanının sağlıklı yüklendiği görülmektedir.

mysql>

mysql> USE world_x;

Database changed

mysql> SHOW TABLES;

+——————-+

| Tables_in_world_x |

+——————-+

| city             |

| country          |

| countryinfo      |

| countrylanguage  |

+——————-+

4 rows in set (0.01 sec)

 

mysql> SELECT COUNT(*) FROM city;

+———-+

| COUNT(*) |

+———-+

|    4079 |

+———-+

1 row in set (0.00 sec)

mysql> SELECT COUNT(*) FROM country;

+———-+

| COUNT(*) |

+———-+

|     239 |

+———-+

1 row in set (0.00 sec)

mysql>

Aşağıda olan komut ile “storage engine”lerle ilgili bilgi alabiliriz.

[root@shiina ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 19

Server version: 8.0.23-cluster MySQL Cluster Community Server – GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show engines;

+——————–+———+—————————————————————-+————–+——+————+

| Engine            | Support | Comment                                                       | Transactions | XA  | Savepoints |

+——————–+———+—————————————————————-+————–+——+————+

| ndbcluster        | YES    | Clustered, fault-tolerant tables                              | YES         | NO  | NO        |

| FEDERATED         | NO     | Federated MySQL storage engine                                | NULL        | NULL | NULL      |

| MEMORY            | YES    | Hash based, stored in memory, useful for temporary tables     | NO          | NO  | NO        |

| InnoDB            | DEFAULT | Supports transactions, row-level locking, and foreign keys    | YES         | YES | YES       |

| PERFORMANCE_SCHEMA | YES    | Performance Schema                                            | NO          | NO  | NO        |

| MyISAM            | YES    | MyISAM storage engine                                         | NO          | NO  | NO        |

| ndbinfo           | YES    | MySQL Cluster system information storage engine               | NO          | NO  | NO        |

| MRG_MYISAM        | YES    | Collection of identical MyISAM tables                         | NO          | NO  | NO        |

| BLACKHOLE         | YES    | /dev/null storage engine (anything you write to it disappears) | NO          | NO  | NO        |

| CSV               | YES    | CSV storage engine                                            | NO          | NO  | NO        |

| ARCHIVE           | YES    | Archive storage engine                                        | NO          | NO  | NO        |

+——————–+———+—————————————————————-+————–+——+————+

11 rows in set (0.00 sec)

mysql>

Sizin için en uygun “storage engine”ı belirlemek için https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html linkini inceleyebilirsiniz. Az önce eklediğimiz world_x veritabanının hangi “storage engine”ı kullandığını aşağıdaki şekilde görebiliriz. World_x veritabanı için InnoDB’nin kullanıldığı görülüyor.

mysql> USE world_x;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

mysql> SHOW TABLES;

+——————-+

| Tables_in_world_x |

+——————-+

| city             |

| country          |

| countryinfo      |

| countrylanguage  |

+——————-+

4 rows in set (0.00 sec)

mysql> SELECT ENGINE

   -> FROM information_schema.TABLES

   -> WHERE TABLE_SCHEMA = ‘world_x’

   -> AND TABLE_NAME = ‘city’;

+——–+

| ENGINE |

+——–+

| InnoDB |

+——–+

1 row in set (0.00 sec)

mysql>

“Storage engine” bilgisini tablo formatında aşağıdaki gibi de görebiliriz.

mysql> SHOW TABLE STATUS LIKE ‘city’;

+——+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time        | Update_time        | Check_time | Collation         | Checksum | Create_options | Comment |

+——+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

| city | InnoDB |     10 | Dynamic   | 4079 |           128 |     524288 |              0 |           0 |        0 |          4080 | 2021-03-31 19:56:55 | 2021-03-31 19:56:57 | NULL      | utf8mb4_0900_ai_ci |    NULL |               |        |

+——+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

1 row in set (0.40 sec)

mysql> SHOW TABLE STATUS LIKE ‘country’;

+———+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

| Name   | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time        | Update_time        | Check_time | Collation         | Checksum | Create_options | Comment |

+———+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

| country | InnoDB |     10 | Dynamic   | 239 |           205 |      49152 |              0 |           0 |        0 |          NULL | 2021-03-31 19:56:57 | 2021-03-31 19:56:57 | NULL      | utf8mb4_0900_ai_ci |    NULL |               |        |

+———+——–+———+————+——+—————-+————-+—————–+————–+———–+—————-+———————+———————+————+——————–+———-+—————-+———+

1 row in set (0.13 sec)

mysql>

Kullandığımız “storage engine” ile ilgili detaylı komutları https://dev.mysql.com/doc/refman/8.0/en/show-engine.html kılavuzunda bulabiliriz. Aşağıda innodb’nin statüsünü gösteren komutu ve çıktısını görebilirsiniz. Çıktı çok uzun olduğu için biraz kırptım.

mysql> SHOW ENGINE INNODB STATUS;

| InnoDB |     |

=====================================

2021-04-02 13:05:12 0x7f2c881f9700 INNODB MONITOR OUTPUT

=====================================

Per second averages calculated from the last 40 seconds

—————–

BACKGROUND THREAD

—————–

srv_master_thread loops: 2 srv_active, 0 srv_shutdown, 64370 srv_idle

srv_master_thread log flush and writes: 0

———-

SEMAPHORES

———-

OS WAIT ARRAY INFO: reservation count 5

OS WAIT ARRAY INFO: signal count 5

————–

ROW OPERATIONS

————–

0 queries inside InnoDB, 0 queries in queue

0 read views open inside InnoDB

Process ID=51503, Main thread ID=139828890240768 , state=sleeping

Number of rows inserted 0, updated 0, deleted 0, read 0

0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s

Number of system rows inserted 17, updated 315, deleted 17, read 4956

0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s

—————————-

END OF INNODB MONITOR OUTPUT

1 row in set (0.18 sec)

mysql>

Şimdi örnek bir veritabanı oluşturacağız. https://dev.mysql.com/doc/refman/8.0/en/using-innodb-tables.html linkini kullanabilirsiniz.

mysql> create database EngineerDB;

Query OK, 1 row affected, 3 warnings (0.23 sec)

mysql> show tables;

Empty set (0.00 sec)

mysql>

mysql> create table civil_engineer (Name VARCHAR(20),owner VARCHAR(20),Faculty VARCHAR(20), birth DATE, death DATE);

Query OK, 0 rows affected, 5 warnings (0.64 sec)

mysql> show tables;

+———————-+

| Tables_in_EngineerDB |

+———————-+

| civil_engineer      |

+———————-+

1 row in set (0.01 sec)

mysql> describe civil_engineer;

+———+————-+——+—–+———+——-+

| Field  | Type       | Null | Key | Default | Extra |

+———+————-+——+—–+———+——-+

| Name   | varchar(20) | YES |    | NULL   |      |

| owner  | varchar(20) | YES |    | NULL   |      |

| Faculty | varchar(20) | YES |    | NULL   |      |

| birth  | date       | YES |    | NULL   |      |

| death  | date       | YES |    | NULL   |      |

+———+————-+——+—–+———+——-+

5 rows in set (0.21 sec)

mysql> SHOW TABLE STATUS\G

*************************** 1. row ***************************

          Name: civil_engineer

        Engine: InnoDB

       Version: 10

    Row_format: Dynamic

          Rows: 0

 Avg_row_length: 0

   Data_length: 16384

Max_data_length: 0

  Index_length: 0

     Data_free: 0

 Auto_increment: NULL

   Create_time: 2021-04-02 16:08:40

   Update_time: NULL

    Check_time: NULL

     Collation: utf8mb4_0900_ai_ci

      Checksum: NULL

 Create_options:

       Comment:

1 row in set (0.01 sec)

 

mysql>

En son olarak, mysqlsh’ı SQL node, yani shiina üzerine yüklayeceğiz. MySQL Shell (mysqlsh), MySQL için gelişmiş bir komut satırı istemcisi ve kod düzenleyicisidir. MySQL Shell, SQL’e ek olarak JavaScript ve Python için komut dosyası oluşturma yetenekleri de sunmaktadır. MySQL Shell, MySQL Sunucusuna X Protokolü aracılığıyla bağlandığında, X DevAPI hem ilişkisel hem de belge verileriyle çalışmak için kullanılabilir. MySQL Shell, InnoDB Cluster ile çalışmanızı sağlayan AdminAPI’yi içermektedir. Aşağıda kurulum adımlarını görebilirsiniz.

Öncelikle, EPEL repoyu yüklüyoruz.

[root@shiina ~]# sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

sudo dnf upgrade

Updating Subscription Management repositories.

Last metadata expiration check: 0:05:34 ago on Sat 03 Apr 2021 07:52:56 PM +03.

epel-release-latest-8.noarch.rpm                                                                                             27 kB/s | 22 kB    00:00   

Dependencies resolved.

=============================================================================================================================================================

 Package                                Architecture                     Version                            Repository                              Size

=============================================================================================================================================================

Installing:

 epel-release                           noarch                           8-10.el8                           @commandline                            22 k

Transaction Summary

=============================================================================================================================================================

Install 1 Package

Total size: 22 k

Installed size: 32 k

Is this ok [y/N]: y

Is this ok [y/N]: y

Downloading Packages:

Running transaction check

Transaction check succeeded.

Running transaction test

Transaction test succeeded.

Running transaction

 Preparing       :                                                                                                                                    1/1

 Installing      : epel-release-8-10.el8.noarch                                                                                                       1/1

 Running scriptlet: epel-release-8-10.el8.noarch                                                                                                       1/1

 Verifying       : epel-release-8-10.el8.noarch                                                                                                       1/1

Installed products updated.

Installed:

 epel-release-8-10.el8.noarch                                                                                                                              

Complete!

[root@shiina ~]#

Snapd’yi yüklüyoruz.

[root@shiina ~]# sudo yum install snapd

Updating Subscription Management repositories.

Last metadata expiration check: 0:05:52 ago on Sat 03 Apr 2021 08:01:53 PM +03.

Dependencies resolved.

=============================================================================================================================================================

 Package                                  Architecture                      Version                                Repository                       Size

=============================================================================================================================================================

Installing:

 snapd                                    x86_64                            2.49-2.el8                             epel                             19 M

Installing dependencies:

 snap-confine                             x86_64                            2.49-2.el8                             epel                            3.5 M

 snapd-selinux                            noarch                            2.49-2.el8                             epel                            396 k

Transaction Summary

=============================================================================================================================================================

Install 3 Packages

Total download size: 23 M

Installed size: 70 M

Is this ok [y/N]: y

Downloading Packages:

(1/3): snapd-selinux-2.49-2.el8.noarch.rpm                                                                                  1.9 MB/s | 396 kB    00:00   

(2/3): snap-confine-2.49-2.el8.x86_64.rpm                                                                                   2.5 MB/s | 3.5 MB    00:01   

(3/3): snapd-2.49-2.el8.x86_64.rpm                                                                                          3.6 MB/s | 19 MB    00:05   

————————————————————————————————————————————————————-

Total                                                                                                                        3.8 MB/s | 23 MB    00:05    

warning: /var/cache/dnf/epel-fafd94c310c51e1e/packages/snap-confine-2.49-2.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY

Extra Packages for Enterprise Linux 8 – x86_64                                                                              1.6 MB/s | 1.6 kB    00:00   

Importing GPG key 0x2F86D6A1:

 Userid    : “Fedora EPEL (8) <epel@fedoraproject.org>”

 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1

 From      : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

Is this ok [y/N]: y

Key imported successfully

Running transaction check

Transaction check succeeded.

Running transaction test

Transaction test succeeded.

Running transaction

 Preparing       :                                                                                                                                    1/1

 Running scriptlet: snapd-selinux-2.49-2.el8.noarch                                                                                                    1/3

 Installing      : snapd-selinux-2.49-2.el8.noarch                                                                                                    1/3

 Running scriptlet: snapd-selinux-2.49-2.el8.noarch                                                                                                    1/3

 Installing      : snap-confine-2.49-2.el8.x86_64                                                                                                     2/3

 Installing      : snapd-2.49-2.el8.x86_64                                                                                                            3/3

 Running scriptlet: snapd-2.49-2.el8.x86_64                                                                                                            3/3

 Running scriptlet: snapd-selinux-2.49-2.el8.noarch                                                                                                    3/3

 Running scriptlet: snapd-2.49-2.el8.x86_64                                                                                                            3/3

 Verifying       : snap-confine-2.49-2.el8.x86_64                                                                                                      1/3

 Verifying       : snapd-2.49-2.el8.x86_64                                                                                                            2/3

 Verifying       : snapd-selinux-2.49-2.el8.noarch                                                                                                    3/3

Installed products updated.

Installed:

 snap-confine-2.49-2.el8.x86_64                       snapd-2.49-2.el8.x86_64                       snapd-selinux-2.49-2.el8.noarch                      

Complete!

[root@shiina ~]#

Snapd’yi aktifleştiriyoruz.

[root@shiina ~]# sudo systemctl enable –now snapd.socket

Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /usr/lib/systemd/system/snapd.socket.

[root@shiina ~]# sudo ln -s /var/lib/snapd/snap /snap

[root@shiina ~]# which snap

/usr/bin/snap

[root@shiina ~]#

[root@shiina ~]# sudo snap install mysql-shell

Setup snap “snapd” (11402) security profiles                                                                                                              

2021-04-03T20:13:26+03:00 INFO Waiting for automatic snapd restart…

mysql-shell 8.0.23 from Canonical✓ installed

[root@shiina ~]#

mysqlsh komutu sisteme yüklendi. Elbette, .bash_profile dosyasında PATH değişkenine /var/lib/snapd/snap/bin dizinini eklememiz gerekiyor.

[root@shiina ~]# which mysqlsh

/var/lib/snapd/snap/bin/mysqlsh

[root@shiina ~]#

Kurulum sonrası aşağıdaki gibi mysqlsh’ı çalıştırabiliriz.

[root@shiina ~]# mysqlsh

Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory

MySQL Shell 8.0.23

Copyright (c) 2016, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

Other names may be trademarks of their respective owners.

Type ‘\help’ or ‘\?’ for help; ‘\quit’ to exit.

mysql-py> \status

MySQL Shell version 8.0.23

Not Connected.

mysql-py>

Aşağıda olan komut ile SQL node’a bağlanıyoruz.

mysql-py> \connect –mysql root@localhost:3306

Creating a Classic session to ‘root@localhost:3306’

Please provide the password for ‘root@localhost:3306’: ************

Fetching schema names for autocompletion… Press ^C to stop.

Your MySQL connection id is 16

Server version: 8.0.23-cluster MySQL Cluster Community Server – GPL

No default schema selected; type \use <schema> to set one.

mysql-py []>

Statüs komutu ile veritabanı detaylarını görebiliriz.

mysql-py []> \status

MySQL Shell version 8.0.23

Connection Id:               16

Current schema:              

Current user:                root@localhost

SSL:                         Cipher in use: TLS_AES_256_GCM_SHA384 TLSv1.3

Using delimiter:             ;

Server version:              8.0.23-cluster MySQL Cluster Community Server – GPL

Protocol version:            Classic 10

Client library:              8.0.23

Connection:                  localhost via TCP/IP

TCP port:                    3306

Server characterset:         utf8mb4

Schema characterset:         utf8mb4

Client characterset:         utf8mb4

Conn. characterset:          utf8mb4

Result characterset:         utf8mb4

Compression:                 Disabled

Uptime:                      2 days 1 hour 26 min 50.0000 sec

Threads: 4 Questions: 38 Slow queries: 0 Opens: 177 Flush tables: 3 Open tables: 94 Queries per second avg: 0.000

mysql-py []>

MySQL Shell, etkileşimli ve toplu kod (“batch”) yürütme özelliğine sahip MySQL Sunucusu için bir komut satırı shell’idir. Ayrıca, MySQL sunucularıyla çalışmayı ve bunları yönetmeyi daha kolay ve verimli hale getiren çok sayıda API sunmaktadır. 8.0.13 sürümü ile bu API’lerin komut satırından doğrudan kolayca erişilebilir hale getirilmesi için oldukça emek verilmiş görünüyor.  API komut satırı entegrasyonu sayesinde shell global nesneleriyle etkileşime girmenin bu yeni yolunu, geliştiriciler, DBA’lar veya kendi betik dosyalarına yerleşik kabuk komutlarını yerleştirmek isteyen herkes çok sevecek. https://mysqlserverteam.com/mysql-shell-api-command-line-integration-for-devops/ , https://www.slideshare.net/openstackil/mysql-shell-the-daily-tool-for-devs-and-admins-by-vittorio-cioe oldukça güzel açıklamalar mevcut.

3 Nisan 2021 Asiye Yiğit

Kaynakça:

https://mysqlserverteam.com/mysql-shell-api-command-line-integration-for-devops/ , https://www.slideshare.net/openstackil/mysql-shell-the-daily-tool-for-devs-and-admins-by-vittorio-cioe

https://dev.mysql.com/doc/refman/8.0/en/using-innodb-tables.html

https://dev.mysql.com/downloads/cluster/

https://dev.mysql.com/doc/mysql-cluster-excerpt/8.0/en/mysql-cluster-install-linux-rpm.html

https://dev.mysql.com/doc/world-x-setup/en

https://dev.mysql.com/doc/index-other.html

https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-install-linux-quick.html