MariaDB的安装

构建 MariaDB Galera Cluster之前,首先安装MariaDB,本文使用的版本是10.1

1.环境准备

主机:

  • MariaDB01(192.168.56.102)
  • MariaDB02(192.168.56.103)
  • MariaDB03(192.168.56.104)

OS: centos6.5
MariaDB版本:10.1

yum源设置
Here is your custom MariaDB YUM repository entry for CentOS. Copy and paste it into a file under /etc/yum.repos.d/ (we suggest naming the file MariaDB.repo or something similar). See "Installing MariaDB with yum" for detailed information.
#翻译:这是您CentOS的自定义MariaDB YUM存储库条目。 将它复制并粘贴到/etc/yum.repos.d/下的文件(我们建议命名文件MariaDB.repo或类似的东西)。 有关详细信息,请参阅“使用yum安装MariaDB”。

vim /etc/yum.repos.d/MariaDB.repo 写入如下内容:

# MariaDB 10.1 CentOS repository list - created -- : UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=

然后执行下列命令导入证书并更新repo

# sudo rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
# yum repolist

如果你对网络质量充满信心,你现在就可以进入第二步的安装maridb了,但是我强烈建议你用下面的这个方法,因为你可能要反复测试重装个几次,毕竟每次都从官网下载不是一件高效的事儿。

就像上面说的,如果你担心和考虑到网络质量不佳的情况,可下载rpm包后自建yum源
http://downloads.mariadb.com/MariaDB/mariadb-10.1/yum/rhel/mariadb-10.1.19-rhel-6-x86_64-rpms.tar 自建yum源方法可问下度娘
或者访问https://mariadb.com/downloads/maxscale下载最新版本的mariadb(它会自动给你选择最新的mariadb的,由于各版本安装配置差异较大,本文只对mariadb10.1版本负责)
对新版感兴趣的可以测试下maxscale方法:
#install MariaDB MaxScale like this:
#https://mariadb.com/downloads/maxscale
yum install maxscale  或者
RPM-ivh https://downloads.mariadb.com/MaxScale/2.0.3/rhel/6/x86_64/maxscale-2.0.3-1.rhel.6.x86_64.rpm
或者依据官方提供的https://downloads.mariadb.com/MaxScale/x.x.x/rhel/6/x86_64/maxscale-x.x.x-.rhel.6.x86_64.rpm最新版本进行安装

2.安装maridb

以下安装过程来源于官网 https://mariadb.com/kb/en/mariadb-enterprise/mariadb-enterprise-installation-guide/
#Install MariaDB Enterprise Server or MariaDB Enterprise Cluster 10.1 like this:

yum install MariaDB-server MariaDB-client

官网还提供了MariaDB Enterprise Cluster 5.5的安装方法,不是本文的重点,直接跳过。
值得注意的是,如果你要安装5.5版本,则后面的cluster集群的安装配置和10.1版本下是完全不一样的,需要高度注意,避免发生混淆和错误。

3.创建执行用户

# groupadd mariadb
# useradd -g mariadb mariadb
# passwd mariadb
# echo 'mariadb ALL=(ALL) ALL' >> /etc/sudoers
# cd /var/lib
# chown -R mariadb:mariadb mysql

4.启动maridb服务

请根据自身系统版本,选择适合的启动方法启动即可。本文安装环境是在centos6.5下,按照4.3进行启动

4.1:On RHEL and CentOS starting with version 7 using systemd, start MariaDB like this: (通过systemd启动mariadb)
# systemctl start mariadb.service

4.2:or on RHEL and CentOS starting with version 7 using systemd, bootstrap the first node of a MariaDB Enterprise Cluster like this:
# galera_new_cluster

4.3:or on RHEL and CentOS before version 7, such as centos6.5, start MariaDB like this:(在centos6.5上仍然按照启动mysql的方法启动mariadb)

# service mysql start

启动时可能会遇到下列错误:
Starting MySQL.161222 11:28:27 mysqld_safe Logging to '/var/lib/mysql/MariaDB03.err'.
 ERROR!
#检查是由于/var/lib/mysql/MariaDB03.err权限的问题,需要执行 su mariadb,在mariadb用户下启动服务

