热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

mariadb主从同步

本文是搭建的mariadb-10.0.17版本的下载地址:https:downloads.mariadb.orginterstitialmariadb-10.0.17sourcemariadb-10.0.17.tar.gzfromhtt

本文是搭建的mariadb-10.0.17版本的下载地址:https://downloads.mariadb.org/interstitial/mariadb-10.0.17/source/mariadb-10.0.17.tar.gz/from/http%3A//ftp.hosteurope.de/mirror/archive.mariadb.org/?serve

master:192.168.1.166

slave:192.168.1.165

1.创建mysql普通账号,设置数据库存储数据的目录,设置权限

[root@zsxyweb3 ~]# groupadd -r mysql

[root@zsxyweb3~]# useradd -r -g mysql -s /sbin/nologin mysql

[root@zsxyweb3~]# mkdir -p /data/mydata

[root@zsxyweb3~]# chown -R mysql:mysql /data

 

2.安装数据库依赖软件包

[root@zsxyweb3~]# yum install -y gcc gcc-c++ make cmake ncurses ncurses libxml2 libxml2-developenssl-devel bison bison-devel ncurses-devel

 

3.上传mariadb包,解压,编译安装。

[root@zsxyweb3 ~]# tar zxvf mariadb-10.0.17.tar.gz

[root@zsxyweb3 mariadb-10.0.17]# cmake-DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/data/mydata-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system-DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci

[root@zsxyweb3 mariadb-10.0.17]# make&& make install

4.复制数据库启动脚本到/etc/init.d/mysqld目录下,修改/etc/my.cnf配置文件。

[root@zsxyweb3mariadb-10.0.17]# cd /app/mysql/

[root@zsxyweb3mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@zsxyweb3mysql]# chmod +x /etc/rc.d/init.d/mysqld

[root@zsxyweb3mysql]# cp support-files/my-large.cnf /etc/my.cnf


5.初始化数据库,启动数据库

[root@zsxyweb3mysql]# scripts/mysql_install_db --user=mysql --datadir=/app/mysql/data

[root@zsxyweb3mysql]#mkdir log

[root@zsxyweb3mysql]#service mysqld start

6.数据库的系统变量

[root@zsxyweb3 mysql]# vim/etc/profile.d/mysqld.sh

export PATH=$PATH:/usr/local/mysql/bin

[root@zsxyweb3 mysql]# source/etc/profile.d/mysqld.sh

[root@zsxyweb3 mysql]# mysql

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

Your MySQL connection id is 148

Server version: 5.5.5-10.0.17-MariaDB-logSource distribution

 

Copyright (c) 2000, 2013, Oracle and/orits affiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

 

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

 

mysql>



7.master192.168.1.166里/etc/my.cnf 如下

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

port = 3306

socket = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 4690M

table_open_cache = 16

sort_buffer_size = 64M

read_buffer_size = 32M

read_rnd_buffer_size = 256M

myisam_sort_buffer_size = 1024M

thread_cache_size = 8

query_cache_size= 128M

log-error=/app/mysql/log/alert.log

slow_query_log_file=/app/mysql/log/slow.log

general_log_file=/app/mysql/log/general.log

datadir = /app/mysql/data

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

[mysqldump]

quick

max_allowed_packet = 4690M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

 

8.slave192.168.1.165里/etc/my.cnf

port = 3306

socket = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

log-error=/app/mysql/log/alert.log

slow_query_log_file=/app/mysql/log/slow.log

general_log_file=/app/mysql/log/general.log

thread_cOncurrency= 8

datadir = /data/mydata

log-bin=mysql-bin

binlog_format=mixed

server-id = 2

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout



9.在master数据库上授权    mysql

mysql> GRANT ALL PRIVILEGES ON *.* TO'root'@'192.168.1.% IDENTIFIED BY 'passwd' WITH GRANT OPTION;

mysql>flush privileges;

mysql> show master status;

+------------------+----------+--------------+------------------+

| File             | Position | Binlog_Do_DB |Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000008 |     2890 |              |                  |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)



10.在从slave mysql

mysql>stop slave;

mysql> change master tomaster_host='192.168.1.166',master_user='root',master_password='passwd',master_log_file='mysql-bin.000008',master_log_pos=2890,master_connect_retry=5,master_heartbeat_period=2,Master_Port=3306;

mysql>flush privileges;

mysql>start slave;

