一. 部署读写分离的契机
目前公司整体项目稳定运行在CDH5.6版本上,与其搭配的Hbase1.0.0无法正确运行Kylin,原因是Kylin只满足Hbase1.1.x+版本。解决方案如下
1. 升级整体CDH版本,从而获得高版本Hbase(方案风险太大)
2. 把Hbase从CDH单独剥离出来,用原生的Hbase高版本替代(方案缺点是管理Hbase不方便,原有的应用难迁移)
3. Kylin读写分离(经验证,CDH5.6的Hbase支持Kylin建CUBE,但无法读(api不兼容),所以只需在另一个集群配置高版本的Hbase即可解决问题,方案高可行,因为既不影响现有的应用,也提高了Kylin的高可用性,一举两得)
二. 环境说明
image
从上图可看出,Kylin支持读写分离,但其设计的初衷是为了分离集群压力,读和写分离,实现高速稳定可用。
当我们在前段发现建CUBE请求时,Build操作在计算集群实现,计算CUBE之后把它load到Hbase集群,最后转成HFILE到Hbase,从而提供前端读。具体到目前我的环境,可把上图抽象为:
1544596170(1)
Kylin版本: apache-kylin-2.4.0-bin-cdh57
集群 机器IP 机器名称 备注
CDH5.6 10.5.8.10 see-data-pre-master-01 集群A 主 (CDH5.6)
CDH5.6 10.5.8.17 see-data-pre-slave-1 集群A 从
CDH5.15.0 10.5.8.12 test-data-master-1 集群B 主 (CDH5.15.0)
CDH5.15.0 10.5.8.6 test-data-slave-1 集群B 从
CDH5.15.0 10.5.8.7 test-data-slave-2 集群B 从
后面我们把CDH5.6集群简述为集群A,CDH5.15.0简述为集群B
三. 部署思路
部署Kylin的读写分离,顾名思义是把写的操作指向集群A,读操作指向集群B,反映到配置上,其实就是:
1. 把集群A中的Hadooo\MR\Hive\Yarn配置复制到部署Kylin的配置目录
2. 把集群B中的Hbase配置文件复制到Kylin的配置目录
3. 配置Kylin.property文件中对集群A和集群B的指针属性
四. 部署过程
1. 首先保证两个集群的所有机器都配置完域名映射,可免密访问,保证两集群可正常运行。
2. Kylin下载解压后放在集群B机器test-data-slave-2 的/home/hadoop/kylin/apache-kylin-2.4.0-bin-cdh57目录下=$KYLIN_HOME
3. 所有配置文件复制到$KYLIN_HOME(CDH的配置文件都默认放在/etc/hadoop/conf; /etc/hive/conf; ….)
把集群A的/etc/hadoop/conf 下的 core-site.xml、hdfs-site.xml、yarn-site.xml、mapred-site.xml 复制到$ YLIN_HOME的conf目录下
把集群A的/etc/hive/conf 下的 hive-site.xml 复制到$KYLIN_HOME的conf目录下
把集群B的/etc/hbase/conf 下的hbase-site.xml 复制到$KYLIN_HOME的conf目录下
原则上,这些从集群拷贝的配置文件都不需要改,但是如果hdfs或者hive的指向地址为本地地址,就需要改成远程访问地址!
[hadoop@test-data-slave-2 conf]$ ll
total 76
-rw-r--r-- 1 hadoop data 3865 Dec 11 15:37 core-site.xml
-rw-r--r-- 1 hadoop data 2926 Dec 11 15:42 hbase-site.xml
-rw-r--r-- 1 hadoop data 1748 Dec 11 15:37 hdfs-site.xml
-rw-r--r-- 1 hadoop data 5517 Dec 11 15:41 hive-site.xml
-rw-r--r-- 1 hadoop data 3605 Jun 20 15:53 kylin_hive_conf.xml
-rw-r--r-- 1 hadoop data 3807 Jun 20 15:53 kylin_job_conf_inmem.xml
-rw-r--r-- 1 hadoop data 3386 Dec 12 11:08 kylin_job_conf.xml
-rw-r--r-- 1 hadoop data 1156 Jun 20 15:53 kylin-kafka-consumer.xml
-rw-r--r-- 1 hadoop data 13112 Dec 11 20:35 kylin.properties
-rw-r--r-- 1 hadoop data 1339 Jun 20 15:53 kylin-server-log4j.properties
-rw-r--r-- 1 hadoop data 1656 Jun 20 15:53 kylin-tools-log4j.properties
-rw-r--r-- 1 hadoop data 4563 Dec 11 15:40 mapred-site.xml
-rwxr-xr-x 1 hadoop data 3649 Jun 20 15:53 setenv.sh
-rw-r--r-- 1 hadoop data 3828 Dec 11 15:39 yarn-site.xml
以下是各个主要文件的配置信息:
core-site.xml
fs.defaultFS
hdfs://see-data-pre-master-01:8020
fs.trash.interval
1
io.compression.codecs
org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.DeflateCodec,org.apache.hadoop.io.compress.SnappyCodec,org.apache.hadoop.io.compress.Lz4Codec
hadoop.security.authentication
simple
hadoop.security.authorization
false
hadoop.rpc.protection
authentication
hadoop.security.auth_to_local
DEFAULT
hadoop.proxyuser.oozie.hosts
*
hadoop.proxyuser.oozie.groups
*
hadoop.proxyuser.mapred.hosts
*
hadoop.proxyuser.mapred.groups
*
hadoop.proxyuser.flume.hosts
*
hadoop.proxyuser.flume.groups
*
hadoop.proxyuser.HTTP.hosts
*
hadoop.proxyuser.HTTP.groups
*
hadoop.proxyuser.hive.hosts
*
hadoop.proxyuser.hive.groups
*
hadoop.proxyuser.hue.hosts
*
hadoop.proxyuser.hue.groups
*
hadoop.proxyuser.httpfs.hosts
*
hadoop.proxyuser.httpfs.groups
*
hadoop.proxyuser.hdfs.groups
*
hadoop.proxyuser.hdfs.hosts
*
hadoop.proxyuser.yarn.hosts
*
hadoop.proxyuser.yarn.groups
*
hadoop.security.group.mapping
org.apache.hadoop.security.ShellBasedUnixGroupsMapping
hadoop.security.instrumentation.requires.admin
false
net.topology.script.file.name
/etc/hadoop/conf.cloudera.yarn/topology.py
io.file.buffer.size
65536
hadoop.ssl.enabled
false
hadoop.ssl.require.client.cert
false
true
hadoop.ssl.keystores.factory.class
org.apache.hadoop.security.ssl.FileBasedKeyStoresFactory
true
hadoop.ssl.server.conf
ssl-server.xml
true
hadoop.ssl.client.conf
ssl-client.xml
true
hbase-site.xml
hbase.rootdir
hdfs://test-data-master-1:8020/hbase_test
hbase.client.write.buffer
2097152
hbase.client.pause
100
hbase.client.retries.number
35
hbase.client.scanner.caching
100
hbase.client.keyvalue.maxsize
10485760
hbase.ipc.client.allowsInterrupt
true
hbase.client.primaryCallTimeout.get
10
hbase.client.primaryCallTimeout.multiget
10
hbase.fs.tmp.dir
/user/${user.name}/hbase-staging
hbase.client.scanner.timeout.period
60000
hbase.coprocessor.region.classes
org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint
hbase.regionserver.thrift.http
false
hbase.thrift.support.proxyuser
false
hbase.rpc.timeout
60000
hbase.snapshot.enabled
true
hbase.snapshot.master.timeoutMillis
60000
hbase.snapshot.region.timeout
60000
hbase.snapshot.master.timeout.millis
60000
hbase.security.authentication
simple
hbase.rpc.protection
authentication
zookeeper.session.timeout
60000
zookeeper.znode.parent
/hbase_test
zookeeper.znode.rootserver
root-region-server-test
hbase.zookeeper.quorum
test-data-master-1,test-data-slave-2,test-data-slave-1
hbase.zookeeper.property.clientPort
2181
hbase.rest.ssl.enabled
false
hdfs-site.xml
dfs.namenode.name.dir
file:///dfs/nn
dfs.namenode.servicerpc-address
see-data-pre-master-01:8022
dfs.https.address
see-data-pre-master-01:50470
dfs.https.port
50470
dfs.namenode.http-address
see-data-pre-master-01:50070
dfs.replication
3
dfs.blocksize
134217728
dfs.client.use.datanode.hostname
false
fs.permissions.umask-mode
022
dfs.namenode.acls.enabled
false
dfs.client.use.legacy.blockreader
false
dfs.client.read.shortcircuit
false
dfs.domain.socket.path
/var/run/hdfs-sockets/dn
dfs.client.read.shortcircuit.skip.checksum
false
dfs.client.domain.socket.data.traffic
false
dfs.datanode.hdfs-blocks-metadata.enabled
true
hive-site.xml
hive.metastore.uris
thrift://see-data-pre-master-01:9083
hive.metastore.client.socket.timeout
300
hive.metastore.warehouse.dir
/user/hive/warehouse
hive.warehouse.subdir.inherit.perms
true
hive.enable.spark.execution.engine
false
hive.conf.restricted.list
hive.enable.spark.execution.engine
hive.auto.convert.join
true
hive.auto.convert.join.noconditionaltask.size
20971520
hive.optimize.bucketmapjoin.sortedmerge
false
hive.smbjoin.cache.rows
10000
mapred.reduce.tasks
-1
hive.exec.reducers.bytes.per.reducer
67108864
hive.exec.copyfile.maxsize
33554432
hive.exec.reducers.max
1099
hive.vectorized.groupby.checkinterval
4096
hive.vectorized.groupby.flush.percent
0.1
hive.compute.query.using.stats
false
hive.vectorized.execution.enabled
true
hive.vectorized.execution.reduce.enabled
false
hive.merge.mapfiles
true