[root@MariaDB03 ~]# cat /var/lib/mysql/MariaDB03.err
:: mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
-- :: [Note] /usr/sbin/mysqld (mysqld 10.1.-MariaDB) starting as process ...
-- :: [ERROR] mysqld: File '/var/lib/mysql/aria_log_control' not found (Errcode: "Permission denied")
-- :: [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/var/lib/mysql/aria_log_control'
-- :: [ERROR] Plugin 'Aria' init function returned error.
-- :: [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
-- :: [Note] InnoDB: Using mutexes to ref count buffer pool pages
-- :: [Note] InnoDB: The InnoDB memory heap is disabled
-- :: [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
-- :: [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
-- :: [Note] InnoDB: Compressed tables use zlib 1.2.
-- :: [Note] InnoDB: Using Linux native AIO
-- :: [Note] InnoDB: Using SSE crc32 instructions
-- :: [Note] InnoDB: Initializing buffer pool, size = 128.0M
-- :: [Note] InnoDB: Completed initialization of buffer pool
-- :: [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
-- :: [ERROR] InnoDB: The system tablespace must be writable!
-- :: [ERROR] Plugin 'InnoDB' init function returned error.
-- :: [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
-- :: [Note] Plugin 'FEEDBACK' is disabled.
-- :: [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
-- :: [ERROR] Unknown/unsupported storage engine: InnoDB
-- :: [ERROR] Aborting
:: mysqld_safe mysqld from pid file /var/lib/mysql/MariaDB03.pid en # su mariadb
$ service mysql start

4.4:or on RHEL and CentOS before version 7, bootstrap the first node of a MariaDB Enterprise Cluster like this:
service mysql bootstrap

5.初始化maridb数据库

在mariadb@MariaDB01 至 mariadb@MariaDB03上分别初始化msyql

[mariadb@MariaDB01 root]# su mariadb
$ sudo mysql_secure_installation

>根据提示进行操作
>由于是测试,密码推荐设置为空,便于后面的操作,正式用的时候再修改密码
>一定要设置不允许root远程访问,这是起码的操守,不要再问为什么了,因为以后也不会再去改它了吧

5.防火墙设置

centos6,root下执行

# iptables -A INPUT -i eth0 -p tcp --dport  -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport -j ACCEPT

如果在centos7下,诸如这样执行:

# firewall-cmd --add-port=/tcp #暂时生效,重启后失效
# firewall-cmd --permanent --add-port=/tcp #永久生效

正式环境务必要配置防火墙的,尤其对于研发的人来说,一定要重视这个问题
如测试用,可关闭防火墙,忽略此配置即可

6.mysql管理和监控工具

MySQL免费性能监控工具-MONyog 分linux和windows版
SQLyog数据库管理 只有windows版
上面的工具说实话我没用过,我更习惯用nginx/zabbix进行监控,用navicat进行管理

7.使用

安装完了,简单测试下吧

[mariadb@MariaDB01 my.cnf.d]$ mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.1.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#看看集群的状态如何

MariaDB [(none)]> show status like 'wsrep%';
+--------------------------+----------------------+
| Variable_name | Value |
+--------------------------+----------------------+
| wsrep_cluster_conf_id | |
| wsrep_cluster_size | |
| wsrep_cluster_state_uuid | |
| wsrep_cluster_status | Disconnected |
| wsrep_connected | OFF |
| wsrep_local_bf_aborts | |
| wsrep_local_index | |
| wsrep_provider_name | |
| wsrep_provider_vendor | |
| wsrep_provider_version | |
| wsrep_ready | OFF |
| wsrep_thread_count | |
+---------------------- MariaDB [(none)]> show variables like 'wsrep_cluster_address';
+-----------------------+------------------------------------------------------+
| Variable_name | Value |
+-----------------------+------------------------------------------------------+
| wsrep_cluster_address | gcomm://192.168.56.102,192.168.56.103,192.168.56.104 | #这个展示是已经配置过集群的,初始安装的这里显示的应该是空,不要被误导啊!
+-----------------------+------------------------------------------------------+
row in set (0.00 sec)

现在还只是个MariaDB10.1的环境,要完成MariaDB Galera Cluster请继续看下一章内容

-本章完-

2017-02-24

构建 MariaDB Galera Cluster 分布式数据库集群(二)的更多相关文章

  1. 构建 MariaDB Galera Cluster 分布式数据库集群(一)

    MariaDB Galera Cluster 介绍 简介 MariaDB集群是MariaDB同步多主机集群,仅支持XtraDB(详见本文结尾注释)/InnoDB存储引擎(虽然有对MyISAM实验支持 ...

  2. 超详细,多图文使用galera cluster搭建mysql集群并介绍wsrep相关参数

    超详细,多图文使用galera cluster搭建mysql集群并介绍wsrep相关参数 介绍galera cluster原理的文章已经有一大堆了,百度几篇看一看就能有相关了解,这里就不赘述了.本文主 ...

  3. MariaDB+Galera+Haproxy+Keepalived搭建集群

    1.MariaDB Galera Cluster介绍 MariaDB Galera Cluster是MariaDB同步多主机集群,它仅支持XtraDB/InnoDB存储引擎,在MySQLInnoDB存 ...

  4. Galera Cluster mysql+keepalived集群部署

    1.卸载mysql 查找本机安装的mysqlrpm -qa | grep -i mysql --nodeps --force rpm -ev MySQL-server-5.6.15-1.el6.x86 ...

  5. 数据库–Cobar分布式数据库集群MySQL中间件

    运行环境: 主机1:Ubuntu14.04 Desktop + MySQL5.5 + JDK 1.7(HP Z400)  内网IP地址:192.168.137.8 NODE1:Ubuntu 13.04 ...

  6. 【线上测试之后的应用】基于MySQL+MHA+Haproxy构建高可用负载均衡数据库集群(详解)

    这里我们先介绍一下MHA是什么,其次就是它的应用与测试,同时为了大家呈现了数据备份案例,最后总结了使用情况以及注意事项和解决办法 一.MHA 概述 MHA(Master High Availabili ...

  7. 使用分布式数据库集群做大数据分析之OneProxy

    一.十亿数据,轻松秒出 实时监控领域有两个显著的特点,一是数据来源很多而且数据量大,有来自监控摄像头.GPS.智能设备等:二是需要实时处理.我们的客户在做实时处理时,就遇到这样的问题.客户的某个数据表 ...

  8. Ubuntu 下 Galera cluster for MySQL 集群安装

    mysql galera cluster官网:http://galeracluster.com/documentation-webpages/ 相关安装教程:(不一定管用) http://blog.c ...

  9. Galera Cluster for MySQL 集群恢复

    node1: 1.rm -rf grastate.dat 2.mysqld_safe --wsrep-recover 3.galera_new_cluster node2: systemctl res ...

随机推荐

  1. 网络接口配置--Bonding

    Bonding 就是讲到快网卡绑定到同一IP地址对外服务,可以实现高可用或者负载均衡.当然,直接给两块网卡设置同一IP地址是不可能的.通过bonding,虚拟一块网卡对外提供连接,物理网卡被修改为同一 ...

  2. 怎么样刷新frameset的整个页面

    <a href="main.html?a=2" target="_parent">?  设置a链接的target属性值为_parent即可

  3. 【Android Developers Training】 80. 管理网络使用

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  4. 机器学习之分类问题实战(基于UCI Bank Marketing Dataset)

    导读: 分类问题是机器学习应用中的常见问题,而二分类问题是其中的典型,例如垃圾邮件的识别.本文基于UCI机器学习数据库中的银行营销数据集,从对数据集进行探索,数据预处理和特征工程,到学习模型的评估与选 ...

  5. Linux上网问题

    开发板运行linux下和主机Windows互ping这块,就是Windows这边已经显示本地连接上了,从Windows ping Linux 可以通 但是在CRT 上ping Windows就没反应了 ...

  6. 遇到attemp to invoke virtual method

    这个很大原因是没有预先初始化sdk,检查application的配置是否配置了application:name

  7. java底层学习---1

    JRE: Java Runtime EnvironmentJDK:Java Development Kit JRE顾名思义是java运行时环境,包含了java虚拟机,java基础类库.是使用java语 ...

  8. Java基础----jdk1.8 反射实验

    (写在最前:还没入门的搬砖工的一本正经的胡说八道) 引言:  最近做到的项目中,需要给对接方提供一个公共接口,根据对方传入的XML文件的rootelement分发调用接口,最简单的使用if-else ...

  9. VMwareTools安装失败提示找不到C headers和gcc目录

    在VMware虚拟机上安装好linux系统后,发现往往不能全屏,也不能设置共享文件夹进行文件共享,这时候可以通过安装VMwareTools这个工具来实现文件拖拽.共享和全屏. 安装的过程不再赘述,关键 ...

  10. maven工程中pom.xml的错误

    更新maven工程,出现如下错误信息. Could not calculate build plan: Failure to transfer org.apache.maven.plugins:mav ...