BigData

Mariadb Install (2) - 설치 & 환경설정 installation

IT오이시이 2017. 11. 15. 23:38
728x90

Mariadb Install  (2) - 설치 & 환경설정 installation

 

1. Configure System Environment 
2. MariaDB Galera Cluster installation
3. Install MariaDB Galera Cluster
4. POST Installation Configuration
5. DataBase System Configuration
6. configure DataBase Server
7. configure Swap space
8. REPLICATION CONFIGURATION
9. wsrep CLUSTER ADDRESS
10. Starting The First Cluster Node
11. Adding Second and additional nodes to the Cluster

 

1. Configure  System  Environment

1. Configure System Environment  

1.1. Disabling SELinux for mysqld

 
# semanage permissive -a mysqld_t

 

1.2. Firewall Configuration

# iptables --append INPUT --protocol tcp \
      --source 64.57.102.34 --jump ACCEPT
# iptables --apend INPUT --protocol tcp \
      --source 193.166.33.20 --jump ACCEPT
# iptables --append INPUT --protocol tcp \
      --source 193.125.4.10 --jump ACCEPT
 
# service save iptables
# iptables-save > /etc/sysconfig/iptables

 

1.3. Check Firewall Configuration

* 설정된 Iptables의 정책은 아래 파일에 적용 됩니다.

# Check for update iptables configuration
/etc/sysconfig/iptables
/etc/iptables/iptables.rules

 

2. MariaDB Galera installation

2. MariaDB Galera Cluster installation

 

2.1. Enabling the apt Repository

# apt-get install python-software-properties
$ sudo apt-get install software-properties-common

 

2.2.Add the GnuPG key for the MariaDB repository. 

# apt-key adv --recv-keys --keyserver \
      keyserver.ubuntu.com 0xcbcb082a1bb943db

 

2.3. Add the MariaDB repository to your sources list.

# add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/version/distro release main'

 

     

2.4. Update the local cache.

# apt-get update

 

2.5. Enabling the yum Repository

# vim /etc/yum/repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/version/package
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1

 

3. INSTALLING MARIADB GALERA CLUSTER

3. Install MariaDB Galera Cluster

3.1 Install mariadb packages

# apt-get install mariadb-client \
      mariadb-galera-server \
      galera

 

# yum install MariaDB-client \
      MariaDB-Galera-server \
      galera

 

3.2 Update  mariadb packages with  yum

 - package update by Yum update 

# yum  update MariaDB-compat \
       MariaDB-client MariaDB-common \ 
       MariaDB-backup MariaDB-tokudb-engine \
       MariaDB-server MariaDB-gssapi-server \
       galera jemalloc jemalloc-devel

 

 

4. POST-INSTALLATION CONFIGURATION

4. POST Installation Configuration 

4.1. Create the user and group for the database server.

# groupadd mysql
# useradd -g mysql mysql

 

4.2. Install the database.

# cd /usr/local/mysql
# ./scripts/mysql_install_db --user=mysql

 

4.3. Change the user and group permissions for the base directory.

# chown -R mysql /usr/local/mysql
# chgrp -R mysql /usr/local/mysql

 

4.4. Create a system unit for the database server.

# cp /usr/local/mysql/supported-files/mysql.server \
      /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# chkconfig --add mysql

 

5. Database System CONFIGURATION

5. DataBase System Configuration 

5.1. Edit Dataconfigureation file "my.cnf ".

 - mysql의 환경 파일은 "/etc/my.cnf"를 기본으로 참조 합니다. 여기에 데이터베이스의 환경 설정과 튜닝을 할 수 있습니다.
 - edit the /etc/my.cnf file.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
binlog_format=ROW
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=122M
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=300M; gcache.page_size=300M"
wsrep_cluster_name="example_cluster"
wsrep_cluster_address="gcomm://IP.node1,IP.node2,IP.node3"
wsrep_sst_method=rsync

