mirror of
https://github.com/midoks/mdserver-web
synced 2026-11-05 19:56:01 +08:00
@@ -99,7 +99,7 @@ class nosqlMySQL():
|
||||
result['host'] = '127.0.0.1'
|
||||
result['username'] = 'root'
|
||||
|
||||
if sid in ['mysql', 'mysql-apt', 'mysql-yum', 'mysql-community']:
|
||||
if sid in ['mysql', 'mysql-apt', 'mysql-yum', 'mysql-community','mariadb']:
|
||||
my_cnf_path = "{}/{}/etc/my.cnf".format(mw.getServerDir(),sid)
|
||||
if not os.path.exists(my_cnf_path):
|
||||
return False
|
||||
@@ -151,6 +151,10 @@ class nosqlMySQL():
|
||||
local_mysql_yum = "{}/mysql-community/etc/my.cnf".format(mw.getServerDir())
|
||||
if os.path.exists(local_mysql_yum):
|
||||
data.append({'name':'本地服务器[Tar]', 'val':'mysql-community'})
|
||||
|
||||
local_mysql_yum = "{}/mariadb/etc/my.cnf".format(mw.getServerDir())
|
||||
if os.path.exists(local_mysql_yum):
|
||||
data.append({'name':'本地服务器[mariadb]', 'val':'mariadb'})
|
||||
return mw.returnData(True, 'ok', data)
|
||||
|
||||
@singleton
|
||||
@@ -471,23 +475,42 @@ class nosqlMySQLCtr():
|
||||
return err
|
||||
|
||||
my_instance.execute("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))")
|
||||
|
||||
# ANY_VALUE 是 MySQL 5.7+ 的函数,MariaDB 不支持(报 FUNCTION ANY_VALUE does not exist);
|
||||
# 上面已去掉 ONLY_FULL_GROUP_BY,MariaDB 可直接取非聚合字段
|
||||
ver = my_instance.find("SELECT @@version as db_version")
|
||||
is_mariadb = ver is not None and 'MariaDB' in str(ver.get('db_version', ''))
|
||||
|
||||
def any_val(expr):
|
||||
return expr if is_mariadb else 'ANY_VALUE(' + expr + ')'
|
||||
|
||||
data = my_instance.query(
|
||||
"""
|
||||
SELECT t.TABLE_SCHEMA as TABLE_SCHEMA, t.TABLE_NAME as TABLE_NAME,
|
||||
ANY_VALUE(t.ENGINE) as ENGINE,
|
||||
ANY_VALUE(IFNULL(t.DATA_LENGTH/1024/1024/1024, 0)) as DATA_LENGTH,
|
||||
ANY_VALUE(IFNULL(t.INDEX_LENGTH/1024/1024/1024, 0)) as INDEX_LENGTH,
|
||||
ANY_VALUE(IFNULL((t.DATA_LENGTH+t.INDEX_LENGTH)/1024/1024/1024, 0)) AS TOTAL_LENGTH,
|
||||
ANY_VALUE(c.column_name) AS COLUMN_NAME, ANY_VALUE(c.data_type) AS DATA_TYPE,
|
||||
ANY_VALUE(c.COLUMN_TYPE) AS COLUMN_TYPE,
|
||||
ANY_VALUE(t.AUTO_INCREMENT) AS AUTO_INCREMENT,
|
||||
ANY_VALUE(locate('unsigned', c.COLUMN_TYPE) = 0) AS IS_SIGNED
|
||||
FROM information_schema.TABLES t
|
||||
JOIN information_schema.COLUMNS c ON t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.table_name=c.table_name
|
||||
WHERE t.TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys')
|
||||
GROUP BY t.TABLE_SCHEMA, t.TABLE_NAME
|
||||
{engine} as ENGINE,
|
||||
{data_length} as DATA_LENGTH,
|
||||
{index_length} as INDEX_LENGTH,
|
||||
{total_length} AS TOTAL_LENGTH,
|
||||
{column_name} AS COLUMN_NAME, {data_type} AS DATA_TYPE,
|
||||
{column_type} AS COLUMN_TYPE,
|
||||
{auto_increment} AS AUTO_INCREMENT,
|
||||
{is_signed} AS IS_SIGNED
|
||||
FROM information_schema.TABLES t
|
||||
JOIN information_schema.COLUMNS c ON t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.table_name=c.table_name
|
||||
WHERE t.TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys')
|
||||
GROUP BY t.TABLE_SCHEMA, t.TABLE_NAME
|
||||
ORDER BY TOTAL_LENGTH DESC, AUTO_INCREMENT DESC
|
||||
"""
|
||||
""".format(
|
||||
engine=any_val("t.ENGINE"),
|
||||
data_length=any_val("IFNULL(t.DATA_LENGTH/1024/1024/1024, 0)"),
|
||||
index_length=any_val("IFNULL(t.INDEX_LENGTH/1024/1024/1024, 0)"),
|
||||
total_length=any_val("IFNULL((t.DATA_LENGTH+t.INDEX_LENGTH)/1024/1024/1024, 0)"),
|
||||
column_name=any_val("c.column_name"),
|
||||
data_type=any_val("c.data_type"),
|
||||
column_type=any_val("c.COLUMN_TYPE"),
|
||||
auto_increment=any_val("t.AUTO_INCREMENT"),
|
||||
is_signed=any_val("locate('unsigned', c.COLUMN_TYPE) = 0"),
|
||||
)
|
||||
)
|
||||
|
||||
if data is None:
|
||||
|
||||
@@ -9,11 +9,7 @@ searchd {
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
data_dir = /var/lib/manticore
|
||||
workers = threads
|
||||
binlog_path = /var/lib/manticore
|
||||
max_children = 1000
|
||||
max_matches = 1000000
|
||||
#binlog_path = /var/lib/manticore/binlog
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<p onclick="pluginLogs('manticoresearch','','query_log', 30);">查询日志</p>
|
||||
<p onclick="mcsRunStatus();">运行状态</p>
|
||||
<p onclick="mcsCommonFunc();">常用功能</p>
|
||||
<p onclick="pluginLogsContent('manticoresearch',$('.plugin_version').attr('version'),'systemctl_log');">服务运行日志</p>
|
||||
<p onclick="mcsReadme();">说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
|
||||
@@ -273,6 +273,11 @@ def queryLog():
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0]
|
||||
|
||||
def systemctlLog():
|
||||
cmd = "journalctl -u manticore -n 15 --no-pager"
|
||||
data = mw.execShell(cmd)
|
||||
return data[0]
|
||||
|
||||
|
||||
def runStatus():
|
||||
s = status()
|
||||
@@ -491,6 +496,8 @@ if __name__ == "__main__":
|
||||
print(runLog())
|
||||
elif func == 'query_log':
|
||||
print(queryLog())
|
||||
elif func == 'systemctl_log':
|
||||
print(systemctlLog())
|
||||
elif func == 'run_status':
|
||||
print(runStatus())
|
||||
elif func == 'run_status_test':
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "manticoresearch",
|
||||
"title": "manticoresearch",
|
||||
"shell": "install.sh",
|
||||
"versions":["7.4.6"],
|
||||
"versions":["latest"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":true,
|
||||
"checks": "server/manticoresearch",
|
||||
|
||||
@@ -98,8 +98,8 @@ logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_all"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_all' + "\n"
|
||||
cmd += 'cd $mw_dir && . bin/activate && python3 plugins/manticoresearch/index.py update_all' + "\n"
|
||||
cmd += 'echo "cd $mw_dir && . bin/activate && python3 plugins/manticoresearch/index.py update_all"' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
@@ -147,8 +147,8 @@ logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_delta"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_delta' + "\n"
|
||||
cmd += 'cd $mw_dir && . bin/activate && python3 plugins/manticoresearch/index.py update_delta' + "\n"
|
||||
cmd += 'echo "cd $mw_dir && . bin/activate && python3 plugins/manticoresearch/index.py update_delta"' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
|
||||
@@ -5,5 +5,4 @@ searchd {
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
data_dir = /var/lib/manticore
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@ Install_App()
|
||||
|
||||
wget --no-check-certificate -O $MC_DIR/manticore-repo.noarch.deb https://repo.manticoresearch.com/manticore-repo.noarch.deb
|
||||
dpkg -i $MC_DIR/manticore-repo.noarch.deb
|
||||
apt update -y
|
||||
apt -y install manticore manticore-extra
|
||||
|
||||
apt -y install manticore manticore-extra
|
||||
apt -y install manticore-extra
|
||||
apt -y upgrade manticore
|
||||
|
||||
echo "${VERSION}" > $serverPath/manticoresearch/version.pl
|
||||
|
||||
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py start ${VERSION}
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py initd_install ${VERSION}
|
||||
|
||||
if [ -d ${MC_DIR} ];then
|
||||
rm -rf ${MC_DIR}
|
||||
fi
|
||||
# if [ -d ${MC_DIR} ];then
|
||||
# rm -rf ${MC_DIR}
|
||||
# fi
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
|
||||
@@ -25,7 +25,8 @@ Install_App()
|
||||
mkdir -p $MC_DIR
|
||||
|
||||
yum install -y https://repo.manticoresearch.com/manticore-repo.noarch.rpm
|
||||
yum install -y manticore manticore-extra
|
||||
yum install -y manticore
|
||||
yum install -y manticore-extra
|
||||
|
||||
echo "${VERSION}" > $serverPath/manticoresearch/version.pl
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
server-id = {$SERVER_ID}
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
performance_schema = 1
|
||||
|
||||
key_buffer_size = 8M
|
||||
max_allowed_packet = 100M
|
||||
|
||||
@@ -2381,7 +2381,7 @@ def getMasterRepSlaveUserCmd(version):
|
||||
sql = '<span class="set-info c7 ta_center">经典模式</span><hr style="margin-top: 5px;margin-bottom: 10px;"/>'
|
||||
sql += base_sql + "', MASTER_LOG_FILE='" + mstatus[0]["File"] + \
|
||||
"',MASTER_LOG_POS=" + str(mstatus[0]["Position"])
|
||||
sql = '<br/><span class="set-info c7 ta_center">GTID模式</span><hr style="margin-top: 5px;margin-bottom: 10px;"/>'
|
||||
sql += '<br/><hr/><span class="set-info c7 ta_center">GTID模式</span><hr style="margin-top: 5px;margin-bottom: 10px;"/>'
|
||||
sql += base_sql + "',MASTER_USE_GTID=slave_pos,MASTER_CONNECT_RETRY=10;";
|
||||
sql += "<br/>";
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_all"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_all' + "\n"
|
||||
cmd += 'cd $mw_dir && . bin/activate && python3 plugins/sphinx/index.py update_all' + "\n"
|
||||
cmd += 'echo "cd $mw_dir && . bin/activate && python3 plugins/sphinx/index.py update_all' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
@@ -147,8 +147,8 @@ logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_delta"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_delta' + "\n"
|
||||
cmd += 'cd $mw_dir && . bin/activate && python3 plugins/sphinx/index.py update_delta' + "\n"
|
||||
cmd += 'echo "cd $mw_dir && . bin/activate && python3 plugins/sphinx/index.py update_delta' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user