自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(530)
  • 收藏
  • 关注

原创 SQL 找出字符串中连续值的最大个数

需求: 现有一个逗号分隔的,由0和1 组成的字符串,要从这个字符串中找到0连续出现的最大次数。要求: 用SQL实现字符串示例: ‘0,1,0,0,1,1,0,0,0,0,0,1,0,0,1’解题思路:求字符串中0连续出现的最大次数,也就是求0组成的字符串的最大长度,能想到这一点问题就解决一半了。如何找到包含0的字符串?因为这个字符串中只有0,1,逗号。把逗号去除掉后,在按1进行分割,就能找到包含0的字符串。求出每个包含0的字符串的长度求包含0的字符串长度的最大值-- 在Cl

2022-03-20 16:02:12 1239

原创 Did not consume whole string

MongoDB 4.4.10 调整wiredTigerConcurrentWriteTransactions参数时抛出‘Did not consume whole string’ 。解决方式:在设置的值上增加引号。> db.version()4.4.10> db.runCommand({ getParameter:1, "wiredTigerConcurrentWriteTransactions":1}){ "wiredTigerConcurrentWriteTransaction

2022-03-01 18:15:08 779

原创 Hive 数据同步ClickHouse

需求:按条件筛选Hive表中的数据同步到ClickHouse中方法一:按照ClickHouse 官方文档提供的方法,在ClickHouse 中创建HDFS引擎表,读取Hive的数据,将读取的数据插入到ClickHouse本地表中。缺点:1.需要在clickhouse中创建两张表2.如果Hadoop集群压力比较大,在读取HDFS数据的时候会出现超时的情况方法二:在能直接读取HDFS数据的主机上安装clickhouse-client,读取HDFS数据后直接插入ClickHouse。#!/bin/

2022-02-09 18:06:10 6089 2

原创 DB::Exception: test: Authentication failed:

问题描述:想限制特定的IP可以访问clickhouse,使用如下语句创建用户drop user test;CREATE USER test HOST IP '172.18.xxx.xxx' IDENTIFIED WITH sha256_password BY 'test';GRANT SHOW, SELECT, INSERT ON test.* TO test;客户端登陆:确保输入的用户名和密码是正确的clickhouse-client --host 172.18.xxx.xxx --po

2021-10-17 10:00:04 2097

原创 clickhouse-backup

clickhouse-backup -vVersion: 1.0.0Git Commit: 37f3bd78adec2aadc1de10f9323fe426a5e12dc4Build Date: 2021-06-16SELECT version()Query id: 20eab3e5-347d-42fe-82a2-03459476a023┌─version()─┐│ 21.8.3.44 │└───────────┘# clickhouse-ba.

2021-08-21 14:53:26 837 1

原创 Slave has more GTIDs than the master has, using the master‘s SERVER_UUID

机房掉电,con Last_IO_Errno: 1236 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Slave has more GTIDs than the master has, using the master's SERVER_UUID. This may indicate that the end of the binary log was truncated o..

2021-06-21 14:06:07 2745

原创 ClickHouse JSON 函数用法

ClickHouse 支持的JSON函数 SELECT name FROM system.functions WHERE name LIKE '%JSON%' ; -- 1.判断JSON是否合法SELECT isValidJSON('{"a":1}') as isValid;┌─isValid─┐│ 1 │└──────┘--2. 判断JSON是否存在某个值select JSONHas('{"a": "hello", "b": [-100, ...

2021-04-23 21:49:24 6912

原创 clickhouse sha256 函数

MYSQL中的sha256函数返回64位字符串。mysql> select sha2('a',256);+------------------------------------------------------------------+| sha2('a',256) |+-----------------------------------------------------...

2021-04-20 11:58:06 845

原创 MySQL 判断闰年

判断方式:根据二月份的最后一天是不是29天,判断是否是闰年。SELECTYEAR(CURRENT_DATE ()) AS YEAR,CASE WHEN DAY ( last_day( date_add( concat( YEAR ( CURRENT_DATE ()), '-01-01' ), INTERVAL 1 MONTH )))= 29 THEN '润年' ELSE '平年' END AS IS_LEAP...

2021-03-24 17:04:21 1484 1

原创 How to use scan in Python to get or delete data ?

#! /usr/bin/python#coding=utf-8import sysimport redisreload(sys)sys.setdefaultencoding('utf-8')r = redis.StrictRedis(host='127.0.0.1',port=6380,password='foobared')for i in range(20): r.set('key_'+str(i) , i) #print(r.get('key_'+str(i).

2020-09-26 16:03:10 141 1

原创 ERR Target instance replied with error: NOAUTH Authentication required

问题描述:使用Redis的migrate迁移key,当目标Redis 有密码时遇到如下错误。(error) ERR Target instance replied with error: NOAUTH Authentication required.127.0.0.1:6379> info server# Serverredis_version:5.0.9127.0.0.1:6379> MIGRATE 127.0.0.1 6380 key1 0 1000 copy(...

2020-09-25 15:28:03 959 1

原创 Apply Error 1399: Error

问题描述AWS RDS Slave 复制中断,RDS 控制台显示错误信息如下: Apply Error 1399: Error 'XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state' on query. Default dat...

2018-12-30 22:28:37 1813

原创 Waiting for table metadata lock

问题:开发同学反馈一张小表加字段很长时间不能完成,processlist中STATE为Waiting for table metadata lock 请求支援。问题分析:想了一下有两种情况:1.加字段的这个表上有查询长时间未能结束。2.对这个表有事务操作未完成。验证:mysql> select * from information_schema.processl...

2018-11-02 19:45:45 584

原创 MySQL 空事务

问题描述; 研发同事反应MySQL数据库有锁,检查innodb_trx时,发现有很多长时间未结束的空事务。 这些事务的trx_mysql_thread_id都为0,因此不能通过kill   id 的方式强制关闭这些长时间未结束的僵尸事务。   SELECTtrx_mysql_thread_id, trx_id, trx_started, sysdate(), trx_state, t...

2018-10-18 16:47:42 3716 1

原创 mysqldump: [ERROR] unknown variable 'prompt=\u@\h :[\d]>'

问题:使用mysqldump 导出数据时报如下错误:mysqldump --helpmysqldump: [ERROR] unknown variable 'prompt=\u@\h :[\d]>'mysqldump  版本mysqldump  Ver 10.13 Distrib 5.7.22, for linux-glibc2.12 (x86_64)解决办法:把[client]中的prom...

2018-07-13 20:25:24 2977

原创 Docker Compose 构建TiDB

硬件资源有限,但又想体验一下TiDB集群。查阅官方文档后得知可以用Docker Compose的方式来构建TiDB.文档中仅需三步就可用Docker Compose构建一套TiDB集群,心中一阵窃喜。但实际操作起来缺不是很顺利。由于没仔细阅读tidb-docker-compose中的README.md,由于docker和docker-compose版本的问题,走了一些弯路。最终在如下环境下成功构建...

2018-06-02 23:24:18 2339

原创 如何将Mariadb Galera Cluster中的节点转换为slave

由于架构变化需要将Mariadb Galera Cluster中的一个节点转移为slave,步骤如下:正常停止集群中的待转换节点找到该节点最后一个事务的xid值查找候选master上Xid(第2步中找到的xid)所在binlog中下一个事务开始的位置change master启动slave【实验】1.正常停止Mariadb Galera Cluster集群中的待转换节点2.查找待转换为slave节...

2018-05-30 10:33:22 935

原创 ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an acti

MariaDB [test]> rename table mgc_new to mgc;ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction#perror 1192 MySQL error code 1192...

2018-05-28 11:16:32 9294 2

原创 ERROR 1146 (42S02): Table 'test._mgc_new' doesn't exist

测试时发现一个有趣的问题,更新表A,确报表B不存在。这是为什么呢?【实验】MariaDB [test]> update test.mgc set c1='xxx1' where id=4; ERROR 1146 (42S02): Table 'test._mgc_new' doesn't exist检查发现_mgc_new表确实不存在。MariaDB [test]> show ta...

2018-05-26 11:56:03 4539

原创 Mariadb Galera Cluster DDL 的救星pt-online-schema-change

版本信息:MariaDB [information_schema]> select * from GLOBAL_status where variable_name in ('wsrep_provider_name','wsrep_provider_version') union all select * from GLOBAL_VARIABLES where variable_name...

2018-05-25 21:51:56 825

原创 ERROR 1045 (28000): Access denied for user

同事咨询一个关于MySQL用户权限的问题,相同的用户密码在远程机器可以访问成功。但相同的用户密码在本机通过IP访问确报错。ERROR 1045 (28000): Access denied for user。首先想到的是该用户的IP有访问限制。检查发现本机IP在授权的范围内。MariaDB [(none)]> select user,host from mysql.user ...

2018-05-25 21:12:23 2039

原创 ERROR 1047 (08S01): WSREP has not yet prepared node for application use

同事问三个节点的Galera Cluster中如果只剩一个节点了,那么还能提供读写服务吗? 分两种情况: 一、节点正常关闭的情况 如果集群中的两个节点都正常关闭,集群中剩余的一个节点还是可以提供读写服务的。MariaDB [(none)]> SHOW STATUS WHERE Variable_name IN ( 'wsrep_local_state_uuid','wsrep...

2018-05-24 16:38:08 7656

原创 ERROR 1180 (HY000): Got error 5 "Input/output error" during COMMIT

MariaDB [(none)]> select * from information_schema.GLOBAL_status where variable_name in ('wsrep_provider_name','wsrep_provider_version') union all select * from information_schema.GLOBAL_VARIABLES ...

2018-05-24 14:30:10 3154

原创 DDL导致的死锁

MariaDB Galera Cluster 中做DDL时会引起死锁,但这个死锁并不是由于并发导致的。而是Galera Cluster中特有的“坑”。当在MariaDB Galera Cluster中做DDL时,相关表的读写事务都会报死锁的异常。 ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting ...

2018-05-23 19:06:19 2037

原创 WSREP: Node consistency compromised, aborting

Mariadb Galera Cluster中的两个节点几乎同时宕机,检查日志发现如下错误[Warning] WSREP: BF applier failed to open_and_lock_tables: 1146, fatal: 0 wsrep = (exec_mode: 1 conflict_state: 0 seqno: 1080339)[ERROR] Slave SQL: ...

2018-05-22 13:45:43 1461

原创 WSREP: Only binlog_format = 'ROW' is currently supported

Mariadb Galera Cluster 节点启动时出现如下错误:mysqld_safe Starting mysqld daemon with databases from /3336/data mysqld_safe WSREP: Running position recovery with –log_error=’/3336/data/wsrep_r ecovery.NzULcc...

2018-05-21 18:57:49 744

原创 Mariadb Galera Cluster 故障快速拉起

Openstack 的控制节点使用了3个节点的Mariadb Galera Cluster集群。当Mariadb集群因故障重启时,有时会遇到Mariadb Galera Cluster集群无法正常启动的情况。有很多方式能将数据库拉起,但是如何做到快速启动,又不丢失数据呢?经分析日志发现Mariadb Galera Cluster节点宕机时会在日志中打印出如下信息:[Note] WSREP: New...

2018-05-18 20:33:36 5247

原创 The mysql.session exists but is not correctly configured

MySQL5.7.21  执行mysql_upgrade时遇到如下错误:$mysql_upgrade -uroot -p123456 -S /data/3316/logs/mysql.sockmysql_upgrade: [Warning] Using a password on the command line interface can be insecure.Checking if upda...

2018-04-28 12:22:32 3616 2

原创 MySQL 主从延迟几万秒 Queueing master event to the relay log

数据库版本Server version: 5.6.24-log Source distribution问题描述数据采集平台业务数据库由于批量灌数据导致主从延迟上万秒。复制线程长期处于Queueing master event to the relay log状态。监控数据显示1.Seconds_Behind_Master 维持在6w秒左右,且有上升趋势。2.主库有大量的binlog积压无法同步到从...

2018-04-24 18:24:31 2718 2

原创 MySQL5.7 Aborted connection

开发环境数据库升级到MySQL5.7.21 后,日志中断断续续出现[Note] Aborted connection。参考官方文档,分析了一下https://dev.mysql.com/doc/refman/5.7/en/communication-errors.html发现这个描述跟遇到的情况比较类似,即因为客户端空闲时间超过了wait_timeout或interactive_timeout超时...

2018-03-30 16:53:48 10439

原创 ERROR 1265 (01000): Data truncated for column 'ENABLED' at row 7

mysql> UPDATE performance_schema.setup_consumers SET ENABLED = 'OFF' WHERE NAME LIKE 'events_transactions%'; ERROR 1265 (01000): Data truncated for column 'ENABLED' at row 7mysql> show create ta...

2018-03-30 12:06:18 2600

原创 Dba.deploySandboxInstance: (RuntimeError)

用sandbox 搭建InnoDB Cluster环境时遇到如下问题:mysql-js> dba.deploySandboxInstance(3310)A new MySQL sandbox instance will be created on this host in /root/mysql-sandboxes/3310Warning: Sandbox instances are onl...

2018-03-06 09:38:25 688

原创 Lost connection to MySQL server at 'reading initial communication packet', system error: 111 (MySQL

DataClient.cpp: 220|get_all_msgpolicy; SQLException [TCS_Mysql::connect]: mysql_real_connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 (MySQL er

2018-01-31 09:21:17 4504

原创 MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key co

开发环境从库复制出错,错误信息如下:mysql> show slave status\G;Last_Errno: 1217Last_Error: Error 'Cannot delete or update a parent row: a foreign key constraint fails' on query.# perror 1217MySQL error code

2018-01-31 09:07:37 1121

原创 MySQL逻辑备份单表恢复

假设要从一个MySQL整库的逻辑备份中恢复其中的一张表,如何做到快速恢复呢?下面通过巧妙利用授权的方式,快速从逻辑备份中恢复想要的表。一. 数据库备份mysqldump -ubackup -ppassword -S /data/3316/logs/mysql.sock -B --flush-privileges --single-transaction --master-dat

2018-01-12 17:39:57 345

原创 Percona Server is not running with jemalloc

Server version:  5.7.20-18-log Percona Server (GPL), Release 18, Revision 7ce54a6deef安装tokudb引擎遇到如下错误:ps-admin  --enable -uroot -pChecking SELinux status...  FO: SELinux is disabled.

2018-01-04 10:42:07 754

原创 ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def

将一个MyISAM 引擎的表转为InnoDB引擎时出现如下错误:ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a keymysql> CREATE TABLE `t_myisam` (`id` int(10

2017-12-08 17:07:46 1262

原创 ERROR 1062 (23000): Duplicate entry '5' for key 'PRIMARY'

现象:MySQL 主从切换后,新的master上写入数据报主键冲突.错误如下:ERROR 1062 (23000): Duplicate entry '5' for key 'PRIMARY'原因:主从切换后只有一张表有问题,其它的表都正常。由于使用了replace into 方式插入导致新插入数据,导致slave上表的AUTO_INCREMENT小于Master。

2017-09-29 15:54:47 6305

原创 Coordinator stopped because there were error(s) in the worker(s).

MySQL5.7  多源复制其中的一个chaannel 报错如下:mysql> select * from performance_schema.replication_applier_status_by_worker where  LAST_ERROR_NUMBER>0\G*************************** 1. row *******************

2017-09-25 11:12:23 7156

原创 Can't execute the query because you have a conflicting read lock

mysql> create table t (id int(10) );ERROR 1223 (HY000): Can't execute the query because you have a conflicting read lockmysql> select id,user,host,command,time,state from information_sch

2017-09-19 18:16:54 3971

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除