windows安装zookeeper_mysql5.7.18的安装与主从复制

CentOS6.7安装mysql5.7.18

a43f53d54ee1eaec335bf89a10f24897.png

1、 解压到/usr/local目录

# tar -zxvf mysql-5.7.18-linux-glibc2.5-i686.tar.gz -C /usr/local

2、 mysql-5.7.18-linux-glibc2.5-i686文件夹重命名为mysql

# cd /usr/local

# mv mysql-5.7.18-linux-glibc2.5-i686/ mysql

欢迎工作一到五年的Java工程师朋友们加入Java程序员开发: 854393687

群内提供免费的Java架构学习资料(里面有高可用、高并发、高性能及分布式、Jvm性能调优、Spring源码,MyBatis,Netty,Redis,Kafka,Mysql,Zookeeper,Tomcat,Docker,Dubbo,Nginx等多个知识点的架构资料)合理利用自己每一分每一秒的时间来学习提升自己,不要再用"没有时间“来掩饰自己思想上的懒惰!趁年轻,使劲拼,给未来的自己一个交代!

3、 新建mysql用户组和mysql用户

# groupadd mysql

# useradd -r -g mysql mysql

4、 新建数据目录

# cd /usr/local/mysql

# mkdir data

5、 更改所有者以及授权755

# cd /usr/local

# chown -R mysql:mysql mysql/

# chmod -R 755 mysql/

 6、 初始化mysqld

# cd /usr/local/mysql

# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

b69b56b988dd2b7fdd1c3e76b81e91d9.png

记录下root的初始密码: GjlI08>p4kDw

7、 将mysqld添加成服务,并启动它

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

建立mysql默认的配置文件/etc/my.cnf,并添加图片中内容

fa8c886f106be84be2a91a38bc2006fa.png

# vim /etc/my.cnf

保存并退出my.cnf,启动mysqld

# service mysqld start

出现如下信息表示启动成功

1d8a90ad806d7f889ef9fe6766719d96.png

查看mysql是否启动成功

# ps -ef|grep mysql

出现如下信息表示启动成功

d2d71b2c679870abf5f3a3de69fa39b8.png

当然也可以查看mysqld的状态

# service mysqld status

eb88e8a8ab7ce904c71b88b8c962974c.png

8、 登录mysql并修改root密码

# cd /usr/local/mysql

# ./bin/mysql -uroot –p

输入初始密码,步骤6中有生成,出现如下信息表示登录成功

3915c8d66a3728d571fd39f7a28b1dc8.png

修改root密码

mysql> SET PASSWORD = PASSWORD('123456');

mysql> FLUSH PRIVILEGES;

初次登录没有修改root的密码,操作数据库会出现如下错误提示,那么需要修改root用户的密码

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

 9、 设置mysql远程可访问(前提是防火墙必须关闭,chkconfig iptables off:设置自动启动为关闭,service iptables stop:关闭防火墙)

先登录到mysql

mysql> use mysql

mysql> update user set host = '192.168.0.4' where user = 'root';

mysql> FLUSH PRIVILEGES;

192.168.0.4即是可远程访问本地mysql的远程ip,若想任意ip都能访问本地mysql,那么只需要将192.168.0.4换成%即可

mysql> update user set host = '%' where user = 'root';

mysql主从复制

windows上mysql做master,linux上mysql做slave,mysql版本是5.7.18;windows的ip为192.168.0.4,linux的ip为192.168.0.223

1、master上开启binlog日志

在mysql的home目录找到my.ini文件(没有则新建),配置上如下内容

[mysqld]# set basedir to your installation pathbasedir=D:mysql-5.7.18# set datadir to the location of your data directorydatadir=D:mysql-5.7.18dataport = 3306log-bin = mysql-bin #[必须]启用二进制日志server-id = 4 #[必须]服务器唯一ID,默认是1,最好取ip的后3位expire-logs-days = 7 #只保留7天的二进制日志,以防磁盘被日志占满binlog-ignore-db = mysql #不备份的数据库binlog-ignore-db = information_schemabinlog-ignore-db = performation_schemabinlog-ignore-db = sysbinlog-do-db=mybatis #需要做复制的数据库名

测试log_bin是否成功开启

mysql> show variables like '%log_bin%';

出现下图,log_bin为ON则表示开启成功,OFF表示开启失败

17c616645d46bba0ccd143746237ffb0.png

2、master的数据库中建立备份账号:backup为用户名,%表示任何远程地址,如下表示密码为1234的任何远程地址的backup都可以连接master主机

mysql> grant replication slave on *.* to 'backup'@'%' identified by '1234';

mysql> use mysql

mysql> select user,authentication_string,host from user;

可看到我们刚创建的备份账号:

b92f1af409564f5df689b001b66a5186.png

3、拷贝数据

重启MySQL服务并设置读取锁定

net stop MySQL

net start MySQL

登录mysql

mysql> flush tables with read lock;

读取锁定的意思是只能读取,不能更新,以便获得一个一致性的快照

查看主服务器上当前的二进制日志名和偏移量值

mysql> show master status G

5f336f9110d2591d79c927c602770ba0.png

复制的过程如下:

70ca43adab7676b9e32a414fc67ace21.png

