DB审核查询平台Archery--安装部署大概碰到的问题

张春  论坛元老 | 2025-2-13 21:39:59 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 1580|帖子 1580|积分 4740

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
Archery先容

Archery是archer的分支项目,定位于SQL审核查询平台,旨在提拔DBA的工作效率,支持多数据库的SQL上线和查询,同时支持丰富的MySQL运维功能,全部功能都兼容手机端操纵。
功能清单
数据库范例查询审核执行备份数据字典慢日记会话管理账号管理参数管理 数据归档MySQL√√√√√√√√√√MsSQL√×√×××××××Redis√×√×××××××PgSQL√×√×××××××Oracle√×√√××××××MongoDB√×√××××××× 因基础环境差异,在安装部署中大概碰到的异常,如下:

1.libmysqlclient.so.20 异常



  1. Watching for file changes with StatReloader
  2. Exception in thread django-main-thread:
  3. Traceback (most recent call last):
  4.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/__init__.py", line 18, in <module>
  5.     from . import _mysql
  6. ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory
  7. During handling of the above exception, another exception occurred:
  8. Traceback (most recent call last):
  9.   File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
  10.     self.run()
  11.   File "/usr/lib64/python3.6/threading.py", line 864, in run
  12.     self._target(*self._args, **self._kwargs)
  13.   File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
  14.     fn(*args, **kwargs)
  15.   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
  16.     autoreload.raise_last_exception()
  17.   File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
  18.     raise _exception[1]
  19.   File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
  20.     autoreload.check_errors(django.setup)()
  21.   File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
  22.     fn(*args, **kwargs)
  23.   File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
  24.     apps.populate(settings.INSTALLED_APPS)
  25.   File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
  26.     app_config.import_models()
  27.   File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
  28.     self.models_module = import_module(models_module_name)
  29.   File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  30.     return _bootstrap._gcd_import(name[level:], package, level)
  31.   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  32.   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  33.   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  34.   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  35.   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  36.   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  37.   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
  38.     from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  39.   File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
  40.     class AbstractBaseUser(models.Model):
  41.   File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py", line 122, in __new__
  42.     new_class.add_to_class('_meta', Options(meta, app_label))
  43.   File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py", line 326, in add_to_class
  44.     value.contribute_to_class(cls, name)
  45.   File "/usr/local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class
  46.     self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  47.   File "/usr/local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
  48.     return getattr(connections[DEFAULT_DB_ALIAS], item)
  49.   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 214, in __getitem__
  50.     backend = load_backend(db['ENGINE'])
  51.   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backend
  52.     return import_module('%s.base' % backend_name)
  53.   File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
  54.     return _bootstrap._gcd_import(name[level:], package, level)
  55.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
  56.     import MySQLdb as Database
  57.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/__init__.py", line 24, in <module>
  58.     version_info, _mysql.version_info, _mysql.__file__
  59. NameError: name '_mysql' is not defined
复制代码


解决方案:
因为我们本机安装了mysql,本地由libmysqlclient.so.20文件包,所以简朴做个软链接即可。
  1. ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
复制代码
2.安装安装pyodbc报错



  1. Using legacy 'setup.py install' for pyodbc, since package 'wheel' is not installed.
  2. Installing collected packages: pyodbc
  3.     Running setup.py install for pyodbc ... error
  4.     ERROR: Command errored out with exit status 1:
  5.      command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jys5r5zz/pyodbc_bXXXXXd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jys5r5zz/pyodbc_b2bXXXX4d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4o7hogt9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pyodbc
  6.          cwd: /tmp/pip-install-jys5r5zz/pyodbc_b2bc9990d79a4871bf031ae2d0c51d4d/
  7.     Complete output (18 lines):
  8.     /usr/local/lib/python3.6/site-packages/setuptools/dist.py:726: UserWarning: Usage of dash-separated 'library-dirs' will not be supported in future versions. Please use the underscore name 'library_dirs' instead
  9.       % (opt, underscore_opt)
  10.     running install
  11.     /usr/local/lib/python3.6/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  12.       setuptools.SetuptoolsDeprecationWarning,
  13.     running build
  14.     running build_ext
  15.     building 'pyodbc' extension
  16.     creating build
  17.     creating build/temp.linux-x86_64-3.6
  18.     creating build/temp.linux-x86_64-3.6/src
  19.     gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=4.0.30 -I/usr/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-strings
  20.     In file included from src/buffer.cpp:12:0:
  21.     src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
  22.      #include <sql.h>
  23.                      ^
  24.     compilation terminated.
  25.     error: command 'gcc' failed with exit status 1
  26.     ----------------------------------------
  27. ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jys5r5zz/pyodbc_XXXXX/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jys5r5zz/pyodbc_XXXXXXX/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4o7hogt9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pyodbc Check the logs for full command output.
