首页 文章 精选 留言 我的

精选列表

搜索[数据表],共3323篇文章
优秀的个人博客,低调大师

hive元数据表结构

在debug hive的问题的时候,经常需要分析hive元数据的表结构。 这里简单地说下常用的几个表的结构: dbs 存储了database的一些信息,id,描述,hdfs中的路径和名称。 tbls 存储了table的一些信息,id,表名等。。其中常用的两个字段是SD_ID和TBL_TYPE,SD_ID后面再说。TBL_TYPE字段 定义了表是外部表(EXTERNAL_TABLE)还是托管表(MANAGED_TABLE) hive目前的版本是支持view的,view的定义是在tbls表中,TBL_TYPE字段是VIRTUAL_VIEW。 1 2 3 4 5 6 7 8 select distinct TBL_TYPE from tbls; + ----------------+ | TBL_TYPE | + ----------------+ | MANAGED_TABLE | | EXTERNAL_TABLE | | VIRTUAL_VIEW | + ----------------+ tbls中有另外的两个字段标识了view的sql: VIEW_EXPANDED_TEXT,VIEW_ORIGINAL_TEXT 其中VIEW_ORIGINAL_TEXT 是创建view时输入的sql,而VIEW_EXPANDED_TEXT是对sql进行规范化之后的结果。 table_params 定义了表的statistics信息和一些表的特性,statistics比如文件数量,分区数量,数据量大小等等,不过目前看来不是很准确,特性比如是否可以drop('PROTECT_MODE'='NO_DROP')等。。 sds 表存储了table到hdfs路径和format,serial等信息,常用的字段是CD_ID和LOCATION,通过tbls的tbl_id字段和sds关联,可以得出表在hdfs中的路径信息和CD_ID 1 2 3 4 5 6 select b.tbl_id,b.tbl_name,c.CD_ID,c.location from dbs a,tbls b,sds c where a.DB_ID=b.DB_ID and b.TBL_NAME= 'partition_test' and b.SD_ID=c.SD_ID\G; *************************** 1. row *************************** tbl_id: 430381 tbl_name: partition_test CD_ID: 431456 location: hdfs://bipcluster/bip/hive_warehouse/cdnlog.db/partition_test cds表只存储了cd_id字段 columns_v2 表存储了表的column信息,比如字段名称(COLUMN_NAME),字段类型(TYPE_NAME),字段位置(INTEGER_IDX)等 通过tbls和sds的join可以得出表的cd_id,然后再和columns_v2表进行join即可得出表的字段信息,比如上面的表: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 select * from columns_v2 where cd_id= '431456' \G; *************************** 1. row *************************** CD_ID: 431456 COMMENT: NULL COLUMN_NAME: ip TYPE_NAME: string INTEGER_IDX: 0 *************************** 2. row *************************** CD_ID: 431456 COMMENT: NULL COLUMN_NAME: size TYPE_NAME: string INTEGER_IDX: 2 *************************** 3. row *************************** CD_ID: 431456 COMMENT: NULL COLUMN_NAME: status TYPE_NAME: string INTEGER_IDX: 1 与partition相关的常用表: partitions 表分区相关信息,和tbl_id关联,可以获取分区的SD_ID,然后可以获取分区的hdfs路径和column信息。 1 2 3 4 select a.PART_NAME,b.LOCATION,b.cd_id from partitions a,sds b where a.tbl_id= '430381' and a.sd_id=b.sd_id\G; PART_NAME: dt=20140121 LOCATION: hdfs://bipcluster/bip/hive_warehouse/cdnlog.db/partition_test/dt=20140121 cd_id: 431456 partition_params 和table_params信息一样,存储一些statistics相关的信息 partition_key_vals 分区信息,和 partitions的part_id关联 partition_keys 分区键信息,和tbls的tbl_id关联 权限相关的表: tbl_privs,tbl_col_privs,db_privs,global_privs,roles,role_map 等。 还有剩下的一些表,用得比较少,以后有机会再来看。。 本文转自菜菜光 51CTO博客,原文链接:http://blog.51cto.com/caiguangguang/1353872,如需转载请自行联系原作者

优秀的个人博客,低调大师

最新数据表明Windows 11市场份额已接近10%

