archery git 地址:
1、https://github.com/hhyo/Archery
2、pyton 版本使用3.9
3、创建虚环境
使用python3.9
安装ldap依赖
对应python版本 下载文件地址https://github.com/cgohlke/python-ldap-build/releases
pip install python_ldap-3.4.4-cp39-cp39-win_amd64.whl
安装其他依赖
pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
修改 archery/setting.py
DEBUG=(bool, True), 改为True
DATABASE_URL=(str, "mysql://root:@127.0.0.1:3306/archery"),
CACHE_URL=(str, "redis://127.0.0.1:6379/0"),
# 数据库初始化
python3 manage.py makemigrations sql
python3 manage.py migrate
# 数据初始化
python3 manage.py dbshell<sql/fixtures/auth_group.sql
python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql
# 创建管理用户
python3 manage.py createsuperuser
修改响应的数据库 mysql地址 ,debug = True
方便调试可以打卡sql 日志
界面接口相关代码
api接口相关代码
启动项目
archery 启动后系统信息,可以从中看到包依赖版本,如果本地安装包版本过高可以参照
{
"archery": {
"version": "1.9.1"
},
"django_q": {
"version": "1.3.9",
"conf": {
"name": "archery",
"workers": 4,
"recycle": 500,
"timeout": 60,
"compress": true,
"cpu_affinity": 1,
"save_limit": 0,
"queue_limit": 50,
"label": "Django Q",
"django_redis": "default",
"sync": false
},
"q_cluster_stats": [
{
"host": "archery-5858f4bf58-chn4f",
"cluster_id": "37cdbe42-4874-49f4-9694-74cb1b1aea3c",
"state": "Idle",
"pool": 4,
"tq": 0,
"rq": 0,
"rc": 0,
"up": "38:32:46"
}
],
"q_broker_stats": {
"info": "Redis 6.2.6",
"Queued": 0,
"Success": 3010,
"Failures": 1
}
},
"inception": {
"goinception_info": {
"backup_host": "archery-mysql-service",
"backup_password": "*13EB61A5FAF367BD6EEE60BCF139BA6BE4C3D450",
"backup_port": "3306",
"backup_user": "root",
"backup_tls": "",
"check_autoincrement_datatype": "false",
"check_autoincrement_init_value": "false",
"check_autoincrement_name": "false",
"check_column_comment": "false",
"check_column_default_value": "false",
"check_column_position_change": "false",
"check_column_type_change": "false",
"check_dml_limit": "false",
"check_dml_orderby": "false",
"check_dml_where": "false",
"check_identifier": "false",
"check_implicit_type_conversion": "false",
"check_index_prefix": "false",
"check_index_column_repeat": "false",
"check_insert_field": "false",
"check_primary_key": "false",
"check_table_comment": "false",
"check_timestamp_default": "false",
"check_timestamp_count": "false",
"enable_timestamp_type": "true",
"enable_zero_date": "true",
"check_datetime_default": "false",
"check_datetime_count": "false",
"check_float_double": "false",
"check_identifier_upper": "false",
"check_identifier_lower": "false",
"check_read_only": "true",
"default_charset": "utf8mb4",
"disable_types": "",
"enable_alter_database": "false",
"enable_any_statement": "false",
"enable_autoincrement_unsigned": "false",
"enable_blob_not_null": "true",
"enable_blob_type": "true",
"enable_change_column": "true",
"enable_column_charset": "true",
"enable_drop_database": "false",
"enable_drop_table": "true",
"enable_enum_set_bit": "false",
"enable_fingerprint": "false",
"enable_foreign_key": "false",
"enable_identifer_keyword": "false",
"enable_json_type": "true",
"enable_use_view": "false",
"enable_minimal_rollback": "false",
"enable_set_engine": "true",
"enable_nullable": "false",
"enable_null_index_name": "false",
"enable_orderby_rand": "true",
"enable_partition_table": "true",
"enable_pk_columns_only_int": "false",
"enable_select_star": "false",
"enable_set_charset": "true",
"enable_set_collation": "true",
"enable_sql_statistic": "true",
"explain_rule": "first",
"sql_mode": "",
"general_log": "false",
"hex_blob": "false",
"index_prefix": "idx_",
"uniq_index_prefix": "uniq_",
"table_prefix": "",
"lang": "zh_cn",
"max_allowed_packet": "0",
"max_char_length": "0",
"max_column_count": "0",
"max_ddl_affect_rows": "0",
"max_insert_rows": "0",
"max_keys": "0",
"max_key_parts": "0",
"max_update_rows": "5000000",
"max_varchar_length": "0",
"max_primary_key_parts": "0",
"merge_alter_table": "false",
"must_have_columns": "",
"columns_must_have_index": "",
"skip_grant_table": "true",
"skip_sqls": "",
"ignore_osc_alter_stmt": "",
"sql_safe_updates": "0",
"lock_wait_timeout": "-1",
"support_charset": "utf8,utf8mb4",
"support_collation": "utf8_general_ci,utf8mb4_general_ci,utf8mb4_bin,utf8mb4_0900_ai_ci,utf8mb4_unicode_ci",
"support_engine": "innodb",
"wait_timeout": "0",
"max_execution_time": "0",
"version": "None",
"custom_keywords": "[]",
"osc_print_none": "false",
"osc_print_sql": "false",
"osc_on": "false",
"osc_min_table_size": "16",
"osc_alter_foreign_keys_method": "none",
"osc_recursion_method": "processlist",
"osc_max_lag": "3",
"osc_max_flow_ctl": "-1",
"osc_check_alter": "true",
"osc_sleep": "0",
"osc_lock_wait_timeout": "60",
"osc_check_replication_filters": "true",
"osc_check_unique_key_change": "true",
"osc_drop_old_table": "true",
"osc_drop_new_table": "true",
"osc_max_thread_running": "80",
"osc_max_thread_connected": "1000",
"osc_critical_thread_running": "80",
"osc_critical_thread_connected": "1000",
"osc_chunk_time": "1",
"osc_chunk_size_limit": "4",
"osc_chunk_size": "1000",
"osc_check_interval": "5",
"osc_bin_dir": "/usr/local/bin",
"ghost_aliyun_rds": "false",
"ghost_allow_master_master": "false",
"ghost_allow_nullable_unique_key": "false",
"ghost_allow_on_master": "true",
"ghost_approve_renamed_columns": "true",
"ghost_assume_master_host": "",
"ghost_assume_rbr": "true",
"ghost_concurrent_rowcount": "true",
"ghost_critical_load_interval_millis": "0",
"ghost_critical_load_hibernate_seconds": "0",
"ghost_cut_over": "atomic",
"ghost_cut_over_exponential_backoff": "false",
"ghost_chunk_size": "1000",
"ghost_cut_over_lock_timeout_seconds": "3",
"ghost_discard_foreign_keys": "false",
"ghost_default_retries": "60",
"ghost_dml_batch_size": "10",
"ghost_exact_rowcount": "false",
"ghost_exponential_backoff_max_interval": "64",
"ghost_force_table_names": "",
"ghost_force_named_cut_over": "false",
"ghost_gcp": "false",
"ghost_heartbeat_interval_millis": "500",
"ghost_initially_drop_ghost_table": "false",
"ghost_initially_drop_old_table": "false",
"ghost_initially_drop_socket_file": "false",
"ghost_max_lag_millis": "1500",
"ghost_nice_ratio": "0",
"ghost_on": "false",
"ghost_ok_to_drop_table": "true",
"ghost_postpone_cut_over_flag_file": "",
"ghost_skip_foreign_key_checks": "true",
"ghost_throttle_control_replicas": "",
"ghost_throttle_http": "",
"ghost_timestamp_old_table": "false",
"ghost_throttle_query": "",
"ghost_throttle_flag_file": "",
"ghost_throttle_additional_flag_file": "",
"ghost_tungsten": "false",
"ghost_replication_lag_query": "",
"ghost_bin_dir": ""
},
"backup_info": "无法连接goInception备份库\n(1045, \"Access denied for user 'root'@'10.100.0.249' (using password: YES)\")"
},
"runtime_info": {
"python_version": "3.9.10",
"mysql_info": {
"mysql_server_info": "5.7.44-log",
"timezone_name": "Asia/Shanghai"
},
"redis_info": {
"redis_version": "6.2.6",
"redis_git_sha1": 0,
"redis_git_dirty": 0,
"redis_build_id": "5b326c4b337eb561",
"redis_mode": "standalone",
"os": "Linux 3.10.0-1160.el7.x86_64 x86_64",
"arch_bits": 64,
"multiplexing_api": "epoll",
"atomicvar_api": "c11-builtin",
"gcc_version": "8.3.0",
"process_id": 1,
"process_supervised": "no",
"run_id": "490197d1897c8b8a403958fd52f6ce2b99356ec3",
"tcp_port": 6379,
"server_time_usec": 1725411138509079,
"uptime_in_seconds": 163685,
"uptime_in_days": 1,
"hz": 10,
"configured_hz": 10,
"lru_clock": 14135106,
"executable": "/redis-server",
"config_file": "",
"io_threads_active": 0,
"connected_clients": 6,
"cluster_connections": 0,
"maxclients": 10000,
"client_recent_max_input_buffer": 56,
"client_recent_max_output_buffer": 0,
"blocked_clients": 1,
"tracking_clients": 0,
"clients_in_timeout_table": 1,
"used_memory": 981608,
"used_memory_human": "958.60K",
"used_memory_rss": 12656640,
"used_memory_rss_human": "12.07M",
"used_memory_peak": 1145648,
"used_memory_peak_human": "1.09M",
"used_memory_peak_perc": "85.68%",
"used_memory_overhead": 935000,
"used_memory_startup": 810120,
"used_memory_dataset": 46608,
"used_memory_dataset_perc": "27.18%",
"allocator_allocated": 1072808,
"allocator_active": 1441792,
"allocator_resident": 9850880,
"total_system_memory": 404095307776,
"total_system_memory_human": "376.34G",
"used_memory_lua": 37888,
"used_memory_lua_human": "37.00K",
"used_memory_scripts": 0,
"used_memory_scripts_human": "0B",
"number_of_cached_scripts": 0,
"maxmemory": 0,
"maxmemory_human": "0B",
"maxmemory_policy": "noeviction",
"allocator_frag_ratio": 1.34,
"allocator_frag_bytes": 368984,
"allocator_rss_ratio": 6.83,
"allocator_rss_bytes": 8409088,
"rss_overhead_ratio": 1.28,
"rss_overhead_bytes": 2805760,
"mem_fragmentation_ratio": 13.48,
"mem_fragmentation_bytes": 11717768,
"mem_not_counted_for_evict": 1530,
"mem_replication_backlog": 0,
"mem_clients_slaves": 0,
"mem_clients_normal": 123152,
"mem_aof_buffer": 1536,
"mem_allocator": "jemalloc-5.1.0",
"active_defrag_running": 0,
"lazyfree_pending_objects": 0,
"lazyfreed_objects": 0,
"loading": 0,
"current_cow_size": 0,
"current_cow_size_age": 0,
"current_fork_perc": 0,
"current_save_keys_processed": 0,
"current_save_keys_total": 0,
"rdb_changes_since_last_save": 293485,
"rdb_bgsave_in_progress": 0,
"rdb_last_save_time": 1725247453,
"rdb_last_bgsave_status": "ok",
"rdb_last_bgsave_time_sec": -1,
"rdb_current_bgsave_time_sec": -1,
"rdb_last_cow_size": 0,
"aof_enabled": 1,
"aof_rewrite_in_progress": 0,
"aof_rewrite_scheduled": 0,
"aof_last_rewrite_time_sec": 1,
"aof_current_rewrite_time_sec": -1,
"aof_last_bgrewrite_status": "ok",
"aof_last_write_status": "ok",
"aof_last_cow_size": 585728,
"module_fork_in_progress": 0,
"module_fork_last_cow_size": 0,
"aof_current_size": 64768774,
"aof_base_size": 731,
"aof_pending_rewrite": 0,
"aof_buffer_length": 0,
"aof_rewrite_buffer_length": 0,
"aof_pending_bio_fsync": 0,
"aof_delayed_fsync": 0,
"total_connections_received": 65484,
"total_commands_processed": 571193,
"instantaneous_ops_per_sec": 2,
"total_net_input_bytes": 204096408,
"total_net_output_bytes": 2992707,
"instantaneous_input_kbps": 1.23,
"instantaneous_output_kbps": 0.01,
"rejected_connections": 0,
"sync_full": 0,
"sync_partial_ok": 0,
"sync_partial_err": 0,
"expired_keys": 52,
"expired_stale_perc": 0,
"expired_time_cap_reached_count": 0,
"expire_cycle_cpu_milliseconds": 3464,
"evicted_keys": 0,
"keyspace_hits": 11,
"keyspace_misses": 38,
"pubsub_channels": 0,
"pubsub_patterns": 0,
"latest_fork_usec": 418,
"total_forks": 2,
"migrate_cached_sockets": 0,
"slave_expires_tracked_keys": 0,
"active_defrag_hits": 0,
"active_defrag_misses": 0,
"active_defrag_key_hits": 0,
"active_defrag_key_misses": 0,
"tracking_total_keys": 0,
"tracking_total_items": 0,
"tracking_total_prefixes": 0,
"unexpected_error_replies": 0,
"total_error_replies": 0,
"dump_payload_sanitizations": 0,
"total_reads_processed": 636672,
"total_writes_processed": 571188,
"io_threaded_reads_processed": 0,
"io_threaded_writes_processed": 0,
"role": "master",
"connected_slaves": 0,
"master_failover_state": "no-failover",
"master_replid": "d39e547b0c69a39512370fde512bc9cb114586a7",
"master_replid2": 0,
"master_repl_offset": 0,
"second_repl_offset": -1,
"repl_backlog_active": 0,
"repl_backlog_size": 1048576,
"repl_backlog_first_byte_offset": 0,
"repl_backlog_histlen": 0,
"used_cpu_sys": 105.647528,
"used_cpu_user": 205.14892,
"used_cpu_sys_children": 0.014904,
"used_cpu_user_children": 0.006582,
"used_cpu_sys_main_thread": 94.077252,
"used_cpu_user_main_thread": 199.540849,
"cluster_enabled": 0,
"db0": {
"keys": 1,
"expires": 1,
"avg_ttl": 1525
}
},
"sys_argv": [
"/opt/venv4archery/bin/gunicorn",
"-w",
"4",
"--env",
"DJANGO_SETTINGS_MODULE=archery.settings",
"--log-level=debug",
"--error-logfile=/tmp/archery.err",
"-b",
"127.0.0.1:8888",
"--preload",
"--timeout",
"600",
"archery.wsgi:application"
],
"platform": [
"Linux",
"archery-5858f4bf58-chn4f",
"3.10.0-1160.el7.x86_64",
"#1 SMP Mon Oct 19 16:18:59 UTC 2020",
"x86_64",
"x86_64"
]
},
"sys_config": {
"go_inception_host": "archery-goinception",
"go_inception_port": "4000",
"inception_remote_backup_host": "archery-mysql-service",
"inception_remote_backup_port": "3306",
"inception_remote_backup_user": "root",
"inception_remote_backup_password": "******",
"critical_ddl_regex": "",
"auto_review_wrong": "",
"enable_backup_switch": true,
"auto_review": false,
"auto_review_tag": "can_write",
"auto_review_db_type": "",
"auto_review_regex": "",
"auto_review_max_update_rows": "",
"manual": "",
"data_masking": true,
"query_check": true,
"disable_star": false,
"max_execution_time": "",
"admin_query_limit": "",
"sqladvisor": "",
"soar": "",
"soar_test_dsn": "",
"archery_base_url": "",
"ddl_notify_auth_group": "",
"notify_phase_control": "Apply,Pass,Execute,Cancel",
"mail": "",
"mail_ssl": "",
"mail_smtp_server": "",
"mail_smtp_port": "",
"mail_smtp_user": "",
"mail_smtp_password": "******",
"ding": "",
"ding_to_person": "",
"ding_agent_id": "",
"ding_app_key": "",
"ding_app_secret": "******",
"ding_archery_username": "",
"ding_dept_ids": "",
"wx": "",
"wx_corpid": "",
"wx_agent_id": "",
"wx_app_secret": "",
"qywx_webhook": "",
"feishu_webhook": "",
"feishu": "",
"feishu_appid": "",
"feishu_app_secret": "******",
"sms_provider": "disabled",
"aliyun_access_key_id": "",
"aliyun_access_key_secret": "",
"aliyun_sign_name": "",
"aliyun_template_code": "",
"aliyun_variable_name": "",
"tencent_secret_id": "",
"tencent_secret_key": "",
"tencent_sign_name": "",
"tencent_template_id": "",
"tencent_sdk_appid": "",
"index_path_url": "",
"my2sql": "",
"default_auth_group": "",
"default_resource_group": "",
"api_user_whitelist": "1",
"lock_time_threshold": "",
"lock_cnt_threshold": "",
"sign_up_enabled": "",
"watermark_enabled": "",
"enforce_2fa": ""
},
"packages": [
"aiohttp==3.8.3",
"aiosignal==1.2.0",
"alibabacloud-credentials==0.2.0",
"alibabacloud-dysmsapi20170525==2.0.9",
"alibabacloud-endpoint-util==0.0.3",
"alibabacloud-gateway-spi==0.0.1",
"alibabacloud-openapi-util==0.1.6",
"alibabacloud-tea-openapi==0.3.4",
"alibabacloud-tea-util==0.3.7",
"alibabacloud-tea-xml==0.0.2",
"alibabacloud-tea==0.2.9",
"aliyun-python-sdk-core-v3==2.13.33",
"aliyun-python-sdk-rds==2.1.1",
"arrow==1.2.3",
"asgiref==3.5.2",
"async-timeout==4.0.2",
"attrs==22.1.0",
"bcrypt==4.0.0",
"blessed==1.19.1",
"certifi==2022.9.24",
"cffi==1.15.1",
"charset-normalizer==2.0.12",
"clickhouse-driver==0.2.3",
"cryptography==38.0.1",
"cx-oracle==7.3.0",
"django-auth-ldap==4.1.0",
"django-environ==0.8.1",
"django-filter==21.1",
"django-mirage-field==1.4.0",
"django-picklefield==3.1",
"django-q==1.3.9",
"django-redis==5.2.0",
"django==4.1.1",
"djangorestframework-simplejwt==5.2.0",
"djangorestframework==3.13.1",
"drf-spectacular==0.22.0",
"frozenlist==1.3.1",
"future==0.18.2",
"gunicorn==20.0.4",
"idna==3.4",
"inflection==0.5.1",
"jinja2==3.1.2",
"jmespath==0.10.0",
"jsonschema==4.16.0",
"markupsafe==2.1.1",
"multidict==6.0.2",
"mybatis-mapper2sql==0.1.9",
"mysql-replication==0.22",
"mysqlclient==2.0.3",
"numpy==1.23.3",
"pandas==1.1.5",
"paramiko==2.11.0",
"parsedatetime==2.4",
"phoenixdb==0.7",
"pillow==9.0.1",
"pip==22.1.2",
"prettytable==3.4.1",
"protobuf==4.21.7",
"psycopg2-binary==2.8.6",
"pyasn1-modules==0.2.8",
"pyasn1==0.4.8",
"pycparser==2.21",
"pycryptodome==3.10.1",
"pyecharts==1.9.1",
"pyjwt==2.5.0",
"pymongo==3.11.0",
"pymysql==0.9.3",
"pynacl==1.5.0",
"pyodbc==4.0.30",
"pyodps==0.10.7.1",
"pyotp==2.6.0",
"pyrsistent==0.18.1",
"python-dateutil==2.8.1",
"python-ldap==3.4.3",
"pytz-deprecation-shim==0.1.0.post0",
"pytz==2022.4",
"pyyaml==6.0",
"qrcode==7.3.1",
"redis==3.5.3",
"requests==2.28.0",
"schema-object==0.5.11",
"schema-sync==0.9.7",
"setuptools==62.6.0",
"simplejson==3.17.2",
"six==1.16.0",
"sqlparse==0.4.3",
"sshtunnel==0.1.5",
"supervisor==4.1.0",
"tencentcloud-sdk-python==3.0.656",
"tqdm==4.64.1",
"tzdata==2022.4",
"tzlocal==4.2",
"uritemplate==4.1.1",
"urllib3==1.26.12",
"wcwidth==0.2.5",
"wheel==0.37.1",
"yarl==1.8.1"
]
}