Home | Chinese Simplified | Chinese Traditional | Essays | Search | Iteye Blog | Oschina Blog | Facebook | Linkedin | EmailDatabase structure version controlHttp://netkiller.github.io/journal/mysql.struct.html Mr.Neo Chen(Chen Jingfeng),Netkiller, Bg7nyt
China Guangdong province Shenzhen Khe Sanh Street, Longhua District, civil Administration
518131
+86 13113668890
+86 755 29812080
<[email protected]>
Copyright? Http://netkiller.github.io
Copyright Notice
Reprint please contact the author, please be sure to indicate the original source of the article and the author's information and this statement.
|
Document Source: |
Http://netkiller.github.io |
Http://netkiller.sourceforge.net |
|
2014-12-17
Summary my series of documents
Netkiller Architect Codex |
Netkiller Developer Codex |
Netkiller PHP Codex |
Netkiller Python Codex |
Netkiller Testing Codex |
Netkiller Cryptography Codex |
Netkiller Linux Codex |
Netkiller Debian Codex |
Netkiller CentOS Codex |
Netkiller FreeBSD Codex |
Netkiller Shell Codex |
Netkiller Security Codex |
Netkiller Web Codex |
Netkiller Monitoring Codex |
Netkiller Storage Codex |
Netkiller Mail Codex |
Netkiller Docbook Codex |
Netkiller Version Codex |
Netkiller Database Codex |
Netkiller PostgreSQL Codex |
Netkiller MySQL Codex |
Netkiller NoSQL Codex |
Netkiller LDAP Codex |
Netkiller Network Codex |
Netkiller Cisco IOS Codex |
Netkiller H3C Codex |
Netkiller Multimedia Codex |
Netkiller Perl Codex |
Netkiller Amateur Radio Codex |
Netkiller DevOps Codex |
Directory
- 1. What is a database structure version control
- 2. Why do you want to do database structure this version control
- 3. When to do database structure this version of the control
- 4. Where to do database structure this version control
- 5. Who will be responsible for database structure This version control
- 6. How to do database structure this version of the control
- 6.1. Installation Scripts
- 6.2. Start the script and stop the script
- 6.3. View the historical version
1. What is a database structure version control
The first thing to say is what is the database structure and what is version control.
Database structure refers to the database table structure, the database definition language exported DDL statements. Composed mainly of CREATE table, DROP table, etc.
Let's talk about something. Versioning, if you are engaged in development work should be easy to understand, version control is to record each change, you can view the history at any time, and can be withdrawn to the specified version.
2. Why do you want to do database structure this version control
In the software development process, it is often necessary to adjust the structure of the database, it is unavoidable, and even many think that after the start, the requirements are not clear, the developer can only create the table according to the understanding requirements. Requirements tend to change, and when changes occur, the code needs to be modified and the table structure avoided. We often just changed the database structure, the demand department has sent to inform, without modification, to maintain the original design. Even after a few weeks ' return.
So we're going to be versioning the changes to the database structure, and the usual practice is to manage the DBA manually, but I think it's completely automated, there's no need to waste human resources, and automation doesn't make a mistake more stable, it just needs to be manually checked for work status.
3. When to do database structure this version of the control
The following scripts can be deployed at any time without any impact on the existing system.
4. Where to do database structure this version control
On the version control server, it is recommended that you push the GIT repository to remote.
5. Who will be responsible for database structure this version control
DBAs and configuration Administrators can do this, and typically DBAs do not touch the repository, it is recommended to create a backup user to the configuration administrator.
6. How to do database structure this version of the control6.1. Installation scripts
First download the script https://github.com/oscm/devops/blob/master/shell/backup.mysql.struct.sh
wget HTTPS://RAW.GITHUBUSERCONTENT.COM/OSCM/DEVOPS/MASTER/SHELL/BACKUP.MYSQL.STRUCT.SHMV backup.mysql.struct.sh/ Usr/local/binchmod +x/usr/local/bin/backup.mysql.struct
Create a backup user
CREATE USER ' backup ' @ ' localhost ' identified by ' Sajepom6bapomofod7xo3e1a52vepe '; GRANT SELECT, LOCK TABLES on *. * to ' backup ' @ ' localhost '; FLUSH privileges; SHOW GRANTS for ' backup ' @ ' localhost ';
Configuration scripts
backup_host= "localhost" database host backup_user= "Backup" Back up user backup_pass= "Chen" Backup password backup_dbname= "test AABBCC" version control those databases, Multiple databases use a space-delimited backup_dir=~/backup database structure there
Initializing the Warehouse
#/usr/local/bin/backup.mysql.struct initinitialized empty Git repository in/www/database/struct/.git/
6.2. Start the script and stop the script
#/usr/local/bin/backup.mysql.structusage:/usr/local/bin/backup.mysql.struct {Init|start|stop|status|restart}
Start Script
#/usr/local/bin/backup.mysql.struct Start
View status
#/usr/local/bin/backup.mysql.struct Status 9644 pts/1 S 0:00/bin/bash/usr/local/bin/backup.mysql.struct Start
Stop script
#/usr/local/bin/backup.mysql.struct Status
6.3. View the historical version
View historical versions with the git log command
# cd/www/database/struct/# git status# on branch masternothing to commit (working directory clean) # git logcommit d38fc62 4c21cad0e2f55f0228bff0c1be981827cauthor:root <[email protected]>date: Wed Dec 12:33:55 +0800 2014-12-17.04:33:55
This is just the database structure version control, more details about version control software, extended reading "Netkiller version Codex"
Database structure version control