根据AdDuplex 11月的调查数据,Windows 11正逐渐接近达到两位数的市场份额。该公司基于6万台Windows 10和Windows 11电脑的最新数据显示,目前有8.6%的电脑在运行Windows 11,比上个月高出3.8%。 与此同时,Windows10版本21H2,这个最新版本的操作系统开始在没有资格使用Windows 11的PC上推出,这一版本本月也出现在AdDuplex的视野中。截至11月底,它的市场份额为3.7%,目前排在Windows 10 2004版(11%)、Windows 10 20H2版(31.8%)和Windows 10 21H1版(36.8%)之后。 如果说AdDuplex的最新数据显示,Windows 11正在稳步上升,那么IT资产管理公司Lansweeper的单独分析则有不同的说法。根据这项基于超过1000万台Windows电脑的研究,11月只有0.21%的电脑在运行Windows 11。AdDuplex的报告关注的是运行AdDuplex广告的更小众的个人电脑,而且有可能是Windows Insiders和早期爱好者,这类用户更有可能运行带有AdDuplex广告的消费者应用程序,从而使结果产生偏差。 微软去年宣布它已经实现登陆10亿台Windows 10月度活跃设备,对于微软而言,现在分享Windows 11的一些官方数字可能还为时尚早。从Windows 11和Windows 10的21H2版本开始,这些操作系统的功能更新每年只在日历年的下半年发布一次,我们可能要等到2022年秋季才能从挂房渠道更好地了解Windows生态系统的情况。 鸿蒙官方战略合作共建――HarmonyOS技术社区 【责任编辑:赵宁宁 TEL:(010)68476606】

优秀的个人博客,低调大师

如何往MySQL的大数据表添中加一列?

以前老版本 MySQL 添加一列的方式: 会造成锁表,简易过程如下: 新建一个和 Table1 完全同构的 Table2 对表 Table1 加写锁 在表 Table2 上执行 ALTER TABLE 你的表 ADD COLUMN 新列 char(128) 将 Table1 中的数据拷贝到 Table2 将 Table2 重命名为 Table1 并移除 Table1,释放所有相关的锁 如果数据量特别特别大,那么锁表时间很长,期间所有表更新都会阻塞,线上业务不能正常执行。 针对MySQL 5.6(不包含)之前的版本,通过触发器将一个表的更新在另一个表上重复,并进行数据同步,当数据同步完成时,业务上修改表名为新表并发布。业务不会暂停。触发器设置类似于: MySQL 5.6(包含)以后的版本引入了在线 DDL 的功能 其中的参数: ALGORITHM: DEFAULT:默认方式,在 MySQL 8.0中,如果未显示指定 ALGORITHM,那么会优先选择 INSTANT 算法,如果不行再使用 INPLACE 算法,如果不支持 INPLACE 算法则使用 COPY 的方式完成 INSTANT:8.0 中新添加的算法,添加列是立即返回。但是不能是虚拟列。这个原理很简单,对于新建一列,表所有原有数据并不是立刻发生变化,只是在表字典里面记录下这个列和默认值,对于默认的 Dynamic 行格式(其实就是 Compressed 的变种),如果更新了这一列则原有数据标记为删除在末尾追加更新后的记录。这样做就是没有提前预留出列空间,之后更新可能经常会发生行记录空间变动。但是对于大多数业务,都是最近的时间的记录才会修改,所以问题不大。 INPLACE:在原表上直接进行修改,不会拷贝临时表,可以逐条记录修改,不会产生大量的 undolog 以及 redolog,不会占用很多 buffer。可以避免重建表带来的IO和CPU消耗,保证期间依然良好的性能和并发。 COPY:拷贝到临时新表上进行修改。由于记录拷贝,会产生大量的 undolog 以及 redolog,并占用很多 buffer,对业务性能有影响。 LOCK: DEFAULT:和 ALGORITHM 的 DEFAULT 类似 NONE:无锁,允许并发读取和更新表 SHARED:共享锁,允许读取不允许更新 EXCLUSIVE:不允许读取和更新 各个版本支持的在线 DDL 修改使用的算法的对比 参考文档: MySQL 5.6:https://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl-operations.html MySQL 5.7:https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html MySQL 8.0:https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html 可以通过: 类似的语句,实现在线增加字段。最好还是明确 ALGORITHM 以及 LOCK,这样执行 DDL 的时候能明确知道到底会对线上业务有多大影响。 同时,执行在线 DDL 的过程大概是 可以看出,在开始阶段需要 metadata lock,metadata lock 是在 5.5 才引入到mysql,之前也有类似保护元数据的机制,只是没有明确提出 metadata lock 概念而已。但是 5.5 之前版本(比如5.1)与5.5之后版本在保护元数据这块有一个显著的不同点是,5.1对于元数据的保护是语句级别的,5.5对于metadata的保护是事务级别的。所谓语句级别,即语句执行完成后,无论事务是否提交或回滚,其表结构可以被其他会话更新;而事务级别则是在事务结束后才释放 metadata lock。 引入 metadata lock 后,主要解决了2个问题,一个是事务隔离问题,比如在可重复隔离级别下,会话A在2次查询期间,会话B对表结构做了修改,两次查询结果就会不一致,无法满足可重复读的要求;另外一个是数据复制的问题,比如会话A执行了多条更新语句期间,另外一个会话B做了表结构变更并且先提交,就会导致 slave 在重做时,先重做 alter,再重做 update 时就会出现复制错误的现象。 如果当前有很多事务在执行,并且有那种包含大查询的事务,例如: 这样类似的会执行较长时间的事务,也会阻塞。 所以,原则上: 避免大事务 在业务低峰去做表结构变化 作者 | 智哥 原文链接 更多技术干货敬请关注码农架构知乎号:码农架构 - 知乎 本文为码农架构原创内容,未经允许不得转载。

