Galera Cluster + Mysql安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Galera Cluster + Mysql安装相关的知识,希望对你有一定的参考价值。
本文主要安装Galera cluster,数据库使用官方mysql-5.6.44。安装时采用轻量级pssh来进行批量安装。概况:
数据库机器:
192.168.1.42
192.168.1.43
192.168.1.44
mysql版本:源码mysql-5.6.44.tar.gz
源码包下载url:https://dev.mysql.com
一、安装Mysql
在每台机器/下创建/data目录,用于mysql数据文件目录。
[[email protected] ~]$ cat hosts.txt
192.168.1.42
192.168.1.43
192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt "sudo mkdir /data/"
[1] 14:37:15 [SUCCESS] 192.168.1.42
[2] 14:37:15 [SUCCESS] 192.168.1.44
[3] 14:37:15 [SUCCESS] 192.168.1.43
将mysql源码文件复制到每台机器
[[email protected] ~]$ pscp.pssh -h hosts.txt mysql-5.6.44.tar.gz /home/elasticsearch/
[1] 14:47:59 [SUCCESS] 192.168.1.42
[2] 14:48:00 [SUCCESS] 192.168.1.44
[3] 14:48:03 [SUCCESS] 192.168.1.43
解压:
[[email protected] ~]$ pssh -h hosts.txt "tar zxvf mysql-5.6.44.tar.gz"
[1] 14:49:03 [SUCCESS] 192.168.1.42
[2] 14:49:04 [SUCCESS] 192.168.1.43
[3] 14:49:04 [SUCCESS] 192.168.1.44
安装依赖包
[[email protected] ~]$ pssh -h hosts.txt "sudo yum install gcc gcc-c++ perl-devel bison bison-devel ncurses-devel cmake autoconf -y"
[1] 14:51:37 [SUCCESS] 192.168.1.42
[2] 14:51:39 [SUCCESS] 192.168.1.44
[3] 14:51:41 [SUCCESS] 192.168.1.43
创建用户:
[[email protected] ~]$ pssh -h hosts.txt "sudo groupadd mysql"
[1] 14:58:03 [SUCCESS] 192.168.1.43
[2] 14:58:03 [SUCCESS] 192.168.1.44
[3] 14:58:03 [SUCCESS] 192.168.1.42
[[email protected] ~]$ pssh -h hosts.txt "sudo useradd -g mysql mysql -d /home/mysql -s /sbin/nologin"
[1] 14:58:16 [SUCCESS] 192.168.1.42
[2] 14:58:16 [SUCCESS] 192.168.1.43
[3] 14:58:16 [SUCCESS] 192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt "sudo mkdir /usr/local/mysql"
[1] 14:58:48 [SUCCESS] 192.168.1.42
[2] 14:58:48 [SUCCESS] 192.168.1.43
[3] 14:58:48 [SUCCESS] 192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt "sudo mkdir /data/mysql/data -p"
[1] 14:59:00 [SUCCESS] 192.168.1.42
[2] 14:59:00 [SUCCESS] 192.168.1.43
[3] 14:59:00 [SUCCESS] 192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt "sudo chown -R mysql:mysql /usr/local/mysql;sudo chown -R mysql:mysql /data/mysql/data/"
[1] 15:01:13 [SUCCESS] 192.168.1.42
[2] 15:01:13 [SUCCESS] 192.168.1.43
[3] 15:01:13 [SUCCESS] 192.168.1.44
编译:
[[email protected] ~]$ pssh -h hosts.txt -t 0 "cd mysql-5.6.44;sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_UNIXODBC=1"
[1] 17:33:19 [SUCCESS] 192.168.1.42
[2] 17:33:48 [SUCCESS] 192.168.1.43
[3] 17:34:01 [SUCCESS] 192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt -t 0 -P "cd mysql-5.6.44;sudo make"
[1] 18:07:16 [SUCCESS] 192.168.1.43
[2] 18:08:27 [SUCCESS] 192.168.1.44
[3] 18:08:45 [SUCCESS] 192.168.1.42
安装:
[[email protected] ~]$ pssh -h hosts.txt -t 0 -P "cd mysql-5.6.44;sudo make install"
[1] 18:11:51 [SUCCESS] 192.168.1.42
[2] 18:12:53 [SUCCESS] 192.168.1.43
[3] 18:13:55 [SUCCESS] 192.168.1.44
初始化:
[[email protected] ~]$ pssh -h hosts.txt -t 0 -P "cd mysql-5.6.44;sudo chmod +x scripts/mysql_install_db"
[1] 18:24:19 [SUCCESS] 192.168.1.42
[2] 18:24:19 [SUCCESS] 192.168.1.43
[3] 18:24:19 [SUCCESS] 192.168.1.44
[[email protected] ~]$ pssh -h hosts.txt -t 0 -P "cd mysql-5.6.44;sudo scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data/ --user=mysql"
[1] 18:30:23 [SUCCESS] 192.168.1.43
[2] 18:30:32 [SUCCESS] 192.168.1.44
[3] 18:30:37 [SUCCESS] 192.168.1.42
以上是关于Galera Cluster + Mysql安装的主要内容,如果未能解决你的问题,请参考以下文章
Galera Cluster5.7 (CentOs7) 集群搭建