复制代码


解决方案:

先安装unixODBC-devel,执行命令如下:
  1. yum install unixODBC-devel
复制代码
在此安装就好好了。
如果没有解决,一直是雷同如下错误:


  1. creating build/temp.linux-x86_64-3.6
  2.   creating build/temp.linux-x86_64-3.6/src
  3.   gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=4.0.30 -I/data/aliyunniubi/include -I/usr/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include
  4.   In file included from src/buffer.cpp:12:0:
  5.   src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
  6.    #include <Python.h>
  7.                       ^
  8.   compilation terminated.
  9.   error: command 'gcc' failed with exit status 1
  10.   ----------------------------------------
  11.   ERROR: Failed building wheel for pyodbc
复制代码


呵呵。。。,可以尝试以下方案:
  1. yum install python-devel
复制代码

  1. yum install python3-devel
复制代码
根据版本决定。
3.安装django-auth-ldap报错



  1. In file included from Modules/LDAPObject.c:3:0:
  2.   Modules/common.h:9:20: fatal error: Python.h: No such file or directory
  3.    #include "Python.h"
  4.                       ^
  5.   compilation terminated.
  6.   error: command 'gcc' failed with exit status 1
  7.   ----------------------------------------
  8.   ERROR: Failed building wheel for python-ldap
  9. Failed to build python-ldap
  10. ERROR: Could not build wheels for python-ldap, which is required to install pyproject.toml-based projects
复制代码


解决方案: 
需要先安装pip3 install python-ldap,而安装之前需要安装yum install openldap-devel。
安装上面两个插件之后,再此安装就报错了。
参考:https://www.cnblogs.com/wangjian941118/p/13518515.html
4.项目启动报错 

python manage.py runserver


  1. File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", line 185, in __init__
  2.     super().__init__(*args, **kwargs2)
  3. MySQLdb._exceptions.OperationalError: (1049, "Unknown database 'archery'")
  4. The above exception was the direct cause of the following exception:
  5. Traceback (most recent call last):
  6.   File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
  7.     self.run()
  8.   File "/usr/lib64/python3.6/threading.py", line 864, in run
  9.     self._target(*self._args, **self._kwargs)
  10.   File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
  11.     fn(*args, **kwargs)
  12.   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
  13.     self.check_migrations()
  14. --------------------------------
  15. File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", line 185, in __init__
  16.     super().__init__(*args, **kwargs2)
  17. django.db.utils.OperationalError: (1049, "Unknown database 'archery'")
复制代码


解决方案
系统默认的数据库是archery。
我们可以先手动创建创建这个数据库。
5.未初始化导致报错

  1. You have 31 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, django_q, sessions.
  2. Run 'python manage.py migrate' to apply them.
复制代码
解决方案:
执行初始化命令
  1. python manage.py makemigrations
  2. python manage.py migrate
