安装和配置Storm环境第一步 安装zookeeper环境
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装和配置Storm环境第一步 安装zookeeper环境 相关的知识,希望对你有一定的参考价值。
1.安装配置Zookeeper
2.Storm的核心配置文件 $STORM_HOME/conf/storm.yaml
3.注意:如果要搭建Storm的HA(高可用性),nimbus即可.
4.把配置好的安装包复制到其他节点上。
-- 自己搭建zookeeper集群
主节点:centos-00
从节点:centos-01,centos-02
(*)tar -zxvf zookeeper-xxx.tar.gz .
(*)设置环境变量 vi ~/.bash_profile
ZOOKEEPER_HOME=/usr/local/apps/zookeeper-3.4.6
export ZOOKEEPER_HOME
PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
(*)编辑zookeeper配置文件/conf ---> zoo_sample.cfg
cp zoo_sample.cfg zoo.cfg -- 拷贝一份示例
dataDir=/tmp/zookeeper -- zookeeper保存数据的目录 tmp目录linux重启时,数据会清除,需要修改 --> /usr/local/apps/zookeeper-3.5.2-alpha/tmp/
//zookeeper主机配置
zookeeper通信端口:选举端口
server.1=192.168.2.20:2888:3888
server.2=192.168.2.21:2888:3888
server.3=192.168.2.22:2888:3888
在 /usr/local/apps/zookeeper-3.5.2-alpha/tmp 创建文件myid ,填写server后的数字1,或2,或3代表zookeeper主机名
//复制zookeeper应用到第二第三台主机
scp -r zookeeper-3.5.2-alpha/ [email protected]:/usr/local/apps
scp -r zookeeper-3.5.2-alpha/ [email protected]:/usr/local/apps
//三台主机的环境变量刷新生效
source ~/.bash_profile
//修改另两台主机的myid的数字为2,3
//启动zookeeper 并验证
zkServer.sh start -- 三台机器启动
zkServer.sh status -- 查看运行状态
第一台主机是follower ,第二台主机是leader,第三台主机是follower
tips:zookeeper-3.5.2-alpha 版本3.5有点问题。启动集群出错,3.4无问题。记录一下错误,后续再解决。
ZooKeeper 3.5.0 分布式配置好后,执行./zkServer.sh start 命令启动,报如下错误: 2015-07-02 21:06:01,671 [myid:] - INFO [main:[email protected]] - Reading configuration from: /usr/zookeeper/bin/../conf/zoo.cfg 2015-07-02 21:06:01,682 [myid:] - ERROR [main:[email protected]] - Invalid config, exiting abnormally org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Address unresolved: Master.Hadoop:3888 at org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer.<init>(QuorumPeer.java:205) at org.apache.zookeeper.server.quorum.flexible.QuorumMaj.<init>(QuorumMaj.java:89) at org.apache.zookeeper.server.quorum.QuorumPeerConfig.createQuorumVerifier(QuorumPeerConfig.java:401) at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseDynamicConfig(QuorumPeerConfig.java:425) at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:291) at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:126) at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:110) at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79) Invalid config, exiting abnormally
zookeeper特点 : 往一个节点写入一个数据,其他节点会自动同步。
//先登录到zookeeper主机的客户端上
zkCli.sh
ls / 查看根节点的信息 [zookeeper] 只有一个节点
get / 获取信息
zk: localhost:2181(CONNECTED) 0] get / cZxid = 0x0 ctime = Wed Dec 31 16:00:00 PST 1969 mZxid = 0x0 mtime = Wed Dec 31 16:00:00 PST 1969 pZxid = 0x0 cversion = -1 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 0 numChildren = 1 [zk: localhost:2181(CONNECTED) 1] ls / [zookeeper]
create /mydata hellworld 往第一个节点创建节点mydata,写入数据helloworld
ls / 出现了[zookeeper, mydata]
[zk: localhost:2181(CONNECTED) 4] ls /
[zookeeper, mydata]
get /mydata
zk: localhost:2181(CONNECTED) 6] get /mydata helloworld cZxid = 0x100000004 ctime = Tue Jul 18 14:37:22 PDT 2017 mZxid = 0x100000004 mtime = Tue Jul 18 14:37:22 PDT 2017 pZxid = 0x100000004 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0
以上是关于安装和配置Storm环境第一步 安装zookeeper环境 的主要内容,如果未能解决你的问题,请参考以下文章