分类目录归档:MySQL

MySQL

ubuntu修改mysql 5.7数据存储目录datadir

环境:Ubuntu 16.04、mysql5.7

在16.04版本的MySQL数据库,默认是5.7版本的;
想要修改MySQL数据库存储的目录,需要了解mysql配置文件,以及apparmor的配置文件。
这里提一下apparnor 是控制访问权限的,而mysql依赖它,所以不单单是改完mysql配置文件的内容,同样的需要修改apparmor的相应的配置文件。
1.创建MySQL另外存储的目录
mkdir /database/mysql
chmod 700 /database/mysql
chowd mysql:mysq /database/mysql
2.将以前的数据库复制到新的存储目录 (这样避免了再次初始化,并且数据还在)
cp -av /var/lib/mysql/* /database/mysql
3.删除日志 (不删除会报错)
rm -rf /database/mysql/ib_logfile0
rm -rf /database/mysql/ib_logfile1

继续阅读

MYSQL提权总结

最近在测试一个项目,遇到了MYSQL数据库,想尽办法提权,最终都没有成功,很是郁闷,可能是自己很久没有研究过提权导致的吧,总结一下MYSQL提权的各种姿势吧,权当复习了。关于mysql提权的方法也就那么几种,希望也能帮到各位小伙伴们。

一、利用mof提权

前段时间国外Kingcope大牛发布了mysql远程提权0day(MySQL Windows Remote System Level Exploit (Stuxnet technique) 0day),剑心牛对MOF利用进行了分析,如下:
Windows 管理规范 (WMI) 提供了以下三种方法编译到 WMI 存储库的托管对象格式 (MOF) 文件:
方法 1: 运行 MOF 文件指定为命令行参数将 Mofcomp.exe 文件。
方法 2: 使用 IMofCompiler 接口和 $ CompileFile 方法。
方法 3: 拖放到 %SystemRoot%\System32\Wbem\MOF 文件夹的 MOF 文件。
Microsoft 建议您到存储库编译 MOF 文件使用前两种方法。也就是运行 Mofcomp.exe 文件,或使用 IMofCompiler::CompileFile 方法。
第三种方法仅为向后兼容性与早期版本的 WMI 提供,并因为此功能可能不会提供在将来的版本后,不应使用。 继续阅读

Mysql常见问题

1.1 MySQL常见问题

1.Slave I/O: error connecting to master ‘backup@192.168.1.x:3306’-retry-time: 60 retries: 86400,Error_code:1045
解决方法:
从服务器上删除掉所有的二进制日志文件,包括一个数据目录下的master.info文件和hostname-relay-bin开头的文件。
master.info::记录了Mysql主服务器上的日志文件和记录位置、连接的密码。

2. Errorreading packet from server: File ‘/home/mysql/mysqlLog/log.000001’ not found(Errcode: 2) ( server_errno=29)
解决方法:
由于主服务器运行了一段时间,产生了二进制文件,而slave是从log.000001开始读取的,删除主机二进制文件,包括log.index文件。

3.Slave SQL: Error ‘Table ‘xxxx’ doesn’t exist’ on query.Default database: ‘t591’.Query: ‘INSERT INTO `xxxx`(type,post_id,browsenum)
SELECT type,post_id,browsenum FROM xxxx WHEREhitdate=’20090209”, Error_code: 1146

解决方法:
由于slave没有此table表,添加这个表,使用slave start 就可以继续同步。 继续阅读

Galera Cluster

Galera Cluster Documentation

Galera Cluster is a synchronous multi-master database cluster, based on synchronous replication and Oracle’s MySQL/InnoDB. When Galera Cluster is in use, you can direct reads and writes to any node, and you can lose any individual node without interruption in operations and without the need to handle complex failover procedures.

At a high level, Galera Cluster consists of a database server—that is, MySQL or MariaDB—that then uses the Galera Replication Plugin to manage replication. To be more specific, the MySQL replication plugin API has been extended to provide all the information and hooks required for true multi-master, synchronous replication. This extended API is called the Write-Set Replication API, or wsrep API.Galera

Through the wsrep API, Galera Cluster provides certification-based replication. A transaction for replication, the write-set, not only contains the database rows to replicate, but also includes information on all the locks that were held by the database during the transaction. Each node then certifies the replicated write-set against other write-sets in the applier queue. The write-set is then applied, if there are no conflicting locks. At this point, the transaction is considered committed, after which each node continues to apply it to the tablespace.

This approach is also called virtually synchronous replication, given that while it is logically synchronous, the actual writing and committing to the tablespace happens independently, and thus asynchronously on each node. 继续阅读

MySQL Cluster fault tolerance – impact of deployment decisions

MySQL Cluster fault tolerance – impact of deployment decisions

Typical management configuration

Fig 1. Typical management configuration

MySQL Cluster is designed to be a High Availability, Fault Tolerant database where no single failure results in any loss of service.

This is however dependent on how the user chooses to architect the configuration – in terms of which nodes are placed on which physical hosts, and which physical resources each physical host is dependent on (for example if the two blades containing the data nodes making up a particular node group are cooled by the same fan then the failure of that fan could result in the loss of the whole database).

Of course, there’s always the possibility of an entire data center being lost due to earthquake, sabotage etc. and so for a fully available system, you should consider using asynchronous replication to a geographically remote Cluster.

Fig 1. illustrates a typical small configuration with one or more data nodes from different node groups being stored on two different physical hosts and a management node on an independent machines (probably co-located with other applications as its resource requirements are minimal. If any single node (process) or physical host is lost then service can continue.

继续阅读

不同场景下 MySQL 的迁移方案

一 目录


二 为什么要迁移

继续阅读

Configuring MySQL Master-Master Replication

MySQL Master-Master replication adds speed and redundancy for active websites. With replication, two separate MySQL servers act as a cluster. Database clustering is particularly useful for high availability website configurations. Use two separate Linodes to configure database replication, each with private IPv4 addresses.

This guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, you can check our Users and Groups guide.

This guide is written for Debian 7 or Ubuntu 14.04.

Install MySQL

继续阅读

Maatkit–Mysql的高级管理工具集

Maatkit是Mysql的一个高级管理工具集。 官方网站:http://www.maatkit.org/

参考:
http://www.bigheaddba.net/article/ytag/maatkit
http://code.google.com/p/maatkit/

#1安装一系列依赖软件

Perl

perl-DBI.x86_64 : A database access API for perl

perl-DBD-MySQL.x86_64 : A MySQL interface for perl

perl-TermReadKey

wget http://packages.sw.be/perl-TermReadKey/perl-TermReadKey-2.30-3.el5.rf.x86_64.rpm

rpm -ivh perl-TermReadKey-2.30-3.el5.rf.x86_64.rpm 继续阅读