1、启停: ./kafka-server-start.sh -daemon ../config/server.properties ./kafka-server-stop.sh -daemon ../config/server.properties 2、创建topic bin/kafka-topics.sh --create --bootstrap-server localhost:9092 -- […]
分类: Uncategorized
AI是真会编
在搜索引擎时代,查询的结果是从万万千千历史信息中过滤的,当AI来临,结果都是基于历史经验“智能”算出来的,一个是有无,一个是真假。当使用者无法判别结果时,往往就会被“智能化”信息中的坑严重误导 举个栗子,在OCP 908认证中有这么一个关于mysqlcheck的问题,一个选项是mysqlcheck改名为mysqlrepair后执行会自动修复损坏的表,正确or否 看看元宝关于mysqlcheck改名 […]
mysql插件audit_log试用
国产的路感觉越走越远,越走越迷糊 1,在mysql的share目录下找到初始化table/routing/plugin的sql文件,然后在mysql库下执行,文件名是audit_log_filter_linux_install.sql,内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Copyright (c) 2016, 2025, Oracle and/or its affiliates. CREATE TABLE IF NOT EXISTS audit_log_filter(NAME VARCHAR(64) BINARY NOT NULL PRIMARY KEY, FILTER JSON NOT NULL) engine= InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_ci; CREATE TABLE IF NOT EXISTS audit_log_user(USER VARCHAR(32) BINARY NOT NULL, HOST VARCHAR(255) CHARACTER SET ASCII NOT NULL, FILTERNAME VARCHAR(64) BINARY NOT NULL, PRIMARY KEY (USER, HOST), FOREIGN KEY (FILTERNAME) REFERENCES audit_log_filter(NAME)) engine= InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_ci; INSTALL PLUGIN audit_log SONAME 'audit_log.so'; CREATE FUNCTION audit_log_filter_set_filter RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_filter_remove_filter RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_filter_set_user RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_filter_remove_user RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_filter_flush RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_read_bookmark RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_read RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_encryption_password_set RETURNS INTEGER SONAME 'audit_log.so'; CREATE FUNCTION audit_log_encryption_password_get RETURNS STRING SONAME 'audit_log.so'; CREATE FUNCTION audit_log_rotate RETURNS STRING SONAME 'audit_log.so'; SELECT audit_log_filter_flush() AS 'Result'; |
对应的这里还有一个卸载的脚本audit_log_filter_uninstall.sql […]
jmeter之JSR223使用groovy执行linux命令
先展示示例(基于apache-jmeter-5.6.3版本)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
def cmd_list = ["pwd", "ls", "ping 127.0.0.1 -c 1", "who"] def random = new Random() def cmd = cmd_list[random.nextInt(cmd_list.size())] log.info("cmd: ${cmd}") def process = cmd.execute() process.waitFor() def exitCode = process.exitValue() def output = process.text //def error = process.err.text log.info("exit: ${exitCode}, output: ${output}") println("exit: ${exitCode}, output: ${output}") SampleResult.setResponseCode(exitCode.toString()) // 设置响应码(如 0 表示成功) SampleResult.setResponseMessage("${output}") // 设置响应消息 SampleResult.setResponseData(output, "UTF-8") // 设置响应数据 SampleResult.setDataType("text") // 响应数据类型 SampleResult.setDataEncoding("UTF-8") SampleResult.setSampleLabel("Shell Script Executed") // 自定义标签 |
坑点: 1,网上有说要import org.apache.jmeter.samplers.SampleResult,千万不要做这个操作,否则SampleResult对象操作回报错误 2,获取execute错误输出会提示IO Stream已经关闭(待解)
sqlplus一个好用替身SQLcl
官方的工具,使用java写就的,下载后解压,设置好JAVA_HOME就能使用,要求java11以上 https://www.oracle.com/database/sqldeveloper/technologies/sqlcl/download/ 或者直接vim sql,在最顶行添加export JAVA_HOME=/opt/jdk-17.0.12也可以 连接方法和sqlplus基本一致,比如 . […]
python下的数据库连接池dbutils
最近在测试业务的时候,出现长时间并发线程跑sql的时候建立链接耗时的问题,于是搜罗了一下python下是否有链接池的功能,于是乎找到dbutils这个模块,官方路径是在这里 https://webwareforpython.github.io/DBUtils/ 基础使用相对不麻烦,使用pymysql作为连接器进行演示验证
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#coding: utf-8 import pymysql from dbutils.pooled_db import PooledDB import threading from concurrent.futures import ThreadPoolExecutor pool = PooledDB( creator=pymysql, maxconnections=16, # 可同时创建的最大连接数,如果并发很快这里可能会出现超过最大链接数的报错 mincached=4, maxcached=12, maxshared=128, blocking=False, maxusage=None, setsession=["set autocommit=0"], #用于设置session的前导语句 ping=1, reset=True, # mysql登陆参数 host="192.30.2.19", port=3306, user="test1234", passwd="test1234", database="mysql", charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor, # 这里设置返回cursor类型, DictCursor会返回字典类型,带有字段名 ) def run_test(num): tid = threading.currentThread().ident conn = pool.connection() cursor = conn.cursor() cursor.execute("begin") cursor.execute(f"insert into db1.t1(id,tid) values({num}, '{tid}')") cursor.execute(f"select {num} as num, '{tid}' as tid from dual") print(cursor.fetchall()) cursor.execute("commit") conn.close() for i in range(30): # 每次最多创建16个线程 threadpool = ThreadPoolExecutor(16) for j in range(16): threadpool.submit(run_test, *(i*16 + j,)) threadpool.shutdown(wait=True) |
  […]
vscode压缩json插件json-tools
JSON格式化:Ctrl(Cmd)+Alt+M JSON压缩:Alt+M for JSON
[转载]Python中@property和@setter的用法
原文地址:https://www.cnblogs.com/yeer-xuan/p/13488291.html 问题引出 在业务处理时经常需要在数据的读取和存入前对数据进行预处理,通过@property和@*.setter两个装饰器就可以方便的实现。 @property python中的@property装饰器可以总结为两个作用: 让函数可以像普通变量一样使用 对要读取的数据进行预 […]