环境要求:
操作系统 linux
Java 1.6以上
HBase 0.92以上
GnuPlot 4.2以上
编译安装还需要安装Autotools、Make、Python、Git
并且连接外网
实验环境:
Xubuntu16.04 x86_64
IP: 10.49.2.239
VirtualBox5.2.8 桥接模式
- 安装单机zookeeper
tar zxf zookeeper-3.4.13.tar.gz -C /opt/
mv zookeeper-3.4.13 /opt/zookeeper
cp /opt/zookeeper/conf/ zoo_sample.cfg /opt/zookeeper/conf/ zoo.cfg
vi conf/zoo.cfg 内容如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
启动zookeeper
/opt/zookeeper/bin/zkServer.sh start
连接zookeeper
/opt/zookeeper/bin/zkCli.sh -server 10.49.2.239:2181
2. 安装单机hbase
tar zxf hbase-2.1.0-bin.tar.gz –C /opt/
mv /opt/ hbase-2.1.0 /opt/ hbase
mkdir /opt/hbase/logs
mkdir /opt/hbase/data // 用来存放hbase的data数据【生产环境下,处于安全性考虑,hbase数据是存放到hdfs的】
vi /opt/hbase/bin/hbase-env.sh 最后追加3行:
export JAVA_HOME=/opt/jdk
export PATH=${JAVA_HOME}/bin:$PATH
export HBASE_MANAGES_ZK=false
vi /opt/hbase/conf/hbase-site.xml 添加红色部分的代码:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>/opt/hbase/data/</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>16001</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value> <!-- false是单机模式,true是分布式模式。若为false,Hbase和Zookeeper会运行在同一个JVM里面。-->
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost:2181</value>
</property>
</configuration>
vi /opt/hbase/conf/regionservers 内容如下:
localhost
注意regionservers 里面写的内容和上面的hbase.zookeeper.quorum里面的hostname一样。
启动hbase:
/opt/hbase/bin/start-hbase.sh 即可启动hbase
验证:
ss –lnt | grep 16001
ps aux|grep hbase
补充,HDFS+hbase+3节点zk的 hbase-site.xml配置文件写法:
<configuration>
//设置将数据写入hdfs的目录
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/usr/local/hadoop-2.6.0/hbaseData</value>
</property>
//设置hbase模式为集群模式
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
//设置hbase的master端口地址
<property>
<name>hbase.master</name>
<value>hdfs://master:60000</value>
</property>
//HBase Master web界面绑定的端口,默认为0.0.0.0
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
//连接zookeeper的端口设置
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2183</value>
</property>
//设置zookeeper的连接地址(必须为基数个)
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2</value>
</property>
//Zookeeper的zoo.conf中的路径配置,快照的存储位置
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/zookeeper-3.4.6/data</value>
</property>
//Zookeeper连接超时时间
<property>
<name>zookeeper.session.timeout</name>
<value>60000</value>
</property>
</configuration>
3. 安装opentsdb
dpkg –i opentsdb-2.3.1_all.deb
vi /etc/opentsdb/opentsdb.conf 内容如下:
tsd.network.port = 4242
tsd.network.bind = 0.0.0.0
tsd.network.worker_threads = 8
tsd.http.staticroot = /usr/share/opentsdb/static/
tsd.http.cachedir = /tmp/opentsdb
tsd.core.auto_create_metrics = true
tsd.core.plugin_path = /usr/share/opentsdb/plugins
tsd.storage.hbase.zk_quorum = localhost:2181
启动之前,需要到hbase上面去创建表:
cd /usr/share/opentsdb/tools
env COMPRESSION=NONE HBASE_HOME=/opt/hbase ./create_table.sh
启动及验证:
nohup /usr/share/opentsdb/bin/tsdb tsd --config=/etc/opentsdb/opentsdb.conf >/dev/null 2>&1 &
ss -lnt | grep 4242
ps aux|grep opentsdb
访问浏览器的http://10.49.2.239:4242
4. 安装grafana
dpkg –i grafana_5.2.2_amd64.deb
cp /usr/share/grafana/conf/defaults.ini /usr/share/grafana/conf/custom.ini
vi /usr/share/grafana/conf/custom.ini 默认http端口如下:
http_port = 3000
启动及验证:
nohup /usr/sbin/grafana-server -homepath="/usr/share/grafana" web >/dev/null 2>&1 &
grafana默认账号/密码 admin/admin