Oracle Linux/MySQL
From r00tedvw.com wiki
(Difference between revisions)
(Created page with "=Simple Cluster configuration= Will consist of 5 components: ;Management Node :holds the configuration for MySQL Cluster in a file called config.ini. It also writes a cluster ...") |
|||
Line 7: | Line 7: | ||
;(2) SQL Nodes | ;(2) SQL Nodes | ||
:the most common way to read/write data to the Data Nodes is by using the MySQL Server (aka SQL Node) | :the most common way to read/write data to the Data Nodes is by using the MySQL Server (aka SQL Node) | ||
+ | =Management Node Configuration= | ||
+ | ==yum installation== | ||
+ | While most of the guides I found perform installation directly using the RPM packages, I prefer to install packages from a repository whenever available. [https://dev.mysql.com/downloads/repo/yum/ MySQL provides a YUM repository]. | ||
+ | <nowiki>~$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm | ||
+ | ~$ sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm</nowiki> | ||
+ | Verify you can see the new '''cluster''' packages and search them. | ||
+ | <nowiki>~$ yum repolist all | grep mysql | ||
+ | ~$ yum --enablerepo=mysql-cluster-8.0-community search mysql</nowiki> | ||
+ | Enable the cluster repo by setting <code>enabled=1</code> | ||
+ | <nowiki>~$ sudo vim /etc/yum.repos.d/mysql-community.repo | ||
+ | ... | ||
+ | [mysql-cluster-8.0-community] | ||
+ | name=MySQL Cluster 8.0 Community | ||
+ | baseurl=http://repo.mysql.com/yum/mysql-cluster-8.0-community/el/7/$basearch/ | ||
+ | enabled=1 | ||
+ | gpgcheck=1 | ||
+ | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql</nowiki> | ||
+ | ==package installation== | ||
+ | There are a couple of dependencies we need to install. | ||
+ | <nowiki>~$ sudo yum install -y epel-release && sudo yum install -y perl-Class-MethodMaker</nowiki> | ||
+ | Install the packages | ||
+ | <nowiki> ~$ sudo yum install -y mysql-cluster-community-management-server mysql-cluster-community-client mysql-cluster-community-libs | ||
+ | ==Configure cluster== | ||
+ | Now we can setup a basic configuration file for the cluster. | ||
+ | <nowiki>~$ sudo mkdir -p /var/lib/mysql-cluster | ||
+ | ~$ sudo vim /var/lib/mysql-cluster/config.ini | ||
+ | ... | ||
+ | [ndb_mgmd default] | ||
+ | # Directory for MGM node log files | ||
+ | DataDir=/var/lib/mysql-cluster | ||
+ | |||
+ | [ndb_mgmd] | ||
+ | #Management Node db1 | ||
+ | HostName=rncv-sqlmgmt01.virtual.local | ||
+ | |||
+ | [ndbd default] | ||
+ | NoOfReplicas=2 # Number of replicas | ||
+ | DataMemory=256M # Memory allocate for data storage | ||
+ | IndexMemory=128M # Memory allocate for index storage | ||
+ | #Directory for Data Node | ||
+ | DataDir=/var/lib/mysql-cluster | ||
+ | |||
+ | [ndbd] | ||
+ | #Data Node db2 | ||
+ | HostName=rncv-sqldata01.virtual.local | ||
+ | |||
+ | [ndbd] | ||
+ | #Data Node db3 | ||
+ | HostName=rncv-sqldata02.virtual.local | ||
+ | |||
+ | [mysqld] | ||
+ | #SQL Node db4 | ||
+ | HostName=rncv-sql01.virtual.local | ||
+ | |||
+ | [mysqld] | ||
+ | #SQL Node db5 | ||
+ | HostName=rncv-sql02.virtual.local</nowiki> | ||
+ | Now we can implement the config | ||
+ | <nowiki>~$ sudo ndb_mgmd --config-file=/var/lib/mysql-cluster/config.ini | ||
+ | MySQL Cluster Management Server mysql-8.0.19 ndb-8.0.19 | ||
+ | 2020-02-24 16:17:03 [MgmtSrvr] WARNING -- at line 12: [DB] IndexMemory is deprecated, will use Number bytes on each ndbd(DB) node allocated for storing indexes instead</nowiki> | ||
+ | And finally we can view the implementation: | ||
+ | <nowiki>~$ ndb_mgm | ||
+ | -- NDB Cluster -- Management Client -- | ||
+ | ndb_mgm> show | ||
+ | Connected to Management Server at: localhost:1186 | ||
+ | Cluster Configuration | ||
+ | --------------------- | ||
+ | [ndbd(NDB)] 2 node(s) | ||
+ | id=2 (not connected, accepting connect from rncv-sqldata01.virtual.local) | ||
+ | id=3 (not connected, accepting connect from rncv-sqldata02.virtual.local) | ||
+ | |||
+ | [ndb_mgmd(MGM)] 1 node(s) | ||
+ | id=1 @10.10.0.40 (mysql-8.0.19 ndb-8.0.19) | ||
+ | |||
+ | [mysqld(API)] 2 node(s) | ||
+ | id=4 (not connected, accepting connect from rncv-sql01.virtual.local) | ||
+ | id=5 (not connected, accepting connect from rncv-sql02.virtual.local) | ||
+ | |||
+ | ndb_mgm> quit</nowiki> |
Revision as of 18:33, 24 February 2020
Contents |
Simple Cluster configuration
Will consist of 5 components:
- Management Node
- holds the configuration for MySQL Cluster in a file called config.ini. It also writes a cluster log, and takes part in arbitration to prevent split-brain or network partitioning.
- (2) Data Nodes
- stores the data and the tables. The data nodes takes cares of managing the transactions, recovery, etc
- (2) SQL Nodes
- the most common way to read/write data to the Data Nodes is by using the MySQL Server (aka SQL Node)
Management Node Configuration
yum installation
While most of the guides I found perform installation directly using the RPM packages, I prefer to install packages from a repository whenever available. MySQL provides a YUM repository.
~$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm ~$ sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
Verify you can see the new cluster packages and search them.
~$ yum repolist all | grep mysql ~$ yum --enablerepo=mysql-cluster-8.0-community search mysql
Enable the cluster repo by setting enabled=1
~$ sudo vim /etc/yum.repos.d/mysql-community.repo ... [mysql-cluster-8.0-community] name=MySQL Cluster 8.0 Community baseurl=http://repo.mysql.com/yum/mysql-cluster-8.0-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
package installation
There are a couple of dependencies we need to install.
~$ sudo yum install -y epel-release && sudo yum install -y perl-Class-MethodMaker
Install the packages
~$ sudo yum install -y mysql-cluster-community-management-server mysql-cluster-community-client mysql-cluster-community-libs ==Configure cluster== Now we can setup a basic configuration file for the cluster. <nowiki>~$ sudo mkdir -p /var/lib/mysql-cluster ~$ sudo vim /var/lib/mysql-cluster/config.ini ... [ndb_mgmd default] # Directory for MGM node log files DataDir=/var/lib/mysql-cluster [ndb_mgmd] #Management Node db1 HostName=rncv-sqlmgmt01.virtual.local [ndbd default] NoOfReplicas=2 # Number of replicas DataMemory=256M # Memory allocate for data storage IndexMemory=128M # Memory allocate for index storage #Directory for Data Node DataDir=/var/lib/mysql-cluster [ndbd] #Data Node db2 HostName=rncv-sqldata01.virtual.local [ndbd] #Data Node db3 HostName=rncv-sqldata02.virtual.local [mysqld] #SQL Node db4 HostName=rncv-sql01.virtual.local [mysqld] #SQL Node db5 HostName=rncv-sql02.virtual.local
Now we can implement the config
~$ sudo ndb_mgmd --config-file=/var/lib/mysql-cluster/config.ini MySQL Cluster Management Server mysql-8.0.19 ndb-8.0.19 2020-02-24 16:17:03 [MgmtSrvr] WARNING -- at line 12: [DB] IndexMemory is deprecated, will use Number bytes on each ndbd(DB) node allocated for storing indexes instead
And finally we can view the implementation:
~$ ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 (not connected, accepting connect from rncv-sqldata01.virtual.local) id=3 (not connected, accepting connect from rncv-sqldata02.virtual.local) [ndb_mgmd(MGM)] 1 node(s) id=1 @10.10.0.40 (mysql-8.0.19 ndb-8.0.19) [mysqld(API)] 2 node(s) id=4 (not connected, accepting connect from rncv-sql01.virtual.local) id=5 (not connected, accepting connect from rncv-sql02.virtual.local) ndb_mgm> quit