mirror of https://github.com/midoks/mdserver-web
commit
d72d4c8d99
@ -0,0 +1,201 @@ |
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
APPENDIX: How to apply the Apache License to your work. |
||||
|
||||
To apply the Apache License to your work, attach the following |
||||
boilerplate notice, with the fields enclosed by brackets "[]" |
||||
replaced with your own identifying information. (Don't include |
||||
the brackets!) The text should be enclosed in the appropriate |
||||
comment syntax for the file format. We also recommend that a |
||||
file or class name and description of purpose be included on the |
||||
same "printed page" as the copyright notice for easier |
||||
identification within third-party archives. |
||||
|
||||
Copyright [yyyy] [name of copyright owner] |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
@ -0,0 +1,5 @@ |
||||
# mysql-apt |
||||
mysql 在ubuntu,debian的apt安装方式 |
||||
|
||||
|
||||
无法使用 |
@ -0,0 +1,91 @@ |
||||
# coding: utf-8 |
||||
|
||||
import re |
||||
import os |
||||
import sys |
||||
|
||||
sys.path.append(os.getcwd() + "/class/core") |
||||
import mw |
||||
|
||||
|
||||
class mysqlDb: |
||||
__DB_PASS = None |
||||
__DB_USER = 'root' |
||||
__DB_PORT = 3306 |
||||
__DB_HOST = 'localhost' |
||||
__DB_CONN = None |
||||
__DB_CUR = None |
||||
__DB_ERR = None |
||||
__DB_CNF = '/etc/my.cnf' |
||||
|
||||
def __Conn(self): |
||||
'''连接MYSQL数据库''' |
||||
try: |
||||
import mw |
||||
socket = '/www/server/mysql-ya/mysql.sock' |
||||
try: |
||||
import MySQLdb |
||||
except Exception as ex: |
||||
# print('dd') |
||||
self.__DB_ERR = ex |
||||
return False |
||||
try: |
||||
myconf = mw.readFile(self.__DB_CNF) |
||||
rep = "port\s*=\s*([0-9]+)" |
||||
self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) |
||||
except: |
||||
self.__DB_PORT = 3306 |
||||
# print self.__DB_PASS |
||||
#self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root') |
||||
try: |
||||
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, |
||||
port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) |
||||
except MySQLdb.Error as e: |
||||
self.__DB_HOST = '127.0.0.1' |
||||
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, |
||||
port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) |
||||
self.__DB_CUR = self.__DB_CONN.cursor() |
||||
return True |
||||
except MySQLdb.Error as e: |
||||
self.__DB_ERR = e |
||||
return False |
||||
|
||||
def setDbConf(self, conf): |
||||
self.__DB_CNF = conf |
||||
|
||||
def setPwd(self, pwd): |
||||
self.__DB_PASS = pwd |
||||
|
||||
def getPwd(self): |
||||
return self.__DB_PASS |
||||
|
||||
def execute(self, sql): |
||||
# 执行SQL语句返回受影响行 |
||||
if not self.__Conn(): |
||||
return self.__DB_ERR |
||||
try: |
||||
result = self.__DB_CUR.execute(sql) |
||||
self.__DB_CONN.commit() |
||||
self.__Close() |
||||
return result |
||||
except Exception as ex: |
||||
return ex |
||||
|
||||
def query(self, sql): |
||||
# 执行SQL语句返回数据集 |
||||
if not self.__Conn(): |
||||
return self.__DB_ERR |
||||
try: |
||||
self.__DB_CUR.execute(sql) |
||||
result = self.__DB_CUR.fetchall() |
||||
# 将元组转换成列表 |
||||
# data = list(map(list, result)) |
||||
self.__Close() |
||||
return result |
||||
except Exception as ex: |
||||
return ex |
||||
|
||||
# 关闭连接 |
||||
def __Close(self): |
||||
self.__DB_CUR.close() |
||||
self.__DB_CONN.close() |
@ -0,0 +1,97 @@ |
||||
[client] |
||||
user = root |
||||
#password = your_password |
||||
port = 3376 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
default-character-set = UTF8MB4 |
||||
|
||||
[mysqld] |
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid |
||||
user = mysql |
||||
port = 3376 |
||||
mysqlx_port = 33760 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
datadir = {$SERVER_APP_PATH}/data |
||||
log-error = {$SERVER_APP_PATH}/data/error.log |
||||
default_storage_engine = MyISAM |
||||
|
||||
key_buffer_size = 8M |
||||
table_open_cache = 32 |
||||
sort_buffer_size = 256K |
||||
net_buffer_length = 4K |
||||
read_buffer_size = 128K |
||||
read_rnd_buffer_size = 256K |
||||
myisam_sort_buffer_size = 4M |
||||
thread_cache_size = 4 |
||||
lower_case_table_names=0 |
||||
tmp_table_size = 8M |
||||
character-set-server = UTF8MB4 |
||||
|
||||
max_connections = 500 |
||||
max_connect_errors = 100 |
||||
open_files_limit = 2560 |
||||
max_allowed_packet = 128M |
||||
|
||||
#skip-external-locking |
||||
#skip-grant-tables |
||||
#loose-skip-innodb |
||||
#skip-networking |
||||
#skip-name-resolve |
||||
|
||||
log-bin=mysql-bin |
||||
binlog_format=mixed |
||||
server-id = 1 |
||||
slow_query_log=1 |
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log |
||||
long_query_time=3 |
||||
#log_queries_not_using_indexes=on |
||||
|
||||
relay-log=mdserver |
||||
relay-log-index=mdserver |
||||
|
||||
#master |
||||
#binlog-do-db |
||||
binlog-ignore-db = test |
||||
binlog-ignore-db = mysql |
||||
binlog-ignore-db = information_schema |
||||
binlog-ignore-db = performance_schema |
||||
|
||||
#slave |
||||
log-slave-updates |
||||
#replicate-do-db |
||||
replicate-ignore-db = information_schema |
||||
replicate-ignore-db = performance_schema |
||||
replicate-ignore-db = mysql |
||||
replicate-ignore-db = test |
||||
|
||||
default_storage_engine = InnoDB |
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_data_file_path = ibdata1:10M:autoextend |
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_buffer_pool_size = 16M |
||||
innodb_log_file_size = 5M |
||||
innodb_log_buffer_size = 8M |
||||
innodb_flush_log_at_trx_commit = 1 |
||||
innodb_lock_wait_timeout = 120 |
||||
innodb_max_dirty_pages_pct = 90 |
||||
innodb_read_io_threads = 1 |
||||
innodb_write_io_threads = 1 |
||||
innodb_file_per_table=1 |
||||
binlog_expire_logs_seconds=2592000 |
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp |
||||
|
||||
[mysqldump] |
||||
quick |
||||
|
||||
[mysql] |
||||
no-auto-rehash |
||||
|
||||
[myisamchk] |
||||
key_buffer_size = 20M |
||||
sort_buffer_size = 20M |
||||
read_buffer = 2M |
||||
write_buffer = 2M |
||||
|
||||
[mysqlhotcopy] |
||||
interactive-timeout |
@ -0,0 +1,98 @@ |
||||
[client] |
||||
user = root |
||||
#password = your_password |
||||
port = 3386 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
default-character-set = UTF8MB4 |
||||
|
||||
[mysqld] |
||||
default_authentication_plugin=mysql_native_password |
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid |
||||
user = mysql |
||||
port = 3386 |
||||
mysqlx_port = 33860 |
||||
socket = {$SERVER_APP_PATH}/mysql.sock |
||||
datadir = {$SERVER_APP_PATH}/data |
||||
log-error = {$SERVER_APP_PATH}/data/error.log |
||||
default_storage_engine = MyISAM |
||||
|
||||
key_buffer_size = 8M |
||||
table_open_cache = 32 |
||||
sort_buffer_size = 256K |
||||
net_buffer_length = 4K |
||||
read_buffer_size = 128K |
||||
read_rnd_buffer_size = 256K |
||||
myisam_sort_buffer_size = 4M |
||||
thread_cache_size = 4 |
||||
lower_case_table_names=0 |
||||
tmp_table_size = 8M |
||||
character-set-server = UTF8MB4 |
||||
|
||||
max_connections = 500 |
||||
max_connect_errors = 100 |
||||
open_files_limit = 2560 |
||||
max_allowed_packet = 128M |
||||
|
||||
#skip-external-locking |
||||
#skip-grant-tables |
||||
#loose-skip-innodb |
||||
#skip-networking |
||||
#skip-name-resolve |
||||
|
||||
log-bin=mysql-bin |
||||
binlog_format=mixed |
||||
server-id = 1 |
||||
slow_query_log=1 |
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log |
||||
long_query_time=3 |
||||
#log_queries_not_using_indexes=on |
||||
|
||||
relay-log=mdserver |
||||
relay-log-index=mdserver |
||||
|
||||
#master |
||||
#binlog-do-db |
||||
binlog-ignore-db = test |
||||
binlog-ignore-db = mysql |
||||
binlog-ignore-db = information_schema |
||||
binlog-ignore-db = performance_schema |
||||
|
||||
#slave |
||||
log_replica_updates |
||||
#replicate-do-db |
||||
replicate-ignore-db = information_schema |
||||
replicate-ignore-db = performance_schema |
||||
replicate-ignore-db = mysql |
||||
replicate-ignore-db = test |
||||
|
||||
default_storage_engine = InnoDB |
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_data_file_path = ibdata1:10M:autoextend |
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data |
||||
innodb_buffer_pool_size = 16M |
||||
innodb_log_file_size = 5M |
||||
innodb_log_buffer_size = 8M |
||||
innodb_flush_log_at_trx_commit = 1 |
||||
innodb_lock_wait_timeout = 120 |
||||
innodb_max_dirty_pages_pct = 90 |
||||
innodb_read_io_threads = 1 |
||||
innodb_write_io_threads = 1 |
||||
innodb_file_per_table=1 |
||||
binlog_expire_logs_seconds=2592000 |
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp |
||||
|
||||
[mysqldump] |
||||
quick |
||||
|
||||
[mysql] |
||||
no-auto-rehash |
||||
|
||||
[myisamchk] |
||||
key_buffer_size = 20M |
||||
sort_buffer_size = 20M |
||||
read_buffer = 2M |
||||
write_buffer = 2M |
||||
|
||||
[mysqlhotcopy] |
||||
interactive-timeout |
@ -0,0 +1,43 @@ |
||||
CREATE TABLE IF NOT EXISTS `config` ( |
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, |
||||
`mysql_root` TEXT |
||||
); |
||||
|
||||
INSERT INTO `config` (`id`, `mysql_root`) VALUES (1, 'admin'); |
||||
|
||||
CREATE TABLE IF NOT EXISTS `databases` ( |
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, |
||||
`pid` INTEGER, |
||||
`name` TEXT, |
||||
`username` TEXT, |
||||
`password` TEXT, |
||||
`accept` TEXT, |
||||
`rw` TEXT DEFAULT 'rw', |
||||
`ps` TEXT, |
||||
`addtime` TEXT |
||||
); |
||||
-- ALTER TABLE `databases` ADD COLUMN `rw` TEXT DEFAULT 'rw'; |
||||
|
||||
CREATE TABLE IF NOT EXISTS `master_replication_user` ( |
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, |
||||
`username` TEXT, |
||||
`password` TEXT, |
||||
`accept` TEXT, |
||||
`ps` TEXT, |
||||
`addtime` TEXT |
||||
); |
||||
|
||||
-- 从库配置主库的[ssh private key] |
||||
-- drop table `slave_id_rsa`; |
||||
CREATE TABLE IF NOT EXISTS `slave_id_rsa` ( |
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT, |
||||
`ip` TEXT, |
||||
`port` TEXT, |
||||
`user` TEXT, |
||||
`db_user` TEXT, |
||||
`id_rsa` TEXT, |
||||
`ps` TEXT, |
||||
`addtime` TEXT |
||||
); |
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,58 @@ |
||||
<div class="bt-form"> |
||||
<div class='plugin_version'></div> |
||||
<div class="bt-w-main"> |
||||
<div class="bt-w-menu"> |
||||
<script type="text/javascript">console.log($('.plugin_version').attr('version'));</script> |
||||
<p class="bgw" onclick="pluginService('mysql-apt', $('.plugin_version').attr('version'));">服务</p> |
||||
<p onclick="pluginInitD('mysql-apt', $('.plugin_version').attr('version'));">自启动</p> |
||||
<p onclick="pluginConfig('mysql-apt', $('.plugin_version').attr('version'));">配置文件</p> |
||||
<p onclick="myDbPos();">存储位置</p> |
||||
<p onclick="myPort();">端口</p> |
||||
<p onclick="runInfo();">当前状态</p> |
||||
<p onclick="myPerfOpt();">性能优化</p> |
||||
<p onclick="myLogs();">日志</p> |
||||
<p onclick="pluginLogs('mysql-apt',$('.plugin_version').attr('version'),'error_log');">错误日志</p> |
||||
<p onclick="pluginLogs('mysql-apt',$('.plugin_version').attr('version'),'show_log');">慢日志</p> |
||||
<p onclick="dbList()">管理列表</p> |
||||
</div> |
||||
<div class="bt-w-con pd15"> |
||||
<div class="soft-man-con"></div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
|
||||
<style type="text/css"> |
||||
.db_list{ |
||||
padding: 0px 0 10px 0; |
||||
font-size: 13px; |
||||
line-height: 35px; |
||||
height: 45px; |
||||
} |
||||
.db_list a{ |
||||
margin-right: 15px; |
||||
color: #555; |
||||
font-weight: 600; |
||||
} |
||||
.db_list span:nth-child(1){ |
||||
display: block; |
||||
float: left; |
||||
padding-left: 15px; |
||||
background: #ececec; |
||||
border-radius: 3px; |
||||
} |
||||
|
||||
#db_tools button { |
||||
margin-right: 10px; |
||||
} |
||||
#db_tools button:last-child{ |
||||
margin-right: 0; |
||||
} |
||||
</style> |
||||
<script type="text/javascript"> |
||||
resetPluginWinWidth(800); |
||||
$.getScript( "/plugins/file?name=mysql-apt&f=js/mysql-apt.js", function(){ |
||||
pluginService('mysql-apt',$('.plugin_version').attr('version')); |
||||
}); |
||||
</script> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,17 @@ |
||||
{ |
||||
"title":"MySQL[APT]", |
||||
"tip":"soft", |
||||
"name":"mysql-apt", |
||||
"type":"运行环境", |
||||
"ps":"[勿用]一种关系数据库管理系统(极速安装)[YUM|APT]!", |
||||
"todo_versions":["5.7","8.0"], |
||||
"versions":["5.7","8.0"], |
||||
"shell":"install.sh", |
||||
"install_pre_inspection":true, |
||||
"checks":"server/mysql-apt", |
||||
"path":"server/mysql-apt", |
||||
"author":"mysql", |
||||
"home":"https://dev.mysql.com/downloads/mysql", |
||||
"date":"2022-06-29", |
||||
"pid": "6" |
||||
} |
@ -0,0 +1,50 @@ |
||||
# Copyright (c) 2015, 2022, Oracle and/or its affiliates. |
||||
# |
||||
# This program is free software; you can redistribute it and/or modify |
||||
# it under the terms of the GNU General Public License, version 2.0, |
||||
# as published by the Free Software Foundation. |
||||
# |
||||
# This program is also distributed with certain software (including |
||||
# but not limited to OpenSSL) that is licensed under separate terms, |
||||
# as designated in a particular file or component or in included license |
||||
# documentation. The authors of MySQL hereby grant you an additional |
||||
# permission to link the program and your derivative works with the |
||||
# separately licensed software that they have included with MySQL. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License, version 2.0, for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
|
||||
# MySQL systemd service file |
||||
|
||||
[Unit] |
||||
Description=MySQL Community Server |
||||
Documentation=man:mysqld(8) |
||||
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html |
||||
After=network.target |
||||
|
||||
[Install] |
||||
WantedBy=multi-user.target |
||||
|
||||
[Service] |
||||
User=mysql |
||||
Group=mysql |
||||
Type=notify |
||||
ExecStartPre=+/usr/share/mysql-8.0/mysql-systemd-start pre |
||||
ExecStart=/usr/sbin/mysqld |
||||
TimeoutSec=0 |
||||
LimitNOFILE = 10000 |
||||
Restart=on-failure |
||||
RestartPreventExitStatus=1 |
||||
|
||||
# Always restart when mysqld exits with exit code of 16. This special exit code |
||||
# is used by mysqld for RESTART SQL. |
||||
RestartForceExitStatus=16 |
||||
|
||||
# Set enviroment variable MYSQLD_PARENT_PID. This is required for restart. |
||||
Environment=MYSQLD_PARENT_PID=1 |
@ -0,0 +1,47 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
|
||||
# curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash |
||||
|
||||
# cd /www/server/mdserver-web/plugins/mysql-apt && bash install.sh install 8.0 |
||||
# cd /www/server/mdserver-web/plugins/mysql-apt && bash install.sh uninstall 8.0 |
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mysql-apt/index.py start 8.0 |
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
|
||||
|
||||
action=$1 |
||||
type=$2 |
||||
|
||||
|
||||
|
||||
if [ "${2}" == "" ];then |
||||
echo '缺少安装脚本...' > $install_tmp |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ ! -d $curPath/versions/$2 ];then |
||||
echo '缺少安装脚本2...' > $install_tmp |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ "${action}" == "uninstall" ];then |
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-apt/index.py stop ${type} |
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-apt/index.py initd_uninstall ${type} |
||||
cd $curPath |
||||
fi |
||||
|
||||
sh -x $curPath/versions/$2/install.sh $1 |
||||
|
||||
if [ "${action}" == "install" ];then |
||||
# #初始化 |
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-apt/index.py start ${type} |
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-apt/index.py initd_install ${type} |
||||
fi |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,119 @@ |
||||
# coding: utf-8 |
||||
#----------------------------- |
||||
# 网站备份工具 |
||||
#----------------------------- |
||||
|
||||
import sys |
||||
import os |
||||
|
||||
if sys.platform != 'darwin': |
||||
os.chdir('/www/server/mdserver-web') |
||||
|
||||
|
||||
chdir = os.getcwd() |
||||
sys.path.append(chdir + '/class/core') |
||||
|
||||
# reload(sys) |
||||
# sys.setdefaultencoding('utf-8') |
||||
|
||||
|
||||
import mw |
||||
import db |
||||
import time |
||||
|
||||
|
||||
class backupTools: |
||||
|
||||
def backupDatabase(self, name, count): |
||||
db_path = mw.getServerDir() + '/mysql-ya' |
||||
db_name = 'mysql' |
||||
name = mw.M('databases').dbPos(db_path, 'mysql').where( |
||||
'name=?', (name,)).getField('name') |
||||
startTime = time.time() |
||||
if not name: |
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime()) |
||||
log = "数据库[" + name + "]不存在!" |
||||
print("★[" + endDate + "] " + log) |
||||
print( |
||||
"----------------------------------------------------------------------------") |
||||
return |
||||
|
||||
backup_path = mw.getRootDir() + '/backup/database' |
||||
if not os.path.exists(backup_path): |
||||
mw.execShell("mkdir -p " + backup_path) |
||||
|
||||
filename = backup_path + "/db_" + name + "_" + \ |
||||
time.strftime('%Y%m%d_%H%M%S', time.localtime()) + ".sql.gz" |
||||
|
||||
import re |
||||
mysql_root = mw.M('config').dbPos(db_path, db_name).where( |
||||
"id=?", (1,)).getField('mysql_root') |
||||
|
||||
mycnf = mw.readFile(db_path + '/etc/my.cnf') |
||||
rep = "\[mysqldump\]\nuser=root" |
||||
sea = "[mysqldump]\n" |
||||
subStr = sea + "user=root\npassword=" + mysql_root + "\n" |
||||
mycnf = mycnf.replace(sea, subStr) |
||||
if len(mycnf) > 100: |
||||
mw.writeFile(db_path + '/etc/my.cnf', mycnf) |
||||
|
||||
mw.execShell( |
||||
db_path + "/bin/mysqldump --opt --default-character-set=utf8 " + name + " | gzip > " + filename) |
||||
|
||||
if not os.path.exists(filename): |
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime()) |
||||
log = "数据库[" + name + "]备份失败!" |
||||
print("★[" + endDate + "] " + log) |
||||
print( |
||||
"----------------------------------------------------------------------------") |
||||
return |
||||
|
||||
mycnf = mw.readFile(db_path + '/etc/my.cnf') |
||||
mycnf = mycnf.replace(subStr, sea) |
||||
if len(mycnf) > 100: |
||||
mw.writeFile(db_path + '/etc/my.cnf', mycnf) |
||||
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime()) |
||||
outTime = time.time() - startTime |
||||
pid = mw.M('databases').dbPos(db_path, db_name).where( |
||||
'name=?', (name,)).getField('id') |
||||
|
||||
mw.M('backup').add('type,name,pid,filename,addtime,size', (1, os.path.basename( |
||||
filename), pid, filename, endDate, os.path.getsize(filename))) |
||||
log = "数据库[" + name + "]备份成功,用时[" + str(round(outTime, 2)) + u"]秒" |
||||
mw.writeLog('计划任务', log) |
||||
print("★[" + endDate + "] " + log) |
||||
print("|---保留最新的[" + count + "]份备份") |
||||
print("|---文件名:" + filename) |
||||
|
||||
# 清理多余备份 |
||||
backups = mw.M('backup').where( |
||||
'type=? and pid=?', ('1', pid)).field('id,filename').select() |
||||
|
||||
num = len(backups) - int(count) |
||||
if num > 0: |
||||
for backup in backups: |
||||
mw.execShell("rm -f " + backup['filename']) |
||||
mw.M('backup').where('id=?', (backup['id'],)).delete() |
||||
num -= 1 |
||||
print("|---已清理过期备份文件:" + backup['filename']) |
||||
if num < 1: |
||||
break |
||||
|
||||
def backupDatabaseAll(self, save): |
||||
db_path = mw.getServerDir() + '/mysql-ya' |
||||
db_name = 'mysql' |
||||
databases = mw.M('databases').dbPos( |
||||
db_path, db_name).field('name').select() |
||||
for database in databases: |
||||
self.backupDatabase(database['name'], save) |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
backup = backupTools() |
||||
type = sys.argv[1] |
||||
if type == 'database': |
||||
if sys.argv[2] == 'ALL': |
||||
backup.backupDatabaseAll(sys.argv[3]) |
||||
else: |
||||
backup.backupDatabase(sys.argv[2], sys.argv[3]) |
@ -0,0 +1,118 @@ |
||||
# -*- coding: utf-8 -*- |
||||
#!/bin/bash |
||||
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.7.html |
||||
#https://dev.mysql.com/downloads/file/?id=489855 |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
sysName=`uname` |
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
mysqlDir=${serverPath}/source/mysql |
||||
|
||||
|
||||
_os=`uname` |
||||
if [ ${_os} == "Darwin" ]; then |
||||
OSNAME='macos' |
||||
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then |
||||
OSNAME='centos' |
||||
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then |
||||
OSNAME='rocky' |
||||
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then |
||||
OSNAME='rhel' |
||||
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then |
||||
OSNAME='aliyun' |
||||
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then |
||||
OSNAME='fedora' |
||||
elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then |
||||
OSNAME='amazon' |
||||
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then |
||||
OSNAME='debian' |
||||
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then |
||||
OSNAME='ubuntu' |
||||
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then |
||||
OSNAME='raspbian' |
||||
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then |
||||
OSNAME='deepin' |
||||
else |
||||
OSNAME='unknow' |
||||
fi |
||||
|
||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` |
||||
|
||||
|
||||
|
||||
|
||||
APT_INSTALL() |
||||
{ |
||||
######## |
||||
wget -O /tmp/mysql-apt-config_0.8.22-1_all.deb https://repo.mysql.com/mysql-apt-config_0.8.22-1_all.deb |
||||
dpkg -i /tmp/mysql-apt-config_0.8.22-1_all.deb |
||||
|
||||
apt update -y |
||||
apt install -y mysql-server |
||||
|
||||
rm -rf /tmp/mysql-apt-config_0.8.22-1_all.deb |
||||
####### |
||||
} |
||||
|
||||
APT_UNINSTALL() |
||||
{ |
||||
### |
||||
apt remove -y mysql-server |
||||
### |
||||
} |
||||
|
||||
|
||||
Install_mysql() |
||||
{ |
||||
|
||||
echo '正在安装脚本文件...' > $install_tmp |
||||
|
||||
if id mysql &> /dev/null ;then |
||||
echo "mysql UID is `id -u mysql`" |
||||
echo "mysql Shell is `grep "^mysql:" /etc/passwd |cut -d':' -f7 `" |
||||
else |
||||
groupadd mysql |
||||
useradd -g mysql mysql |
||||
fi |
||||
|
||||
isApt=`which apt` |
||||
if [ "$isApt" != "" ];then |
||||
APT_INSTALL |
||||
fi |
||||
|
||||
if [ "$?" == "0" ];then |
||||
mkdir -p $serverPath/mysql-apt |
||||
echo '5.7' > $serverPath/mysql-apt/version.pl |
||||
echo '安装完成' > $install_tmp |
||||
else |
||||
echo "暂时不支持该系统" > $install_tmp |
||||
fi |
||||
} |
||||
|
||||
Uninstall_mysql() |
||||
{ |
||||
|
||||
isApt=`which apt` |
||||
if [ "$isApt" != "" ];then |
||||
APT_UNINSTALL |
||||
fi |
||||
|
||||
rm -rf $serverPath/mysql-apt |
||||
echo '卸载完成' > $install_tmp |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_mysql |
||||
else |
||||
Uninstall_mysql |
||||
fi |
@ -0,0 +1,135 @@ |
||||
# -*- coding: utf-8 -*- |
||||
#!/bin/bash |
||||
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.7.html |
||||
#https://dev.mysql.com/downloads/file/?id=489855 |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
sysName=`uname` |
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
mysqlDir=${serverPath}/source/mysql |
||||
|
||||
bash ${rootPath}/scripts/getos.sh |
||||
OSNAME=`cat ${rootPath}/data/osname.pl` |
||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` |
||||
|
||||
# cd /www/server/mdserver-web/plugins/mysql-apt && bash install.sh install 8.0 |
||||
|
||||
MYSQL_VER=8.0.30 |
||||
SUFFIX_NAME=${MYSQL_VER}-1${OSNAME}${VERSION_ID}_amd64 |
||||
|
||||
|
||||
# /lib/systemd/system/mysql.service |
||||
# /etc/mysql/my.cnf |
||||
|
||||
APT_INSTALL() |
||||
{ |
||||
######## |
||||
|
||||
wget -O /tmp/mysql-server_${SUFFIX_NAME}.deb-bundle.tar https://cdn.mysql.com/archives/mysql-8.0/mysql-server_${SUFFIX_NAME}.deb-bundle.tar |
||||
chmod +x /tmp/mysql-server_${SUFFIX_NAME}.deb-bundle.tar |
||||
tar vxf /tmp/mysql-server_${SUFFIX_NAME}.deb-bundle.tar |
||||
|
||||
apt update -y |
||||
apt install -y libnuma1 libaio1 libmecab2 |
||||
|
||||
# 手动调试 |
||||
# dpkg -i mysql-common_8.0.31-1ubuntu18.04_amd64.deb |
||||
# dpkg -i mysql-community-client-plugins_8.0.31-1ubuntu18.04_amd64.deb |
||||
# dpkg -i mysql-community-client-core_8.0.31-1ubuntu18.04_amd64.deb |
||||
# dpkg -i mysql-community-client_8.0.29-1ubuntu18.04_amd64.deb |
||||
# dpkg -i mysql-client_8.0.31-1ubuntu18.04_amd64.deb |
||||
|
||||
|
||||
dpkg -i mysql-common_${SUFFIX_NAME}.deb |
||||
|
||||
# dpkg-preconfigure mysql-community-server_8.0.29-1ubuntu18.04_amd64.deb |
||||
export DEBIAN_FRONTEND=noninteractive |
||||
dpkg -i mysql-community-client-plugins_${SUFFIX_NAME}.deb |
||||
dpkg -i mysql-community-client-core_${SUFFIX_NAME}.deb |
||||
dpkg -i mysql-community-client_${SUFFIX_NAME}.deb |
||||
dpkg -i mysql-client_${SUFFIX_NAME}.deb |
||||
|
||||
# dpkg -i mysql-community-client-plugins_${SUFFIX_NAME}.deb |
||||
# dpkg -i mysql-community-client_${SUFFIX_NAME}.deb |
||||
|
||||
# dpkg -i mysql-client_${SUFFIX_NAME}.deb |
||||
# dpkg -i libmysqlclient-dev_${SUFFIX_NAME}.deb |
||||
# dpkg -i libmysqld-dev_${SUFFIX_NAME}.deb |
||||
# dpkg -i mysql-community-${SUFFIX_NAME}.deb |
||||
# dpkg -i mysql-client_${SUFFIX_NAME}.deb |
||||
# dpkg -i mysql-common_${SUFFIX_NAME}.deb |
||||
|
||||
# apt -f install |
||||
# apt -f install libmecab2 |
||||
|
||||
dpkg -i mysql-community-server-core_${SUFFIX_NAME}.deb |
||||
dpkg -i mysql-community-server_${SUFFIX_NAME}.deb |
||||
dpkg -i mysql-server_${SUFFIX_NAME}.deb |
||||
|
||||
# dpkg -i mysql-server_${SUFFIX_NAME}.deb |
||||
# apt -f install |
||||
# apt install -y mysql-server |
||||
# rm -rf /tmp/mysql-server_8.0.29-1debian11_amd64.deb-bundle.tar |
||||
####### |
||||
} |
||||
|
||||
APT_UNINSTALL() |
||||
{ |
||||
### |
||||
apt remove -y mysql-server |
||||
### |
||||
} |
||||
|
||||
|
||||
Install_mysql() |
||||
{ |
||||
echo '正在安装脚本文件...' > $install_tmp |
||||
if id mysql &> /dev/null ;then |
||||
echo "mysql uid is `id -u mysql`" |
||||
echo "mysql shell is `grep "^mysql:" /etc/passwd |cut -d':' -f7 `" |
||||
else |
||||
groupadd mysql |
||||
useradd -g mysql mysql |
||||
fi |
||||
|
||||
|
||||
isApt=`which apt` |
||||
if [ "$isApt" != "" ];then |
||||
APT_INSTALL |
||||
fi |
||||
|
||||
if [ "$?" == "0" ];then |
||||
mkdir -p $serverPath/mysql-apt |
||||
echo '8.0' > $serverPath/mysql-apt/version.pl |
||||
echo '安装完成' > $install_tmp |
||||
else |
||||
echo "暂时不支持该系统" > $install_tmp |
||||
fi |
||||
} |
||||
|
||||
Uninstall_mysql() |
||||
{ |
||||
|
||||
isApt=`which apt` |
||||
if [ "$isApt" != "" ];then |
||||
APT_UNINSTALL |
||||
fi |
||||
|
||||
rm -rf $serverPath/mysql-apt |
||||
echo '卸载完成' > $install_tmp |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_mysql |
||||
else |
||||
Uninstall_mysql |
||||
fi |
Loading…
Reference in new issue