一、引言
最近的一次培训,用户特意提到Hadoop环境下HDFS中存储的文件如何才能导入到HBase,关于这部分基于HBase Java API的写入方式,之前曾经有过技术文章共享,本文就不再说明。本文基于Hive执行HDFS批量向HBase导入数据,讲解Hive与HBase的整合问题。这方面的文章已经很多,但是由于版本差异,可操作性不大,本文采用的版本均基于以下版本说明中的版本。
二、版本说明
序号 | 软件 | 版本 |
1 | Hive | 0.10.0 |
2 | HBase | 0.94.0 |
3 | Hadoop | 1.0.1 |
三、配置指南
3.1 创建配置文件
cp conf/hive-default.xml.template hive-default.xml
cp conf/hive-default.xml.template hive-site.xml
3.2 修改配置文件
基于hive-default.xml.template进行拷贝复制的hive-site.xml文件有问题,主要集中在<description></description>标签不配对的情况,需要根据错误提示进行修改,修改完成后的配置文件如下所示:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 2 3 19 2021 22 23 24 25 26 27 28 29 37 38mapred.reduce.tasks 30-1 31The default number of reduce tasks per job. Typically set 32 to a prime close to the number of available hosts. Ignored when 33 mapred.job.tracker is "local". Hadoop set this to 1 by default, whereas hive uses -1 as its default value. 34 By setting this property to -1, Hive will automatically figure out what should be the number of reducers. 35 3639 43 44hive.exec.reducers.bytes.per.reducer 401000000000 41size per reducer.The default is 1G, i.e if the input size is 10G, it will use 10 reducers. 4245 52 53hive.exec.reducers.max 46999 47max number of reducers will be used. If the one 48 specified in the configuration parameter mapred.reduce.tasks is 49 negative, hive will use this one as the max number of reducers when 50 automatically determine number of reducers. 5154 58 59hive.cli.print.header 55false 56Whether to print the names of the columns in query output. 5760 64 65hive.cli.print.current.db 61false 62Whether to include the current database in the hive prompt. 6366 72 73hive.cli.prompt 67hive 68Command line prompt configuration value. Other hiveconf can be used in 69 this configuration value. Variable substitution will only be invoked at the hive 70 cli startup. 7174 78 79hive.exec.scratchdir 75/tmp/hive-${user.name} 76Scratch space for Hive jobs 7780 84 85hive.exec.local.scratchdir 81/tmp/${user.name} 82Local scratch space for Hive jobs 8386 90 91hive.test.mode 87false 88whether hive is running in test mode. If yes, it turns on sampling and prefixes the output tablename 8992 96 97 98 99 100 101 102 103 104hive.test.mode.prefix 93test_ 94if hive is running in test mode, prefixes the output table by this string 95105 109 110hive.test.mode.samplefreq 10632 107if hive is running in test mode and table is not bucketed, sampling frequency 108111 115 116hive.test.mode.nosamplelist 112113 if hive is running in test mode, dont sample the above comma seperated list of tables 114117 121 122hive.metastore.uris 118119 Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore. 120123 127 128javax.jdo.option.ConnectionURL 124jdbc:derby:;databaseName=metastore_db;create=true 125JDBC connect string for a JDBC metastore 126129 133 134javax.jdo.option.ConnectionDriverName 130org.apache.derby.jdbc.EmbeddedDriver 131Driver class name for a JDBC metastore 132135 139 140javax.jdo.PersistenceManagerFactoryClass 136org.datanucleus.jdo.JDOPersistenceManagerFactory 137class implementing the jdo persistence 138141 145 146javax.jdo.option.DetachAllOnCommit 142true 143detaches all objects from session so that they can be used after transaction is committed 144147 151 152javax.jdo.option.NonTransactionalRead 148true 149reads outside of transactions 150153 157 158javax.jdo.option.ConnectionUserName 154APP 155username to use against metastore database 156159 163 164javax.jdo.option.ConnectionPassword 160mine 161password to use against metastore database 162165 169 170javax.jdo.option.Multithreaded 166true 167Set this to true if multiple threads access metastore through JDO concurrently. 168171 175 176datanucleus.connectionPoolingType 172DBCP 173Uses a DBCP connection pool for JDBC metastore 174177 181 182datanucleus.validateTables 178false 179validates existing schema against code. turn this on if you want to verify existing schema 180183 187 188datanucleus.validateColumns 184false 185validates existing schema against code. turn this on if you want to verify existing schema 186189 193 194datanucleus.validateConstraints 190false 191validates existing schema against code. turn this on if you want to verify existing schema 192195 199 200datanucleus.storeManagerType 196rdbms 197metadata store type 198201 205 206datanucleus.autoCreateSchema 202true 203creates necessary schema on a startup if one doesn't exist. set this to false, after creating it once 204207 211 212datanucleus.autoStartMechanismMode 208checked 209throw exception if metadata tables are incorrect 210213 217 218datanucleus.transactionIsolation 214read-committed 215Default transaction isolation level for identity generation. 216219 223 224datanucleus.cache.level2 220false 221Use a level 2 cache. Turn this off if metadata is changed independently of hive metastore server 222225 229 230datanucleus.cache.level2.type 226SOFT 227SOFT=soft reference based cache, WEAK=weak reference based cache. 228231 235 236datanucleus.identifierFactory 232datanucleus 233Name of the identifier factory to use when generating table/column names etc. 'datanucleus' is used for backward compatibility 234237 241 242datanucleus.plugin.pluginRegistryBundleCheck 238LOG 239Defines what happens when plugin bundles are found and are duplicated [EXCEPTION|LOG|NONE] 240243 247 248hive.metastore.warehouse.dir 244/user/hive/warehouse 245location of default database for the warehouse 246249 253 254hive.metastore.execute.setugi 250false 251In unsecure mode, setting this property to true will cause the metastore to execute DFS operations using the client's reported user and group permissions. Note that this property must be set on both the client and server sides. Further note that its best effort. If client sets its to true and server sets it to false, client setting will be ignored. 252255 259 260hive.metastore.event.listeners 256257 list of comma seperated listeners for metastore events. 258261 265 266hive.metastore.partition.inherit.table.properties 262263 list of comma seperated keys occurring in table properties which will get inherited to newly created partitions. * implies all the keys will get inherited. 264267 271 272hive.metadata.export.location 268269 When used in conjunction with the org.apache.hadoop.hive.ql.parse.MetaDataExportListener pre event listener, it is the location to which the metadata will be exported. The default is an empty string, which results in the metadata being exported to the current user's home directory on HDFS. 270273 277 278hive.metadata.move.exported.metadata.to.trash 274275 When used in conjunction with the org.apache.hadoop.hive.ql.parse.MetaDataExportListener pre event listener, this setting determines if the metadata that is exported will subsequently be moved to the user's trash directory alongside the dropped table data. This ensures that the metadata will be cleaned up along with the dropped table data. 276279 283 284hive.metastore.partition.name.whitelist.pattern 280281 Partition names will be checked against this regex pattern and rejected if not matched. To use, enable hive.metastore.pre.event.listeners=org.apache.hadoop.hive.metastore.PartitionNameWhitelistPreEventListener Listener will not register if this property value is empty. 282285 289 290hive.metastore.end.function.listeners 286287 list of comma separated listeners for the end of metastore functions. 288291 295 296hive.metastore.event.expiry.duration 2920 293Duration after which events expire from events table (in seconds) 294297 301 302hive.metastore.event.clean.freq 2980 299Frequency at which timer task runs to purge expired events in metastore(in seconds). 300303 307 308hive.metastore.connect.retries 3045 305Number of retries while opening a connection to metastore 306309 313 314hive.metastore.failure.retries 3103 311Number of retries upon failure of Thrift metastore calls 312315 319 320hive.metastore.client.connect.retry.delay 3161 317Number of seconds for the client to wait between consecutive connection attempts 318321 325 326hive.metastore.client.socket.timeout 32220 323MetaStore Client socket timeout in seconds 324327 331 332hive.metastore.rawstore.impl 328org.apache.hadoop.hive.metastore.ObjectStore 329Name of the class that implements org.apache.hadoop.hive.metastore.rawstore interface. This class is used to store and retrieval of raw metadata objects such as table, database 330333 337 338hive.metastore.batch.retrieve.max 334300 335Maximum number of objects (tables/partitions) can be retrieved from metastore in one batch. The higher the number, the less the number of round trips is needed to the Hive metastore server, but it may also cause higher memory requirement at the client side. 336339 343 344hive.metastore.batch.retrieve.table.partition.max 3401000 341Maximum number of table partitions that metastore internally retrieves in one batch. 342345 349 350hive.default.fileformat 346TextFile 347Default file format for CREATE TABLE statement. Options are TextFile and SequenceFile. Users can explicitly say CREATE TABLE ... STORED AS <TEXTFILE|SEQUENCEFILE> to override 348351 355 356hive.fileformat.check 352true 353Whether to check file format or not when loading data files 354357 361 362hive.map.aggr 358true 359Whether to use map-side aggregation in Hive Group By queries 360363 367 368hive.groupby.skewindata 364false 365Whether there is skew in data to optimize group by queries 366369 373 374hive.groupby.mapaggr.checkinterval 370100000 371Number of rows after which size of the grouping keys/aggregation classes is performed 372375 379 380hive.mapred.local.mem 3760 377For local mode, memory of the mappers/reducers 378381 385 386hive.mapjoin.followby.map.aggr.hash.percentmemory 3820.3 383Portion of total memory to be used by map-side grup aggregation hash table, when this group by is followed by map join 384387 391 392hive.map.aggr.hash.force.flush.memory.threshold 3880.9 389The max memory to be used by map-side grup aggregation hash table, if the memory usage is higher than this number, force to flush data 390393 397 398hive.map.aggr.hash.percentmemory 3940.5 395Portion of total memory to be used by map-side grup aggregation hash table 396399 405 406hive.map.aggr.hash.min.reduction 4000.5 401Hash aggregation will be turned off if the ratio between hash 402 table size and input rows is bigger than this number. Set to 1 to make sure 403 hash aggregation is never turned off. 404407 411 412hive.optimize.cp 408true 409Whether to enable column pruner 410413 417 418hive.optimize.index.filter 414false 415Whether to enable automatic use of indexes 416419 423 424hive.optimize.index.groupby 420false 421Whether to enable optimization of group-by queries using Aggregate indexes. 422425 429 430hive.optimize.ppd 426true 427Whether to enable predicate pushdown 428431 435 436hive.optimize.ppd.storage 432true 433Whether to push predicates down into storage handlers. Ignored when hive.optimize.ppd is false. 434437 441 442hive.ppd.recognizetransivity 438true 439Whether to transitively replicate predicate filters over equijoin conditions. 440443 447 448hive.optimize.groupby 444true 445Whether to enable the bucketed group by from bucketed partitions/tables. 446449 468 469hive.optimize.skewjoin.compiletime 450false 451Whether to create a separate plan for skewed keys for the tables in the join. 452 This is based on the skewed keys stored in the metadata. At compile time, the plan is broken 453 into different joins: one for the skewed keys, and the other for the remaining keys. And then, 454 a union is performed for the 2 joins generated above. So unless the same skewed key is present 455 in both the joined tables, the join for the skewed key will be performed as a map-side join. 456 457 The main difference between this paramater and hive.optimize.skewjoin is that this parameter 458 uses the skew information stored in the metastore to optimize the plan at compile time itself. 459 If there is no skew information in the metadata, this parameter will not have any affect. 460 Both hive.optimize.skewjoin.compiletime and hive.optimize.skewjoin should be set to true. 461 Ideally, hive.optimize.skewjoin should be renamed as hive.optimize.skewjoin.runtime, but not doing 462 so for backward compatibility. 463 464 If the skew information is correctly stored in the metadata, hive.optimize.skewjoin.compiletime 465 would change the query plan to take care of it, and hive.optimize.skewjoin will be a no-op. 466 467470 484 485hive.optimize.union.remove 471false 472473 Whether to remove the union and push the operators between union and the filesink above 474 union. This avoids an extra scan of the output by union. This is independently useful for union 475 queries, and specially useful when hive.optimize.skewjoin.compiletime is set to true, since an 476 extra union is inserted. 477 478 The merge is triggered if either of hive.merge.mapfiles or hive.merge.mapredfiles is set to true. 479 If the user has set hive.merge.mapfiles to true and hive.merge.mapredfiles to false, the idea was the 480 number of reducers are few, so the number of files anyway are small. However, with this optimization, 481 we are increasing the number of files possibly by a big margin. So, we merge aggresively. 482 483486 493 494hive.mapred.supports.subdirectories 487false 488Whether the version of hadoop which is running supports sub-directories for tables/partitions. 489 Many hive optimizations can be applied if the hadoop version supports sub-directories for 490 tables/partitions. It was added by MAPREDUCE-1501 491 492495 501 502hive.multigroupby.singlemr 496false 497Whether to optimize multi group by query to generate single M/R 498 job plan. If the multi group by query has common group by keys, it will be 499 optimized to generate single M/R job. 500503 510 511hive.map.groupby.sorted 504false 505If the bucketing/sorting properties of the table exactly match the grouping key, whether to 506 perform the group by in the mapper by using BucketizedHiveInputFormat. The only downside to this 507 is that it limits the number of mappers to the number of files. 508 509512 516 517hive.join.emit.interval 5131000 514How many rows in the right-most join operand Hive should buffer before emitting the join result. 515518 522 523hive.join.cache.size 51925000 520How many rows in the joining tables (except the streaming table) should be cached in memory. 521524 528 529hive.mapjoin.bucket.cache.size 525100 526How many values in each keys in the map-joined table should be cached in memory. 527530 534 535hive.mapjoin.cache.numrows 53125000 532How many rows should be cached by jdbm for map join. 533536 546 547hive.optimize.skewjoin 537false 538Whether to enable skew join optimization. 539 The algorithm is as follows: At runtime, detect the keys with a large skew. Instead of 540 processing those keys, store them temporarily in a hdfs directory. In a follow-up map-reduce 541 job, process those skewed keys. The same key need not be skewed for all the tables, and so, 542 the follow-up map-reduce job (for the skewed keys) would be much faster, since it would be a 543 map-join. 544 545548 563 564hive.exec.list.bucketing.default.dir 549HIVE_DEFAULT_LIST_BUCKETING_DIR_NAME 550Default directory name used in list bucketing. 551 List bucketing feature will create sub-directory for each skewed-value and a default directory 552 for non-skewed value. This config specifies the default name for the default directory. 553 Sub-directory is created by list bucketing DML and under partition directory. User doesn't need 554 to know how to construct the canonical path. It just gives user choice if they want to change 555 the default directory name. 556 For example, there are 2 skewed column c1 and c2. 2 skewed value: (1,a) and (2,b). subdirectory: 557 562/c1=1/c2=a/ 558/c1=2/c2=b/ 559/HIVE_DEFAULT_LIST_BUCKETING_DIR_NAME/HIVE_DEFAULT_LIST_BUCKETING_DIR_NAME/ 560 Note: This config won't impact users if they don't list bucketing. 561565 571 572hive.skewjoin.key 566100000 567Determine if we get a skew key in join. If we see more 568 than the specified number of rows with the same key in join operator, 569 we think the key as a skew join key. 570573 579 580hive.skewjoin.mapjoin.map.tasks 57410000 575Determine the number of map task used in the follow up map join job 576 for a skew join. It should be used together with hive.skewjoin.mapjoin.min.split 577 to perform a fine grained control. 578581 587 588hive.skewjoin.mapjoin.min.split 58233554432 583Determine the number of map task at most used in the follow up map join job 584 for a skew join by specifying the minimum split size. It should be used together with 585 hive.skewjoin.mapjoin.map.tasks to perform a fine grained control. 586589 600 601hive.mapred.mode 590nonstrict 591The mode in which the hive operations are being performed. 592 In strict mode, some risky queries are not allowed to run. They include: 593 Cartesian Product. 594 No partition being picked up for a query. 595 Comparing bigints and strings. 596 Comparing bigints and doubles. 597 Orderby without limit. 598 599602 610 611hive.enforce.bucketmapjoin 603false 604If the user asked for bucketed map-side join, and it cannot be performed, 605 should the query fail or not ? For eg, if the buckets in the tables being joined are 606 not a multiple of each other, bucketed map-side join cannot be performed, and the 607 query will fail if hive.enforce.bucketmapjoin is set to true. 608 609612 616 617hive.exec.script.maxerrsize 613100000 614Maximum number of bytes a script is allowed to emit to standard error (per map-reduce task). This prevents runaway scripts from filling logs partitions to capacity 615618 623 624hive.exec.script.allow.partial.consumption 619false 620When enabled, this option allows a user script to exit successfully without consuming all the data from the standard input. 621 622625 630 631hive.script.operator.id.env.var 626HIVE_SCRIPT_OPERATOR_ID 627Name of the environment variable that holds the unique script operator ID in the user's transform function (the custom mapper/reducer that the user has specified in the query) 628 629632 636 637hive.script.operator.truncate.env 633false 634Truncate each environment variable for external script in scripts operator to 20KB (to fit system limits) 635638 642 643hive.exec.compress.output 639false 640This controls whether the final outputs of a query (to a local/hdfs file or a hive table) is compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* 641644 648 649hive.exec.compress.intermediate 645false 646This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* 647650 654 655hive.exec.parallel 651false 652Whether to execute jobs in parallel 653656 660 661hive.exec.parallel.thread.number 6578 658How many jobs at most can be executed in parallel 659662 666 667hive.exec.rowoffset 663false 664Whether to provide the row offset virtual column 665668 672 673hive.task.progress 669false 670Whether Hive should periodically update task progress counters during execution. Enabling this allows task progress to be monitored more closely in the job tracker, but may impose a performance penalty. This flag is automatically set to true for jobs with hive.exec.dynamic.partition set to true. 671674 678 679hive.hwi.war.file 675lib/hive-hwi-0.10.0.war 676This sets the path to the HWI war file, relative to ${HIVE_HOME}. 677680 684 685hive.hwi.listen.host 6810.0.0.0 682This is the host address the Hive Web Interface will listen on 683686 690 691hive.hwi.listen.port 6879999 688This is the port the Hive Web Interface will listen on 689692 696 697hive.exec.pre.hooks 693694 Comma-separated list of pre-execution hooks to be invoked for each statement. A pre-execution hook is specified as the name of a Java class which implements the org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext interface. 695698 702 703hive.exec.post.hooks 699700 Comma-separated list of post-execution hooks to be invoked for each statement. A post-execution hook is specified as the name of a Java class which implements the org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext interface. 701704 708 709hive.exec.failure.hooks 705706 Comma-separated list of on-failure hooks to be invoked for each statement. An on-failure hook is specified as the name of Java class which implements the org.apache.hadoop.hive.ql.hooks.ExecuteWithHookContext interface. 707710 714 715hive.client.stats.publishers 711712 Comma-separated list of statistics publishers to be invoked on counters on each job. A client stats publisher is specified as the name of a Java class which implements the org.apache.hadoop.hive.ql.stats.ClientStatsPublisher interface. 713716 720 721hive.client.stats.counters 717718 Subset of counters that should be of interest for hive.client.stats.publishers (when one wants to limit their publishing). Non-display names should be used 719722 726 727hive.merge.mapfiles 723true 724Merge small files at the end of a map-only job 725728 732 733hive.merge.mapredfiles 729false 730Merge small files at the end of a map-reduce job 731734 738 739hive.mergejob.maponly 735true 736Try to generate a map-only job for merging files if CombineHiveInputFormat is supported. 737740 744 745hive.heartbeat.interval 7411000 742Send a heartbeat after this interval - used by mapjoin and filter operators 743746 750 751hive.merge.size.per.task 747256000000 748Size of merged files at the end of the job 749752 756 757hive.merge.smallfiles.avgsize 75316000000 754When the average output file size of a job is less than this number, Hive will start an additional map-reduce job to merge the output files into bigger files. This is only done for map-only jobs if hive.merge.mapfiles is true, and for map-reduce jobs if hive.merge.mapredfiles is true. 755758 762 763hive.mapjoin.smalltable.filesize 75925000000 760The threshold for the input file size of the small tables; if the file size is smaller than this threshold, it will try to convert the common join into map join 761764 768 769hive.mapjoin.localtask.max.memory.usage 7650.90 766This number means how much memory the local task can take to hold the key/value into in-memory hash table; If the local task's memory usage is more than this number, the local task will be abort by themself. It means the data of small table is too large to be hold in the memory. 767770 774 775hive.mapjoin.followby.gby.localtask.max.memory.usage 7710.55 772This number means how much memory the local task can take to hold the key/value into in-memory hash table when this map join followed by a group by; If the local task's memory usage is more than this number, the local task will be abort by themself. It means the data of small table is too large to be hold in the memory. 773776 780 781hive.mapjoin.check.memory.rows 777100000 778The number means after how many rows processed it needs to check the memory usage 779782 786 787 788hive.auto.convert.join 783false 784Whether Hive enable the optimization about converting common join into mapjoin based on the input file size 785789 793 794hive.script.auto.progress 790false 791Whether Hive Tranform/Map/Reduce Clause should automatically send progress information to TaskTracker to avoid the task getting killed because of inactivity. Hive sends progress information when the script is outputting to stderr. This option removes the need of periodically producing stderr messages, but users should be cautious because this may prevent infinite loops in the scripts to be killed by TaskTracker. 792795 799 800hive.script.serde 796org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe 797The default serde for trasmitting input data to and reading output data from the user scripts. 798801 806 807 808hive.binary.record.max.length 8021000 803Read from a binary stream and treat each hive.binary.record.max.length bytes as a record. 804 The last record before the end of stream can have less than hive.binary.record.max.length bytes 805809 813 814hive.script.recordreader 810org.apache.hadoop.hive.ql.exec.TextRecordReader 811The default record reader for reading data from the user scripts. 812815 819 820hive.script.recordwriter 816org.apache.hadoop.hive.ql.exec.TextRecordWriter 817The default record writer for writing data to the user scripts. 818821 825 826hive.input.format 822org.apache.hadoop.hive.ql.io.CombineHiveInputFormat 823The default input format. Set this to HiveInputFormat if you encounter problems with CombineHiveInputFormat. 824827 831 832hive.udtf.auto.progress 828false 829Whether Hive should automatically send progress information to TaskTracker when using UDTF's to prevent the task getting killed because of inactivity. Users should be cautious because this may prevent TaskTracker from killing tasks with infinte loops. 830833 837 838hive.mapred.reduce.tasks.speculative.execution 834true 835Whether speculative execution for reducers should be turned on. 836839 843 844hive.exec.counters.pull.interval 8401000 841The interval with which to poll the JobTracker for the counters the running job. The smaller it is the more load there will be on the jobtracker, the higher it is the less granular the caught will be. 842845 851 852hive.querylog.location 846/tmp/${user.name} 847848 Location of Hive run time structured log file 849 850853 860 861hive.querylog.enable.plan.progress 854true 855856 Whether to log the plan's progress every time a job's progress is checked. 857 These logs are written to the location specified by hive.querylog.location 858 859862 875 876hive.querylog.plan.progress.interval 86360000 864865 The interval to wait between logging the plan's progress in milliseconds. 866 If there is a whole number percentage change in the progress of the mappers or the reducers, 867 the progress is logged regardless of this value. 868 The actual interval will be the ceiling of (this value divided by the value of 869 hive.exec.counters.pull.interval) multiplied by the value of hive.exec.counters.pull.interval 870 I.e. if it is not divide evenly by the value of hive.exec.counters.pull.interval it will be 871 logged less frequently than specified. 872 This only has an effect if hive.querylog.enable.plan.progress is set to true. 873 874877 881 882hive.enforce.bucketing 878false 879Whether bucketing is enforced. If true, while inserting into the table, bucketing is enforced. 880883 887 888hive.enforce.sorting 884false 885Whether sorting is enforced. If true, while inserting into the table, sorting is enforced. 886889 895 896hive.enforce.sortmergebucketmapjoin 890false 891If the user asked for sort-merge bucketed map-side join, and it cannot be performed, 892 should the query fail or not ? 893 894897 901 902hive.metastore.ds.connection.url.hook 898899 Name of the hook to use for retriving the JDO connection URL. If empty, the value in javax.jdo.option.ConnectionURL is used 900903 907 908hive.metastore.ds.retry.attempts 9041 905The number of times to retry a metastore call if there were a connection error 906909 913 914hive.metastore.ds.retry.interval 9101000 911The number of miliseconds between metastore retry attempts 912915 919 920hive.metastore.server.min.threads 916200 917Minimum number of worker threads in the Thrift server's pool. 918921 925 926hive.metastore.server.max.threads 922100000 923Maximum number of worker threads in the Thrift server's pool. 924927 931 932hive.metastore.server.tcp.keepalive 928true 929Whether to enable TCP keepalive for the metastore server. Keepalive will prevent accumulation of half-open connections. 930933 937 938hive.metastore.sasl.enabled 934false 935If true, the metastore thrift interface will be secured with SASL. Clients must authenticate with Kerberos. 936939 943 944hive.metastore.thrift.framed.transport.enabled 940false 941If true, the metastore thrift interface will use TFramedTransport. When false (default) a standard TTransport is used. 942945 949 950hive.metastore.kerberos.keytab.file 946947 The path to the Kerberos Keytab file containing the metastore thrift server's service principal. 948951 955 956hive.metastore.kerberos.principal 952hive-metastore/_HOST@EXAMPLE.COM 953The service principal for the metastore thrift server. The special string _HOST will be replaced automatically with the correct host name. 954957 961 962hive.cluster.delegation.token.store.class 958org.apache.hadoop.hive.thrift.MemoryTokenStore 959The delegation token store implementation. Set to org.apache.hadoop.hive.thrift.ZooKeeperTokenStore for load-balanced cluster. 960963 967 968hive.cluster.delegation.token.store.zookeeper.connectString 964localhost:2181 965The ZooKeeper token store connect string. 966969 973 974hive.cluster.delegation.token.store.zookeeper.znode 970/hive/cluster/delegation 971The root path for token store data. 972975 979 980hive.cluster.delegation.token.store.zookeeper.acl 976sasl:hive/host1@EXAMPLE.COM:cdrwa,sasl:hive/host2@EXAMPLE.COM:cdrwa 977ACL for token store entries. List comma separated all server principals for the cluster. 978981 985 986hive.metastore.cache.pinobjtypes 982Table,StorageDescriptor,SerDeInfo,Partition,Database,Type,FieldSchema,Order 983List of comma separated metastore object types that should be pinned in the cache 984987 991 992hive.optimize.reducededuplication 988true 989Remove extra map-reduce jobs if the data is already clustered by the same key which needs to be used again. This should always be set to true. Since it is a new feature, it has been made configurable. 990993 997 998hive.exec.dynamic.partition 994true 995Whether or not to allow dynamic partitions in DML/DDL. 996999 1003 1004hive.exec.dynamic.partition.mode 1000strict 1001In strict mode, the user must specify at least one static partition in case the user accidentally overwrites all partitions. 10021005 1009 1010hive.exec.max.dynamic.partitions 10061000 1007Maximum number of dynamic partitions allowed to be created in total. 10081011 1015 1016hive.exec.max.dynamic.partitions.pernode 1012100 1013Maximum number of dynamic partitions allowed to be created in each mapper/reducer node. 10141017 1021 1022hive.exec.max.created.files 1018100000 1019Maximum number of HDFS files created by all mappers/reducers in a MapReduce job. 10201023 1027 1028hive.exec.default.partition.name 1024__HIVE_DEFAULT_PARTITION__ 1025The default partition name in case the dynamic partition column value is null/empty string or anyother values that cannot be escaped. This value must not contain any special character used in HDFS URI (e.g., ':', '%', '/' etc). The user has to be aware that the dynamic partition value should not contain this value to avoid confusions. 10261029 1033 1034hive.stats.dbclass 1030jdbc:derby 1031The default database that stores temporary hive statistics. 10321035 1039 1040hive.stats.autogather 1036true 1037A flag to gather statistics automatically during the INSERT OVERWRITE command. 10381041 1045 1046hive.stats.jdbcdriver 1042org.apache.derby.jdbc.EmbeddedDriver 1043The JDBC driver for the database that stores temporary hive statistics. 10441047 1051 1052hive.stats.dbconnectionstring 1048jdbc:derby:;databaseName=TempStatsStore;create=true 1049The default connection string for the database that stores temporary hive statistics. 10501053 1057 1058hive.stats.default.publisher 10541055 The Java class (implementing the StatsPublisher interface) that is used by default if hive.stats.dbclass is not JDBC or HBase. 10561059 1063 1064hive.stats.default.aggregator 10601061 The Java class (implementing the StatsAggregator interface) that is used by default if hive.stats.dbclass is not JDBC or HBase. 10621065 1069 1070hive.stats.jdbc.timeout 106630 1067Timeout value (number of seconds) used by JDBC connection and statements. 10681071 1075 1076hive.stats.retries.max 10720 1073Maximum number of retries when stats publisher/aggregator got an exception updating intermediate database. Default is no tries on failures. 10741077 1081 1082hive.stats.retries.wait 10783000 1079The base waiting window (in milliseconds) before the next retry. The actual wait time is calculated by baseWindow * failues + baseWindow * (failure + 1) * (random number between [0.0,1.0]). 10801083 1090 1091hive.stats.reliable 1084false 1085Whether queries will fail because stats cannot be collected completely accurately.1086 If this is set to true, reading/writing from/into a partition may fail becuase the stats1087 could not be computed accurately.1088 10891092 1098 1099hive.stats.collect.tablekeys 1093false 1094Whether join and group by keys on tables are derived and maintained in the QueryPlan.1095 This is useful to identify how tables are accessed and to determine if they should be bucketed.1096 10971100 1105 1106hive.stats.ndv.error 110120.0 1102Standard error expressed in percentage. Provides a tradeoff between accuracy and compute cost.A lower value for error indicates higher accuracy and a higher compute cost.1103 11041107 1111 1112hive.support.concurrency 1108false 1109Whether hive supports concurrency or not. A zookeeper instance must be up and running for the default hive lock manager to support read-write locks. 11101113 1117 1118hive.lock.numretries 1114100 1115The number of times you want to try to get all the locks 11161119 1123 1124hive.unlock.numretries 112010 1121The number of times you want to retry to do one unlock 11221125 1129 1130hive.lock.sleep.between.retries 112660 1127The sleep time (in seconds) between various retries 11281131 1135 1136hive.zookeeper.quorum 11321133 The list of zookeeper servers to talk to. This is only needed for read/write locks. 11341137 1141 1142hive.zookeeper.client.port 11382181 1139The port of zookeeper servers to talk to. This is only needed for read/write locks. 11401143 1147 1148hive.zookeeper.session.timeout 1144600000 1145Zookeeper client's session timeout. The client is disconnected, and as a result, all locks released, if a heartbeat is not sent in the timeout. 11461149 1153 1154hive.zookeeper.namespace 1150hive_zookeeper_namespace 1151The parent node under which all zookeeper nodes are created. 11521155 1159 1160hive.zookeeper.clean.extra.nodes 1156false 1157Clean extra nodes at the end of the session. 11581161 1165 1166fs.har.impl 1162org.apache.hadoop.hive.shims.HiveHarFileSystem 1163The implementation for accessing Hadoop Archives. Note that this won't be applicable to Hadoop vers less than 0.20 11641167 1171 1172hive.archive.enabled 1168false 1169Whether archiving operations are permitted 11701173 1177 1178hive.fetch.output.serde 1174org.apache.hadoop.hive.serde2.DelimitedJSONSerDe 1175The serde used by FetchTask to serialize the fetch output. 11761179 1183 1184hive.exec.mode.local.auto 1180false 1181Let hive determine whether to run in local mode automatically 11821185 1191 1192hive.exec.drop.ignorenonexistent 1186true 11871188 Do not report an error if DROP TABLE/VIEW specifies a non-existent table/view1189 11901193 1200 1201hive.exec.show.job.failure.debug.info 1194true 11951196 If a job fails, whether to provide a link in the CLI to the task with the1197 most failures, along with debugging hints if applicable.1198 11991202 1209 1210 1211 1212hive.auto.progress.timeout 12030 12041205 How long to run autoprogressor for the script/UDTF operators (in seconds).1206 Set to 0 for forever.1207 12081213 1217 1218hive.hbase.wal.enabled 1214true 1215Whether writes to HBase should be forced to the write-ahead log. Disabling this improves HBase write performance at the risk of lost writes in case of a crash. 12161219 1223 1224hive.table.parameters.default 12201221 Default property values for newly created tables 12221225 1229 1230hive.entity.separator 1226@ 1227Separator used to construct names of tables and partitions. For example, dbname@tablename@partitionname 12281231 1235 1236hive.ddl.createtablelike.properties.whitelist 12321233 Table Properties to copy over when executing a Create Table Like. 12341237 1241 1242hive.variable.substitute 1238true 1239This enables substitution using syntax like ${var} ${system:var} and ${env:var}. 12401243 1247 1248hive.variable.substitute.depth 124440 1245The maximum replacements the substitution engine will do. 12461249 1253 1254hive.conf.validation 1250true 1251Eables type checking for registered hive configurations 12521255 1259 1260hive.security.authorization.enabled 1256false 1257enable or disable the hive client authorization 12581261 1267 1268hive.security.authorization.manager 1262org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider 1263the hive client authorization manager class name.1264 The user defined authorization class should implement interface org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProvider.1265 12661269 1275 1276hive.security.metastore.authorization.manager 1270org.apache.hadoop.hive.ql.security.authorization.DefaultHiveMetastoreAuthorizationProvider 1271authorization manager class name to be used in the metastore for authorization.1272 The user defined authorization class should implement interface org.apache.hadoop.hive.ql.security.authorization.HiveMetastoreAuthorizationProvider. 1273 12741277 1283 1284hive.security.metastore.authorization.manager 1278org.apache.hadoop.hive.ql.security.authorization.DefaultHiveMetastoreAuthorizationProvider 1279authorization manager class name to be used in the metastore for authorization.1280 The user defined authorization class should implement interface org.apache.hadoop.hive.ql.security.authorization.HiveMetastoreAuthorizationProvider. 1281 12821285 1290 1291hive.security.authenticator.manager 1286org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator 1287hive client authenticator manager class name.1288 The user defined authenticator should implement interface org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider. 12891292 1297 1298hive.security.metastore.authenticator.manager 1293org.apache.hadoop.hive.ql.security.HadoopDefaultMetastoreAuthenticator 1294authenticator manager class name to be used in the metastore for authentication. 1295 The user defined authenticator should implement interface org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider. 12961299 1304 1305hive.security.metastore.authenticator.manager 1300org.apache.hadoop.hive.ql.security.HadoopDefaultMetastoreAuthenticator 1301authenticator manager class name to be used in the metastore for authentication. 1302 The user defined authenticator should implement interface org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider. 13031306 1312 1313hive.security.authorization.createtable.user.grants 13071308 the privileges automatically granted to some users whenever a table gets created.1309 An example like "userX,userY:select;userZ:create" will grant select privilege to userX and userY,1310 and grant create privilege to userZ whenever a new table created. 13111314 1320 1321hive.security.authorization.createtable.group.grants 13151316 the privileges automatically granted to some groups whenever a table gets created.1317 An example like "groupX,groupY:select;groupZ:create" will grant select privilege to groupX and groupY,1318 and grant create privilege to groupZ whenever a new table created. 13191322 1328 1329hive.security.authorization.createtable.role.grants 13231324 the privileges automatically granted to some roles whenever a table gets created.1325 An example like "roleX,roleY:select;roleZ:create" will grant select privilege to roleX and roleY,1326 and grant create privilege to roleZ whenever a new table created. 13271330 1335 1336hive.security.authorization.createtable.owner.grants 13311332 the privileges automatically granted to the owner whenever a table gets created.1333 An example like "select,drop" will grant select and drop privilege to the owner of the table 13341337 1344 1345hive.metastore.authorization.storage.checks 1338false 1339Should the metastore do authorization checks against the underlying storage1340 for operations like drop-partition (disallow the drop-partition if the user in1341 question doesn't have permissions to delete the corresponding directory1342 on the storage). 13431346 1350 1351hive.error.on.empty.partition 1347false 1348Whether to throw an excpetion if dynamic partition insert generates empty results. 13491352 1357 1358hive.index.compact.file.ignore.hdfs 1353false 1354True the hdfs location stored in the index file will be igbored at runtime.1355 If the data got moved or the name of the cluster got changed, the index data should still be usable. 13561359 1363 1364hive.optimize.index.filter.compact.minsize 13605368709120 1361Minimum size (in bytes) of the inputs on which a compact index is automatically used. 13621365 1370 1371hive.optimize.index.filter.compact.maxsize 1366-1 1367Maximum size (in bytes) of the inputs on which a compact index is automatically used.1368 A negative number is equivalent to infinity. 13691372 1376 1377hive.index.compact.query.max.size 137310737418240 1374The maximum number of bytes that a query using the compact index can read. Negative value is equivalent to infinity. 13751378 1382 1383hive.index.compact.query.max.entries 137910000000 1380The maximum number of index entries to read during a query that uses the compact index. Negative value is equivalent to infinity. 13811384 1388 1389hive.index.compact.binary.search 1385true 1386Whether or not to use a binary search to find the entries in an index table that match the filter, where possible 13871390 1394 1395hive.exim.uri.scheme.whitelist 1391hdfs,pfile 1392A comma separated list of acceptable URI schemes for import and export. 13931396 1401 1402hive.lock.mapred.only.operation 1397false 1398This param is to control whether or not only do lock on queries1399 that need to execute at least one mapred job. 14001403 1408 1409hive.limit.row.max.size 1404100000 1405When trying a smaller subset of data for simple LIMIT, how much size we need to guarantee1406 each row to have at least. 14071410 1415 1416hive.limit.optimize.limit.file 141110 1412When trying a smaller subset of data for simple LIMIT, maximum number of files we can1413 sample. 14141417 1421 1422hive.limit.optimize.enable 1418false 1419Whether to enable to optimization to trying a smaller subset of data for simple LIMIT first. 14201423 1428 1429hive.limit.optimize.fetch.max 142450000 1425Maximum number of rows allowed for a smaller subset of data for simple LIMIT, if it is a fetch query.1426 Insert queries are not restricted by this limit. 14271430 1435 1436hive.rework.mapredwork 1431false 1432should rework the mapred work or not.1433 This is first introduced by SymlinkTextInputFormat to replace symlink files with real paths at compile time. 14341437 1445 1446hive.exec.concatenate.check.index 1438true 1439If this sets to true, hive will throw error when doing1440 'alter table tbl_name [partSpec] concatenate' on a table/partition1441 that has indexes on it. The reason the user want to set this to true1442 is because it can help user to avoid handling all index drop, recreation,1443 rebuild work. This is very helpful for tables with thousands of partitions. 14441447 1452 1453hive.sample.seednumber 14480 1449A number used to percentage sampling. By changing this number, user will change the subsets1450 of data sampled. 14511454 1460 1461hive.io.exception.handlers 14551456 A list of io exception handler class names. This is used1457 to construct a list exception handlers to handle exceptions thrown1458 by record readers 14591462 1467 1468hive.autogen.columnalias.prefix.label 1463_c 1464String used as a prefix when auto generating column alias.1465 By default the prefix label will be appended with a column position number to form the column alias. Auto generation would happen if an aggregate function is used in a select clause without an explicit alias. 14661469 1473 1474hive.autogen.columnalias.prefix.includefuncname 1470false 1471Whether to include function name in the column alias auto generated by hive. 14721475 1479 1480hive.exec.perf.logger 1476org.apache.hadoop.hive.ql.log.PerfLogger 1477The class responsible logging client side performance metrics. Must be a subclass of org.apache.hadoop.hive.ql.log.PerfLogger 14781481 1485 1486hive.start.cleanup.scratchdir 1482false 1483To cleanup the hive scratchdir while starting the hive server 14841487 1491 1492hive.output.file.extension 14881489 String used as a file extension for output files. If not set, defaults to the codec extension for text files (e.g. ".gz"), or no extension otherwise. 14901493 1498 1499hive.insert.into.multilevel.dirs 1494false 1495Where to insert into multilevel directories like1496 "insert directory '/HIVEFT25686/chinna/' from table" 14971500 1506 1507hive.warehouse.subdir.inherit.perms 1501false 1502Set this to true if the the table directories should inherit the1503 permission of the warehouse or database directory instead of being created1504 with the permissions derived from dfs umask 15051508 1514 1515hive.exec.job.debug.capture.stacktraces 1509true 1510Whether or not stack traces parsed from the task logs of a sampled failed task for1511 each failed job should be stored in the SessionState1512 15131516 1522 1523hive.exec.driver.run.hooks 15171518 A comma separated list of hooks which implement HiveDriverRunHook and will be run at the1519 beginning and end of Driver.run, these will be run in the order specified1520 15211524 1531 1532hive.ddl.output.format 1525text 15261527 The data format to use for DDL output. One of "text" (for human1528 readable text) or "json" (for a json object).1529 15301533 1541 1542hive.transform.escape.input 1534false 15351536 This adds an option to escape special chars (newlines, carriage returns and1537 tabs) when they are passed to the user script. This is useful if the hive tables1538 can contain data that contains special characters.1539 15401543 1551 1552hive.exec.rcfile.use.explicit.header 1544true 15451546 If this is set the header for RC Files will simply be RCF. If this is not1547 set the header will be that borrowed from sequence files, e.g. SEQ- followed1548 by the input and output RC File formats.1549 15501553 1568 1569hive.multi.insert.move.tasks.share.dependencies 1554false 15551556 If this is set all move tasks for tables/partitions (not directories) at the end of a1557 multi-insert query will only begin once the dependencies for all these move tasks have been1558 met.1559 Advantages: If concurrency is enabled, the locks will only be released once the query has1560 finished, so with this config enabled, the time when the table/partition is1561 generated will be much closer to when the lock on it is released.1562 Disadvantages: If concurrency is not enabled, with this disabled, the tables/partitions which1563 are produced by this query and finish earlier will be available for querying1564 much earlier. Since the locks are only released once the query finishes, this1565 does not apply if concurrency is enabled.1566 15671570 1580 1581hive.fetch.task.conversion 1571minimal 15721573 Some select queries can be converted to single FETCH task minimizing latency.1574 Currently the query should be single sourced not having any subquery and should not have1575 any aggregations or distincts (which incurrs RS), lateral views and joins.1576 1. minimal : SELECT STAR, FILTER on partition columns, LIMIT only1577 2. more : SELECT, FILTER, LIMIT only (+TABLESAMPLE, virtual columns)1578 15791582 1586 1587hive.hmshandler.retry.attempts 15831 1584The number of times to retry a HMSHandler call if there were a connection error 15851588 1592 1593 1594hive.hmshandler.retry.interval 15891000 1590The number of miliseconds between HMSHandler retry attempts 15911595 1599 1600hive.server.read.socket.timeout 159610 1597Timeout for the HiveServer to close the connection if no response from the client in N seconds, defaults to 10 seconds. 15981601 1605 1606hive.server.tcp.keepalive 1602true 1603Whether to enable TCP keepalive for the Hive server. Keepalive will prevent accumulation of half-open connections. 16041607 1610hive.aux.jars.path 1608file:///home/hadoop/source/hive/lib/hive-hbase-handler-0.10.0.jar,file:///home/hadoop/source/hive/lib/hbase-0.94.0.jar,file:///home/hadoop/source/hive/lib/zookeeper-3.4.3.jar 1609
3.3 新增配置属性-hive.aux.jars.path
12 hive.aux.jars.path 3file:///home/hadoop/source/hive/lib/hive-hbase-handler-0.10.0.jar,file:///home/hadoop/source/hive/lib/hbase-0.94.0.jar,file:///home/hadoop/source/hive/lib/zookeeper-3.4.3.jar 4
3.4 拷贝Jar包到Hive/lib目录
hbase-0.94.0.jar,zookeeper-3.4.3.jar
四、测试脚本-创建HBase能够识别的数据表
1 CREATE TABLE hbase_table_1(key int, value string) 2 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 3 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val") 4 TBLPROPERTIES ("hbase.table.name" = "xyz");
五、异常解决
5.1 错误提示
java.lang.NoClassDefFoundError: com/google/protobuf/Messageat org.apache.hadoop.hbase.io.HbaseObjectWritable.(HbaseObjectWritable.java…
5.2 解决方案
将$HBASE_HOME/lib/protobuf-java-2.4.0a.jar 拷贝到 $HIVE_HOME/lib/.
六、运行效果
[hadoop@hadoop1 lib]$ hive -hiveconf hbase.zookeeper.quorum=hadoop1WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.Logging initialized using configuration in jar:file:/home/hadoop/source/hive/lib/hive-common-0.10.0.jar!/hive-log4j.propertiesHive history file=/tmp/hadoop/hive_job_log_hadoop_201401012315_758621762.txthive> CREATE TABLE hbase_table_1(key int, value string) > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' > WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val") > TBLPROPERTIES ("hbase.table.name" = "xyz"); OKTime taken: 23.246 secondshive> show tables;OKhbase_table_1Time taken: 1.346 seconds