In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to carry out the mysql backup platform and django practice. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Mysql backup platform-- django practice
1. Mysql backup platform
1.1.The description of mysql backup platform
Features:
Realize interface backup table and SQL export backup
Methods:
Using django,bootstrap,mysqldump,html to build
Make use of mysqldump to select the backup from the library first
Applicable scenarios:
Backup before launch, daily backup, etc.
1.2. The platform interface is as follows
1.2.1, initial interface
Note: IP addresses and ports are blocked. You can change them when you test them.
The interface is a little ugly, mainly done by the author himself, without the help of development and front-end, and only DBA can be used by himself, so it is simple and practical ~ you can also find the front-end to help beautify ~
1.2.2. Interface for checking library information
Note: enter the library name here, such as my, and click to check the group number corresponding to the library name to get the cluster information corresponding to this library.
That is, cluster 1.
1.2.3. SQL backup method
Note: select the SQL backup method and enter the specific SQL in the input box
Next, determine the cluster number, enter 1, and click submit
Because: html is not familiar with, temporarily do not know how to click 1@my to determine the cluster, later optimization
The backup results are shown in the figure:
Note:
The backup address is the address of the central control computer
Table name is not easy to get, temporarily empty
1.2.4, table mode backup
Note: select TABLE and select table backup mode:
Table structure only, data only, table structure and data all
Fill in the cluster number 1
Enter a table name. Multiple table names can be separated by spaces.
For example: my_db my_cluster my_database
The backup results are shown in the figure:
Note:
That is, all three tables are backed up to the address of the central control computer.
File name: library name _ table name _ time
II. Concrete realization
2.1The installation of python2.7
Tar zvf Python-2.7.10.tar
Cd Python-2.7.10
. / configure-enable-shared-prefix=/usr/local/python27
Make & & make install
Cp / usr/local/python27/lib/libpython2.7.so.1.0 / usr/local/lib
Cd / usr/local/lib
Ln-s libpython2.7.so.1.0 libpython2.7.so
2.2. Build the django environment
Tar zxvf Django-1.11.3.tar.gzcd Django-1.11.3
Python setup.py install
2.3.Install MySQL-python
Tar xvf MySQL-python-1.2.3.tarcd MySQL-python-1.2.3/
Python setup.py build
Python setup.py install
Test to see if ok
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
> import django
> import MySQLdb
> > >
2.4. Database
, create the mysql database, ignore it here
, set up database my, create meta-information table, refer to blog: mysql multi-layer meta-information and query practice (http://blog.itpub.net/28823725/viewspace-2142234/)
Create user dumper@'127.0.0.1' identified by '123456'
Grant select on *. * to dumper@'127.0.0.1'
Grant show view on *. * to dumper@'127.0.0.1'
Grant lock tables on *. * to dumper@'127.0.0.1'
Grant trigger on *. * to dumper@'127.0.0.1'
Query users
Create user dba_read@'127.0.0.1' identified by '123456'
Grant select on *. * to dba_read@'127.0.0.1'
Note: there is only one mysql at the secondary location, which only serves as a meta-information base and a test backup database.
, build data:
Insert into my_server values ((1) 127.0.0.1 (1))
Insert into my_ip values (1, 127.0.0.1), 1, 1, 1, idc1, 7, 2017, July, 24, 2017, July, 24, 2017, July 24, 2017, July 24, 2017.
Insert into my_cluster values (1 meme mythology department 6001 minefield db info',0,1,now (), now (), '1fujie 10 mine10 mine5. 7. 19 page1 mind1 mine1 mindb info')
Insert into my_db values (1pyrrhenium 127.0.0.1magnum now (), now (), 1pyrmne.wrewformakespeare) 1pyrone, 0pence, 1pyrme, data pinch, minql, pinch, peel, pinch, peg, peg, pinch, peg, peel, pinch, pinch, etc.
Insert into my_database values (1 now (), 'dba','dba','succ','db info')
2.5, django details
Create a project
Cd / chunlei/django/
Django-admin.py startproject dba_backup
A directory dba_backup will be generated
Cd / chunlei/django/dba_backup
Ls
Drwxr-xr-x. 3 root root 4096 Jul 24 17:18 dba_backup
-rwxrwxr-x. 1 root root 808 Jul 24 14:56 manage.py
Setting up Profil
Cd / chunlei/django/dba_backup/dba_backup
Vi settings.py
ALLOWED_HOSTS = ['IP address that can be accessed, or write * that is unrestricted']
INSTALLED_APPS = [
'django.contrib.admin'
'django.contrib.auth'
'django.contrib.contenttypes'
'django.contrib.sessions'
'django.contrib.messages'
'django.contrib.staticfiles'
'dba_backup'
]
EMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates'
'DIRS': ['/ chunlei/chunlei/django/dba_backup/dba_backup/templates']
'APP_DIRS': True
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug'
'django.template.context_processors.request'
'django.contrib.auth.context_processors.auth'
'django.contrib.messages.context_processors.messages'
]
}
}
]
TIME_ZONE = 'Asia/Shanghai'
, set the url file of django
From django.conf.urls import url
From django.contrib import admin
From dba_backup.views import sql_export_search_form
From dba_backup.views import sql_export_result
From dba_backup.views import sql_export_sql
Urlpatterns = [
Url (r'^ admin/', admin.site.urls)
Url (r'^ SQL _ export_search_form/$',sql_export_search_form)
Url (r'^ SQL _ export_result/$', sql_export_result)
Url (r'^ SQL _ export_search_form/sql_export_sql/$', sql_export_sql)
]
, write the view file of django
Such as attachment
, django's template web page file
/ chunlei/django/dba_backup/dba_backup
Mkdir templates
Documents as attached
, start django
Cd / chunlei/django/dba_backup
Python manage.py runserver IP: Port
Test use
Http://IP: port number / sql_export_search_form/
You can use it as shown in the picture above.
III. Other
3.1, advantages
Simple and convenient DBA backup, which can be backed up before or on a daily basis
Give priority to finding backup database backup to prevent the performance of the main database from being affected.
Export limit number to prevent performance of slave library from being affected
3.2, shortcomings
The interface is simple and can be optimized later.
The code is untidy, which is done when you are just learning, and can be optimized later.
The above is the editor for you to share how to carry out the mysql backup platform and django practice, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.