[mysql_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

6. CONFIGURING DATABASE SERVER

6. configure DataBase Server 

Ensure that mysqld is not bound to 127.0.0.1. This is IP address for localhost. comment it out:

# bind-address = 127.0.0.1

configuration file includes the conf.d/

!includedir /etc/mysql/conf.d/

 set to use row-level replication, as opposed to statement-level replication.

binlog_format=ROW

 

Ensure that the default storage engine is InnoDB

default_storage_engine=InnoDB

InnoDB locking mode for generating auto-increment values is set to interleaved lock mode

innodb_autoinc_lock_mode=2

[Note]

Warning: When innodb_autoinc_lock_mode is set to traditional lock mode, indicated by 0, or to consecutive lock mode, indicated by 1, in Galera Cluster it can cause unresolved deadlocks and make the system unresponsive.

 

InnoDB log buffer is written to file once per second, rather than on each commit, to improve performance.

innodb_flush_log_at_trx_commit=0

[Note]

Warning: While setting innodb_flush_log_at_trx_commit to a value of 0 or 2improves performance, it also introduces certain dangers.

 

Configuring the InnoDB Buffer Pool

innodb_buffer_pool_size=122M

 

7.CONFIGURING SWAP SPACE

7. configure Swap space  

 
$ swapon --summary
Filename        Type        Size     Used    Priority
/dev/sda2       partition   3369980  0       -1
/swap/swap1     file        524284   0       -2
/swap/swap2     file        524284   0       -3

 

you can fix this by creating swap files.

  1. Create an empty file on your disk, set the file size to whatever size you require.Alternatively, you can manage the same using dd.
  2. # dd if=/dev/zero of=/swapfile bs=1M count=512
    
  3. # fallocate -l 512M /swapfile
    
  4. Secure the swap file.This sets the file permissions so that only the root user can read and write to the file. No other user or group member can access it. You can view the results with ls:
  5. $ ls -a / | grep swapfile
    -rw------- 1 root root 536870912 Feb 12 23:55 swapfile
    
  6. # chmod 600 /swapfile
    
  7. Format the swap file.
  8. # mkswap /swapfile
    
  9. Activate the swap file.
  10. # swapon /swapfile
    
  11. Using your preferred text editor, update the /etc/fstab file to include the swap file by adding the following line to the bottom:
  12. /swapfile none swap defaults 0 0

    After you save the /etc/fstab file, you can see the results with swapon.

$ swapon --summary
Filename        Type        Size     Used    Priority
/swapfile       file        524284   0       -1

 

 

8. REPLICATION COnfigureation

8. REPLICATION CONFIGURATION

 
wsrep_cluster_name Use this parameter to set the logical name for your cluster
wsrep_cluster_address Use this parameter to define the IP addresses for the cluster in a comma separated list.
  • wsrep_node_name Use this parameter to define the logical name for the individual node—for convenience.
  • wsrep_node_address Use this parameter to explicitly set the IP address for the individual node. It gets used in the event that the auto-guessing does not produce desirable results.
[mysql]
wsrep_cluster_name=MyCluster
wsrep_cluster_address="gcomm://192.168.0.1,192.168.0.2,192.168.0.3"
wsrep_node_name=MyNode1
wsrep_node_address="192.168.0.1"

 

9. UNDERSTANDING CLUSTER ADDRESSES

9. wsrep CLUSTER ADDRESS

 wsrep_cluster_address parameter 는 다음과 같이 설정 합니다.
 
<backend schema>://<cluster address>[?<option1>=<value1>[&<option2>=<value2>]]

Backend Schem

  • dummy Which provides a pass-through back-end for testing and profiling purposes. It does not connect to any other nodes. It ignores any values given to it.
  • gcomm Which provides the group communications back-end for use in production. It takes an address and has several settings that you can enable through the option list, or by using the wsrep_provider_options parameter.

Cluster Addresses

  • The IP addresses of any current members, in the event that you want to connect to an existing cluster; or,
  • The IP addresses of any possible cluster members, assuming that the list members can belong to no more than one Primary Component;
 

If you start the node without an IP address for this parameter, the node assumes that it is the first node of a new cluster. It initializes a cluster as though you launched mysqld with the --wsrep-new-cluster option.

 

wsrep_cluster_address="gcomm://192.168.0.1, 192.168.0.2, 192.168.0.3 ? gmcast.segment=0 & evs.max_install_timeouts=1"
wsrep_provider=/usr/lib64/libgalera_smm.so

 

 

10. STARTING THE FIRST CLUSTER NODE

10. Starting The First Cluster Node

There is no Primary Component when the cluster starts. In order to initialize it, you need to explicitly tell one node to do so with the --wsrep-new-cluster argument

 

$ service mysql start --wsrep-new-cluster

 

$ systemctl start mysql --wsrep-new-cluster

 

$ /usr/bin/mysqld_bootstrap

 

SHOW STATUS LIKE 'wsrep_cluster_size';

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 1     |
+--------------------+-------+

 

 

11. ADDING ADDITIONAL NODES TO THE CLUSTER

11. Adding Second and additional nodes to the Cluster

# service mysql start
 
# systemctl start mysql
 
SHOW STATUS LIKE 'wsrep_cluster_size';

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 2     |
+--------------------+-------+
 

 

728x90
반응형