我是靠谱客的博主 传统丝袜,最近开发中收集的这篇文章主要介绍hbase 修改表名_HBase建表-修改表属性脚本,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

0.orignal.sh

echo `hbase shell <

exists 'dc_task'

quit

EOF` | grep 'does exist' >/dev/null 2>&1

rtstatus=$?

if [ $rtstatus -ne 0 ]; then

`hbase shell <

create 'dc_task','region'

quit

EOF` >/dev/null 2>&1

fi

1.create-hbase-table.sh

#!/bin/bash

htablename=$1

if [ $# -eq 1 ]; then

date

echo `hbase shell <

exists $htablename

quit

EOF` | grep 'does exist' >/dev/null 2>&1

rtstatus=$?

if [ $rtstatus -ne 0 ]; then

echo $htablename" hbase-table is creating and configuring..."

`hbase shell <

create '$htablename','data'

disable '$htablename'

alter '$htablename', METHOD => 'table_att', 'coprocessor' => 'hdfs:///hbase/lib/observer-$htablename.jar|com.jusfoun.data.DataSyncObserver|1001|es_cluster=elas2.3.4,es_type=data,es_index=hbase,es_port=9300,es_host=localhost--127.0.0.1'

enable '$htablename'

quit

EOF` >/dev/null 2>&1

echo $htablename" hbase-table is successed for create and configure."

else

echo "hbase-table already exists for name:"$htablename

fi

date

else

echo "参数输入有误,请确认后重新运行。"

echo "Usage: sh "$0" "

fi

2.create-hbase-table-es-type.sh

#!/bin/bash

htablename=$1

estypename=$2

if [ $# -eq 2 ]; then

date

echo `hbase shell <

exists $htablename

quit

EOF` | grep 'does exist' >/dev/null 2>&1

rtstatus=$?

if [ $rtstatus -ne 0 ]; then

echo "copying new observer.jar to observer-"$htablename".jar..."

hdfs dfs -cp /hbase/lib/observer.jar /hbase/lib/observer-$htablename.jar

echo $htablename" hbase-table is creating and configuring..."

`hbase shell <

create '$htablename','data'

disable '$htablename'

alter '$htablename', METHOD => 'table_att', 'coprocessor' => 'hdfs:///hbase/lib/observer-$htablename.jar|com.jusfoun.data.DataSyncObserver|1001|es_cluster=elas2.3.4,es_type=$estypename,es_index=hbase,es_port=9300,es_host=localhost--127.0.0.1'

enable '$htablename'

quit

EOF` >/dev/null 2>&1

echo $htablename" hbase-table is successed for create and configure."

else

echo "hbase-table already exists for name:"$htablename

fi

date

else

echo "参数输入有误,请确认后重新运行。"

echo "Usage: sh "$0" "

fi

3.create-hb-es-server.sh

#!/bin/bash

htablename=$1

estypename=$2

if [ $# -eq 2 ]; then

date

echo `hbase shell <

exists $htablename

quit

EOF` | grep 'does exist' >/dev/null 2>&1

rtstatus=$?

if [ $rtstatus -ne 0 ]; then

echo "copying new observer.jar to observer-"$htablename".jar..."

hdfs dfs -cp /hbase/lib/observer.jar /hbase/lib/observer-$htablename.jar

echo $htablename" hbase-table is creating and configuring..."

`hbase shell <

create '$htablename','data'

disable '$htablename'

alter '$htablename', METHOD => 'table_att', 'coprocessor' => 'hdfs:///hbase/lib/observer-$htablename.jar|com.jusfoun.data.DataSyncObserver|1001|es_cluster=esc,es_type=$estypename,es_index=hbase,es_port=9300,es_host=192.168.4.205--192.168.4.206--192.168.4.207'

enable '$htablename'

quit

EOF` >/dev/null 2>&1

echo $htablename" hbase-table is successed for create and configure."

else

echo "hbase-table already exists for name:"$htablename

fi

date

else

echo "参数输入有误,请确认后重新运行。"

echo "Usage: sh "$0" "

fi

4.create-hb-es-index-type.sh

HBaseTableName=$1

sourceDBName=$2

function changeHTableProp{

local htbale=$1

local srcdb=$2

hdfs dfs -cp /hbase/lib/observer.jar /hbase/lib/observer-$htbale.jar

`hbase shell <

disable '$htbale'

alter '$htbale', METHOD => 'table_att', 'coprocessor' => 'hdfs:///hbase/lib/observer-$HBaseTableName.jar|com.jusfoun.data.DataSyncObserver|1001|es_cluster=esc,es_type=$htbale,es_index=$srcdb,es_port=9300,es_host=192.168.4.205--192.168.4.206--192.168.4.207'

enable '$htbale'

quit

EOF` >/dev/null 2>&1

}

echo `hbase shell <

exists $HBaseTableName

quit

EOF` | grep 'does exist' >/dev/null 2>&1

if [ $? -ne 0 ]; then

`hbase shell <

create '$HBaseTableName','data'

quit

EOF` >/dev/null 2>&1

changeHTableProp $HBaseTableName $sourceDBName

fi

changeHTableProp $HBaseTableName $sourceDBName

最后

以上就是传统丝袜为你收集整理的hbase 修改表名_HBase建表-修改表属性脚本的全部内容,希望文章能够帮你解决hbase 修改表名_HBase建表-修改表属性脚本所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部