优秀的个人博客,低调大师

Azure 云平台用 SQOOP 将 SQL server 2012 数据表导入 HIVE / HBASE

My name is Farooq and I am with HDinsight support team here at Microsoft. In this blog I will try to give some brief overview of Sqoop in HDinsight and then use an example of importing data from a Windows Azure SQL Database table to HDInsight cluster to demonstrate how you can get stated with Sqoop in HDInsight. What is Sqoop? Sqoop is an Apache project and part of Hadoop ecosystem. It allows data transfer between Hadoop\HDInsight cluster and relational databases such as SQL, Oracle, MySQL etc. Sqoop is a collection of related tools, for example import, export, list-all-tables, list-databases etc. To use Sqoop, you specify the tool you want to use and the arguments that control the tool. For more information on Sqoop please check Sqoop User Guide. When do you need to use Sqoop? You need to use Sqoop only when you are trying to import/export data between Hadoop and a relational Database. HDInsight provides a full-featured Hadoop Distributed File System (HDFS) over Windows Azure Blob storage (WABS) and if you want to upload data to HDInsight or WASB from any other source, for example from your local computer's file system then you should use any of the tools discussed in this article. The same article also discusses how to import data to HDFS from SQL Database/SQL Server using Sqoop. In this blog I will elaborate on the same with an example and try to provide more details information along the way. What do I need to do for Sqoop to work in my HDInsight cluster? HDInsight 2.1 includes Sqoop 1.4.3. The Microsoft SQL Server SQOOP Connector for Hadoop is now part of Apache SQOOP 1.4. So you do not need to install the connector separately. All HDInsight clusters also have Microsoft SQL Server JDBC driver installed; so all components that are needed to transfer data between HDInsight cluster and SQL server are already installed in a HDI cluster and you do not have to install anything. How can I run a Sqoop job? With HDInsight preview version we could only run the Sqoop commands from Hadoop command line after doing a remote desktop session (RDP) on the HDInsight cluster head node. However the release version of HDInsight SDK includes the PowerShell cmdlet to run Sqoop job remotely. So we can Run Sqoop jobs locally from HDInsight head node using Hadoop Command Line Run Sqoop job remotely using HDInsight SDK PowerShell cmlets We recommend that you run your Sqoop commands remotely using HDInsight SDK cmdlets . We will discuss both the options in detail. First let's see how we can run Sqoop jobs locally from HDInsight head node using Hadoop Command Line. Run Sqoop jobs locally from HDInsight head node using Hadoop Command Line I am assuming you already have a Windows Azure SQL Database. If you don't and you want to get one please follow the steps in this article. Let's follow the steps below to create a test table and populate with some sample data in your Windows Azure SQL Database which we will import in our HDInsight cluster shortly. I will show how to do this from Windows Azure portal but you can also connect to the Windows Azure SQL Database from SSMS and do the same. Note: if you want to transfer data from a SQL server on your environment instead then you need to change the Sqoop command with appropriate connection information and it should be very similar to the connection string I have provided later in this blog under 'More sample Sqoop commands' section for SQL server on Window Azure VM. Login to your Windows Azure Portal and select 'SQL Databases' from the Left and click 'Manage' at the bottom. Provider your Windows Azure SQL Database user ID and password to login and then click 'New Query' to open a new query window to run T-SQL queries. Copy paste the following T-SQL query and execute to create a test table Table1. CREATE TABLE [dbo].[Table1]( [ID] [int] NOT NULL, [FName] [nvarchar](50) NOT NULL, [LName] [nvarchar](50) NOT NULL, CONSTRAINT [PK_Table_4] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) ON [PRIMARY] GO Run the Following to Populate Table1 with 4 rows. INSERT INTO [dbo].[Table1] VALUES (1,'Jhon','Doe'), (2,'Harry','Hoe'), (3, 'Carla','Coe'), (4,'Jackie','Joe'); GO Now finally run the following T-SQL to make sure that is table is populated with the sample data. You should see the output as below. SELECT * from [dbo].[Table1] Now let's follow the steps below to Import the rows in Table1 to the HDInsight Cluster. Login to your HDInsight cluster head node via Remote Desktop (RDP) and double click the 'Hadoop Command Line' icon in the desktop to open Hadoop Command Line. RDP access is turned off by default but you can follow the steps inthis blog to enable RDP and then RDP to the head node of your HDInsight cluster. In Hadoop Command Line please navigate tothe "C:\apps\dist\sqoop-1.4.3.1.3.1.0-06\bin" folder. Note: Please verify the path for the Sqoop bin folder in your environment. It may slightly vary from version to version. Run the following Sqoop command to importall the rows of table "Table1" from Windows Azure SQL Database "mfarooqSQLDB" to HDInsight Cluster. sqoop.cmd import –-connect "jdbc:sqlserver://<SQLDatabaseServerName>.database.windows.net:1433;username=<SQLDatabasUsername>@<SQLDatabaseServerName>;password=<SQLDatabasePassword>;database=<SQLDatabaseDatabaseName>" --table Table1 --target-dir /user/hdp/SqoopImportTable1 Once the command is executed successfully you should see something similar as below in Hadoop Command Line window. There are quite a number of tools available to upload/download and view data in WASB. Let's use Azure Storage Explorer tool. You need to install the tool in your work station and configure for your cluster. Once all is done open the tool and find out /user/hdp/SqoopImportTable1 folder. You should see something similar as below. It shows 4 files indicating 4 map jobs were used. You can select a file and click the 'View' button to see the actual text data. Now let's export the same rows back to the SQL server from HDInsight cluster. Please use a different table with the same schema as 'Table1'. Otherwise you would get a Primary Key violation error since the rows already exist in 'Table1'. Create an empty table 'Table2' with the same schema as 'Table1'. CREATE TABLE [dbo].[Table2]( [ID] [int] NOT NULL, [FName] [nvarchar](50) NOT NULL, [LName] [nvarchar](50) NOT NULL, CONSTRAINT [PK_Table_2] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) ON [PRIMARY] GO Run the following Sqoop command from Hadoop Command Line. sqoop.cmd export --connect "jdbc:sqlserver://<SQLDatabaseServerName>.database.windows.net:1433;username=<SQLDatabasUsername>@<SQLDatabaseServerName>;password=<SQLDatabasePassword>;database=<SQLDatabaseDatabaseName>" --table Table2 --export-dir /user/hdp/SqoopImportTable1 --input-fields-terminated-by "," More sample Sqoop commands: Import from a SQL server on Window Azure VM: sqoop.cmd import --connect "jdbc:sqlserver:// <WindowsAzureVMServerName>.cloudapp.net:1433; username=<SQLServerUserName>; password=<SQLServerPassword>; database=<SQLServerDatabaseName>" --table Table_1 --target-dir /user/hdp/SqoopImportTable Export to a SQL server on Window Azure VM: sqoop.cmd export --connect "jdbc:sqlserver://<WindowsAzureVMServerName>.cloudapp.net:1433; username=<SQLServerUserName>; password=<SQLServerPassword>; database=<SQLServerDatabaseName>" --table Table_2 --export-dir /user/hdp/SqoopImportTable2 --input-fields-terminated-by "," Importing to HIVE from Windows Azure SQL Database: C:\apps\dist\sqoop-1.4.2\bin>sqoop.cmd import –connect "jdbc:sqlserver://<WindowsAzureVMServerName>.cloudapp.net:1433; username=<SQLServerUserName>; password=<SQLServerPassword>; database=<SQLServerDatabaseName>" --table Table1 --hive-import Note: This will store the files under hive/warehouse/TableName folder in HDFS (For example hive/warehouse/table1/part-m-00000 ) Run Sqoop job remotely using HDInsight SDK PowerShell cmlets To use HDInsight PowerShell tools you need to install Windows Azure PowerShell tools first and then install HDInsight PowerShell tools. Then you need to prepare your workstation to use the HDInsight SDK. Please follow the detail steps in this earlier blog post to install the tools and prepare your work station to use the HDInsight SDK. Once you have installed and configured Windows Azure PowerShell tools and HDInsight SDK running a Sqoop job is very easy. Please follow the steps below to import all the rows of table "Table2" fromWindows Azure SQL Database "mfarooqSQLDB" to HDInsight Cluster. Open the Windows azure PowerShell console on the workstation and run the following cmdlets one at a time. Note: You can also use Windows Powershell ISE to type the code and run all at once. Powershell ISE makes edits easy and you can open the tool from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe". Set the variables for your Windows Azure Subscription name and the HDInsight cluster name. $subscriptionName = "<WindowsAzureSubscriptionName>" $clusterName = "<HDInsightClusterName>" Select-AzureSubscription $subscriptionName Use-AzureHDInsightCluster $clusterName -Subscription $subscriptionName Define the Sqoop job that we want to run. In this exercise we will importall the rows of table "Table2" that we created earlier in Windows Azure SQL Database. $sqoop = New-AzureHDInsightSqoopJobDefinition -Command "import --connect jdbc:sqlserver://<SQLDatabaseServerName>.database.windows.net:1433;username=<SQLDatabasUsername>@<SQLDatabaseServerName>; password=<SQLDatabasePassword>; database=<SQLDatabaseDatabaseName> --table Table2 --target-dir /user/hdp/SqoopImportTable8" Run the Sqoop job that we just defined. $sqoopJob = Start-AzureHDInsightJob -Subscription $subscriptionName -Cluster $clusterName -JobDefinition $sqoop Run the following to wait for the completion or failure of the HDInsight job and show its progress. Wait-AzureHDInsightJob -Subscription $subscriptionName -WaitTimeoutInSeconds 3600 -Job $sqoopJob Run the following to retrieve the log output for a job from the storage account associated with a specified cluster. Get-AzureHDInsightJobOutput -Cluster $clusterName -Subscription $subscriptionName -StandardError -JobId $sqoopJob.JobId If the Sqoop job completes successfully you should see something similar as below in your Windows Azure PowerShell command line window. Troubleshooting tips When you run a Sqoop job command it runs MapReduce job in Hadoop Cluster (map only and no reduce task). You can specify the number of map tasks but by default four tasks are used. There is no separate log file specific to Sqoop. So we need to troubleshoot Sqoop job failure or performance issues as any other MapReduce job failure or performance issues and start by checking the task logs. I plan to write more on how to troubleshot Sqoop issues by focusing on some specific scenarios in the near future. That's all for today and I hope you found this blog useful. I look forward to your comments and suggestions J.

优秀的个人博客,低调大师

无代码/低代码 平台 NocoBase 发布 V0.7.1,增强数据表关系的建立

NocoBase 是一个极易扩展的开源无代码开发平台。 无需编程,使用 NocoBase 搭建自己的协作平台、管理系统,只需要几分钟时间。 本周我们发布了 V0.7.1,带来以下新功能: 新的字段: 公式 表关系(o2o, o2m, m2o, m2m) 新的区块类型: 图表(g2plot) 新的插件: 操作记录 导出 工作流(定时任务) 中文官网: https://cn.nocobase.com/ 在线体验: https://demo-cn.nocobase.com/new 文档: https://docs-cn.nocobase.com/

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册