mysql>show slave status\G

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

               Slave_IO_State: Waiting formaster to send event

                  Master_Host: 192.168.1.166

                  Master_User: root

                  Master_Port: 3306

                Connect_Retry: 5

              Master_Log_File: mysql-bin.000008

         Read_Master_Log_Pos: 2890

               Relay_Log_File:zsxyweb3-relay-bin.000002

                Relay_Log_Pos: 1198

       Relay_Master_Log_File: mysql-bin.000008

             Slave_IO_Running: Yes

           Slave_SQL_Running: Yes

              Replicate_Do_DB:

         Replicate_Ignore_DB:

          Replicate_Do_Table:

      Replicate_Ignore_Table:

      Replicate_Wild_Do_Table:

 Replicate_Wild_Ignore_Table:

                   Last_Errno: 0

                   Last_Error:

                 Skip_Counter: 0

         Exec_Master_Log_Pos: 2890

              Relay_Log_Space: 1498

              Until_Condition: None

               Until_Log_File:

                Until_Log_Pos: 0

          Master_SSL_Allowed: No

          Master_SSL_CA_File:

          Master_SSL_CA_Path:

              Master_SSL_Cert:

           Master_SSL_Cipher:

               Master_SSL_Key:

       Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

                Last_IO_Errno: 0

                Last_IO_Error:

               Last_SQL_Errno: 0

               Last_SQL_Error:

 Replicate_Ignore_Server_Ids:

             Master_Server_Id: 1

               Master_SSL_Crl:

          Master_SSL_Crlpath:

                   Using_Gtid: No

                  Gtid_IO_Pos:

1 row in set (0.00 sec)



注:主要看看Slave_IO_Running: Yes Slave_SQL_Running: Yes  是否为yes



推荐阅读
  • centos6.8 下nginx1.10 安装 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • 使用在线工具jsonschema2pojo根据json生成java对象
    本文介绍了使用在线工具jsonschema2pojo根据json生成java对象的方法。通过该工具,用户只需将json字符串复制到输入框中,即可自动将其转换成java对象。该工具还能解析列表式的json数据,并将嵌套在内层的对象也解析出来。本文以请求github的api为例,展示了使用该工具的步骤和效果。 ... [详细]
  • IT方面的论坛太多了,有综合,有专业,有行业,在各个论坛里混了几年,体会颇深,以前是论坛哪里人多 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • REVERT权限切换的操作步骤和注意事项
    本文介绍了在SQL Server中进行REVERT权限切换的操作步骤和注意事项。首先登录到SQL Server,其中包括一个具有很小权限的普通用户和一个系统管理员角色中的成员。然后通过添加Windows登录到SQL Server,并将其添加到AdventureWorks数据库中的用户列表中。最后通过REVERT命令切换权限。在操作过程中需要注意的是,确保登录名和数据库名的正确性,并遵循安全措施,以防止权限泄露和数据损坏。 ... [详细]
  • Node.js学习笔记(一)package.json及cnpm
    本文介绍了Node.js中包的概念,以及如何使用包来统一管理具有相互依赖关系的模块。同时还介绍了NPM(Node Package Manager)的基本介绍和使用方法,以及如何通过NPM下载第三方模块。 ... [详细]
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
  • Linux下安装免费杀毒软件ClamAV及使用方法
    本文介绍了在Linux系统下安装免费杀毒软件ClamAV的方法,并提供了使用该软件更新病毒库和进行病毒扫描的指令参数。同时还提供了官方安装文档和下载地址。 ... [详细]
  • 本文介绍了5个基本Linux命令行工具的现代化替代品,包括du、top和ncdu。这些替代品在功能上进行了改进,提高了可用性,并且适用于现代化系统。其中,ncdu是du的替代品,它提供了与du类似的结果,但在一个基于curses的交互式界面中,重点关注占用磁盘空间较多的目录。 ... [详细]
  • 安装oracle软件1创建用户组、用户和目录bjdb节点下:[rootnode1]#groupadd-g200oinstall[rootnode1]#groupad ... [详细]
  • tcpdump 4.5.1 crash 深入分析
    tcpdump 4.5.1 crash 深入分析 ... [详细]
  • 如何使用人人账号进行快捷登录
    在人人开放平台的技术架构中,一个人人Connect站点也相当于一个人人网应用(App),所以在安装之前你需要申请创建一个应用 ... [详细]
  • 现在比较流行使用静态网站生成器来搭建网站,博客产品着陆页微信转发页面等。但每次都需要对服务器进行配置,也是一个重复但繁琐的工作。使用DockerWeb,只需5分钟就能搭建一个基于D ... [详细]
author-avatar
wtc21232
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有