File表示实现复制功能的日志,即上图中的Binary log;Position则表示binlog日志文件的偏移量之后的都会同步到slave中,那么在偏移量之前的则需要我们手动导入

从master导出数据,然后导入到slave中

另外开一个命令窗口,用mysqldump命令进行数据的导出

db6257b0fc5a3239d28cd4b3c5ae2c5b.png

将d:a.txt拷贝到slave上,然后导入到mysql数据库中,slave上的mybatis数据库不存在则先创建,然后再导入

1d2bb006091320abd40f8d54d4490cc0.png

导出是mysqldump,导入是mysql

4、配置slave(192.168.0.223)

slave是linux环境,mysql的配置文件是/etc/my.cnf,不存在则新建,配上如下内容

[mysqld]basedir=/usr/local/mysqldatadir=/usr/local/mysql/datasocket=/tmp/mysql.sockuser=mysqlport=3306log-bin=mysql-binserver-id=223

重启slave数据库

# service mysqld restart

登录slave数据库,并做如下设置

mysql> stop slave;

mysql> change master to

master_host='192.168.0.4',

master_user='backup',

master_password='1234',

master_log_file='mysql-bin.000005',

master_log_pos=601;

各个参数含义:

master_host 实现复制的主机的IP地址

master_user 实现复制的远程登录master的mysql的用户,在步骤2有设置

master_password 实现复制的远程登录master的mysql的面,在步骤2有设置

master_log_file 实现复制的binlog日志文件 在步骤3标红的框框中

master_log_pos 实现复制的binlog日志文件的偏移量 在步骤3标红的框框中

mysql> start slave;

查看slave从机的状态

mysql> show slave status G

a59134a50b0237e60164cdda38b054b9.png
e502a1f7b1ad064609962b099b49b299.png

若图中标记的那两项的值为Yes,则表示slave设置成功

5、关闭掉主数据库的读取锁定

mysql> unlock tables;

6、测试

前面没出问题的话,那么master上的数据操作都会同步到slave上

欢迎工作一到五年的Java工程师朋友们加入Java程序员开发: 854393687

群内提供免费的Java架构学习资料(里面有高可用、高并发、高性能及分布式、Jvm性能调优、Spring源码,MyBatis,Netty,Redis,Kafka,Mysql,Zookeeper,Tomcat,Docker,Dubbo,Nginx等多个知识点的架构资料)合理利用自己每一分每一秒的时间来学习提升自己,不要再用"没有时间“来掩饰自己思想上的懒惰!趁年轻,使劲拼,给未来的自己一个交代!

我用它来修改ldf,你呢? XVI32 is a free hex-editor with the following main features: - New: Runs on systems with > 2 GB virtual memory - New: Bugfix (script command CHARCON is now working) - Simplified search for Unicode Latin (UTF-16) strings - Script commands BITNOT, BITAND, BITOR, BITXOR, BITSHL, BITSHR - Reload command - Wheel mouse support - Computing of CRC16 (standard) and CRC32 (PKZIP compatible) for complete file and selected block (only if block is currently selected) - Data inspector to view decoded numbers - Built-in script interpreter! Refer to online help for details - Easily works with huge files. Try to open a 60 MB sized text file with some other hex editor (not to speak about Wordpad), then use XVI32... - XVI32 allows to edit files up to 2 GB (enough virtual memory provided, of course) - For your convenience, XVI32 stores settings and last used search strings etc. in XVI32.INI file - Progress indication in percent for most operations - You can abort nearly all operations (reading/writing files, search, replace, print...) - Display of both text (ASCII/ANSI) and hexadecimal representation - Two synchronous cursors in text and hex area - Fully resizeable window (change number of rows and columns) - Font and font size adjustable - Overwrite or insert characters - Insert text or hex string n times - Switch byte offset (address) of first byte between 0 or 1 to examine also record structure of plain text files - Search text or hex string, e.g. find "this text" or find "0D 0A" - Search optionally with joker char, e.g. find "A.C" or "00 2E 2E 00" where "." = "2E" (user-defined) stands for any character - Fast searching algorithm (Quicksearch) for both search directions (down/up) - Count occurences of text or hex string - Replace text or hex string, e.g. replace "0D 0A" by "0A" or replace "0D 0A" by text "EOL" - Extremely fast "replace all" mode (if needed, additional memory is allocated beforehead, not at every single replacing operation) - Auto-fill feature to copy bytes from current address into input field for hex string using right arrow key - Character conversion using self-defined character table - Easy converting of text to hex string in dialogs (e.g. "abc" -> "61 62 63") - Decoding and encoding of 1, 2, 4, and 8 byte integers or 4/8 byte floats in 2 possible byte orders - Bit manipulation (view or set bits) - Open file in Read Only mode (e.g. if opened by another application or to avoid unintentional modifications) - Insert file contents into file - Write block to file - Copy, move or delete block - Clipboard support - Goto address (absolute or relative up/down) - Up to 9 named bookmarks - Enter jump width and jump up/down (useful for files with fixed record length) - Patch BORLAND PASCAL 7.0 EXE files for execution on processors > 200 MHz - Printing with preview or print to file - Easily access most recently used files - No setup programm needed, doesn't write any data to registry - And last, but not least: XVI32 is free!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值