复制代码
6.执行初始化时报错,不能创建外键



  1. File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 245, in handle
  2.     fake_initial=fake_initial,
  3.   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
  4.     state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  5.   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
  6.     state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  7.   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 229, in apply_migration
  8.     migration_recorded = True
  9.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 115, in __exit__
  10.     self.execute(sql)
  11.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 142, in execute
  12.     cursor.execute(sql, params)
  13.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 98, in execute
  14.     return super().execute(sql, params)
  15.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 66, in execute
  16.     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  17.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
  18.     return executor(sql, params, many, context)
  19.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
  20.     return self.cursor.execute(sql, params)
  21.   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
  22.     raise dj_exc_value.with_traceback(traceback) from exc_value
  23.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
  24.     return self.cursor.execute(sql, params)
  25.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 73, in execute
  26.     return self.cursor.execute(query, args)
  27.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
  28.     res = self._query(query)
  29.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query
  30.     db.query(q)
  31.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", line 259, in query
  32.     _mysql.connection.query(self, query)
  33. django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')
复制代码


解决方案:
  1. set global FOREIGN_KEY_CHECKS=0
复制代码
参考:
https://stackoverflow.com/questions/12966626/mysql-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails
再次初始化,不再报错。
7.启动还是报错,此次错误说缺少表



  1. [ERROR]- 获取系统配置信息失败:(1146, "Table 'archery.sql_config' doesn't exist")Traceback (most recent call last):
  2.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
  3.     return self.cursor.execute(sql, params)
  4.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 73, in execute
  5.     return self.cursor.execute(query, args)
  6.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
  7.     res = self._query(query)
  8.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query
  9.     db.query(q)
  10.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", line 259, in query
  11.     _mysql.connection.query(self, query)
  12. MySQLdb._exceptions.ProgrammingError: (1146, "Table 'archery.sql_config' doesn't exist")
  13. The above exception was the direct cause of the following exception:
  14. Traceback (most recent call last):
  15.   File "/data/scripts/Archery-master/common/config.py", line 25, in get_all_config
  16.     for items in all_config:
  17.   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 287, in __iter__
  18.     self._fetch_all()
  19.   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 1308, in _fetch_all
  20.     self._result_cache = list(self._iterable_class(self))
  21.   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 111, in __iter__
  22.     for row in compiler.results_iter(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size):
  23.   File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1108, in results_iter
  24.     results = self.execute_sql(MULTI, chunked_fetch=chunked_fetch, chunk_size=chunk_size)
  25.   File "/usr/local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
  26.     cursor.execute(sql, params)
  27.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 98, in execute
  28.     return super().execute(sql, params)
  29.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 66, in execute
  30.     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  31.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
  32.     return executor(sql, params, many, context)
  33.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
  34.     return self.cursor.execute(sql, params)
  35.   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
  36.     raise dj_exc_value.with_traceback(traceback) from exc_value
  37.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
  38.     return self.cursor.execute(sql, params)
  39.   File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 73, in execute
  40.     return self.cursor.execute(query, args)
  41.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
  42.     res = self._query(query)
  43.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query
  44.     db.query(q)
  45.   File "/usr/local/lib64/python3.6/site-packages/MySQLdb/connections.py", line 259, in query
  46.     _mysql.connection.query(self, query)
  47. django.db.utils.ProgrammingError: (1146, "Table 'archery.sql_config' doesn't exist")
复制代码


解决方案
step 1.将之前存在的库删除掉:
  1. drop database archery
复制代码
step 2.先初始化sql应用的脚本
  1. python manage.py makemigrations sql
  2. python manage.py migrate sql
复制代码
step 3 再初始化整个项目标脚本
  1. python manage.py makemigrations
  2. python manage.py migrate
复制代码
注意上面的顺序。
到此,此项目再正是部署完成,才算基本调通。
8.服务启动,网址可访问

login会表现输入账号,此时需要进行数据初始化。


  1. # 数据初始化
  2. python3 manage.py dbshell<sql/fixtures/auth_group.sql
  3. python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql
  4. # 创建管理用户
  5. python3 manage.py createsuperuser
复制代码



参考:

1.手动部署--Archery
https://archerydms.com/installation/manual/
2.开源SQL审核平台——Archery 安装、部署心得 
[原创]开源SQL审核平台——Archery 安装、部署心得 - 指弹小能手 - 博客园
3.Archery SQL审核查询平台
https://archerydms.com/

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

张春

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表