摘要:使用文章創(chuàng)建的集群下使用部署中創(chuàng)建的集群進(jìn)行的安裝在上制作安裝包下載官方源下載顯得十分緩慢,所以還是選擇國內(nèi)的鏡像源,將下載到創(chuàng)建鏈接下載完成后將解壓并創(chuàng)建鏈接,方便管理修改配置文件中已經(jīng)提供了配置模板,復(fù)制一份
使用文章“Docker創(chuàng)建的集群下使用ansible部署hadoop”中創(chuàng)建的集群進(jìn)行zookeeper的安裝
OS | hostname | IP |
---|---|---|
Centos7 | cluster-master | 172.18.0.2 |
Centos7 | cluster-slave1 | 172.18.0.3 |
Centos7 | cluster-slave1 | 172.18.0.4 |
Centos7 | cluster-slave1 | 172.18.0.5 |
官方源下載顯得十分緩慢,所以還是選擇國內(nèi)的鏡像源,將zookeeper下載到/opt
[root@cluster-master opt]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz創(chuàng)建鏈接
下載完成后將zookeeper-3.4.10.tar.gz解壓并創(chuàng)建鏈接,方便管理
[root@cluster-master opt]# tar -zxvf zookeeper-3.4.10.tar.gz [root@cluster-master opt]# ln -s zookeeper-3.4.10 zookeeper修改配置文件
/opt/zookeeper/conf中已經(jīng)提供了zoo_sample.cfg配置模板,復(fù)制一份zoo.cfg進(jìn)行修改即可使用,我的配置項(xiàng)如下:
[root@cluster-master conf]# cp zoo_sample.cfg zoo.cfg
[root@cluster-master conf]# vi zoo.cfg
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/home/zookeeper/data # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 server.2=172.18.0.2:2888:3888 server.3=172.18.0.3:2888:3888 server.4=172.18.0.4:2888:3888 server.5=172.18.0.5:2888:3888
dataDir做了從新定義,server項(xiàng)使用IP的最后一位,也是為了方便管理
創(chuàng)建shell腳本,完成安裝步驟在/opt/zookeeper下新建postinstall.sh創(chuàng)建dataDir目錄和myid文件,并寫入zoo.cfg中定義的myid值
vi /opt/zookeeper/postinstall.sh #!/bin/bash # zookeeper conf file conf_file="/opt/zookeeper/conf/zoo.cfg" # get myid IP=$(/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6 | awk "{print $2}") ID=$(grep ${IP} ${conf_file}|cut -d = -f 1|cut -d . -f 2) # get dataDir dataDir=$(grep dataDir ${conf_file}|grep -v "^#"|cut -d = -f 2) # create dataDir and myid file mkdir -p ${dataDir} :>${dataDir}/myid echo ${ID} > ${dataDir}/myid打包配置完成后的zookeeper,準(zhǔn)備上傳至slave主機(jī)
將鏈接zookeeper和目錄zookeeper-3.4.10打包并壓縮
[root@cluster-master opt]# tar -zcvf zookeeper-dis.tar.gz zookeeper zookeeper-3.4.10創(chuàng)建yaml,安裝zookeeper
[root@cluster-master opt]# vi install-zookeeper.yaml
--- - hosts: slaves tasks: - name: install ifconfig yum: name=net-tools state=latest - name: unarchive zookeeper unarchive: src=/opt/zookeeper-dis.tar.gz dest=/opt - name: postinstall shell: bash /opt/zookeeper/postinstall.sh分發(fā)安裝文件到slave主機(jī)
[root@cluster-master opt]# ansible-playbook install-zookeeper.yaml啟動zookeeper
此時(shí),zookeeper集群已經(jīng)可以正常啟動
[root@cluster-master opt]# ansible cluster -m command -a "/opt/zookeeper/bin/zkServer.sh start"查看狀態(tài)
[root@cluster-master bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper/bin/../conf/zoo.cfg Mode: follower運(yùn)行客戶端
[root@cluster-master bin]# ./zkCli.sh -server localhost:2181 Connecting to localhost:2181 2017-08-29 18:05:36,078 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT 2017-08-29 18:05:36,091 [myid:] - INFO [main:Environment@100] - Client environment:host.name=cluster-master 2017-08-29 18:05:36,091 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_141 2017-08-29 18:05:36,098 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2017-08-29 18:05:36,098 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/jre 2017-08-29 18:05:36,098 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper/bin/../build/classes:/opt/zookeeper/bin/../build/lib/*.jar:/opt/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/opt/zookeeper/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper/bin/../lib/jline-0.9.94.jar:/opt/zookeeper/bin/../zookeeper-3.4.10.jar:/opt/zookeeper/bin/../src/java/lib/*.jar:/opt/zookeeper/bin/../conf: 2017-08-29 18:05:36,099 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2017-08-29 18:05:36,100 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2017-08-29 18:05:36,100 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=總結(jié)2017-08-29 18:05:36,100 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2017-08-29 18:05:36,100 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2017-08-29 18:05:36,100 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64 2017-08-29 18:05:36,101 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2017-08-29 18:05:36,101 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2017-08-29 18:05:36,101 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.10/bin 2017-08-29 18:05:36,124 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@25f38edc 2017-08-29 18:05:36,205 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2017-08-29 18:05:36,730 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session 2017-08-29 18:05:36,795 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x25e2f22aa660001, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181(CONNECTED) 0] ls / [zookeeper] [zk: localhost:2181(CONNECTED) 1]
使用到了之前創(chuàng)建的集群和ansible,發(fā)現(xiàn)使用ansible部署應(yīng)用確實(shí)很方便。
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/27013.html
摘要:基于安裝好的和集群部署創(chuàng)建的集群下使用部署創(chuàng)建的集群下使用部署在上制作安裝包下載創(chuàng)建目錄,并將軟件包現(xiàn)在到這個(gè)目錄,依然使用國內(nèi)鏡像下載。部署使用執(zhí)行完成的部署工作。 基于安裝好的hadoop和zookeeper集群部署hbase Docker創(chuàng)建的集群下使用ansible部署hadoop Docker創(chuàng)建的集群下使用ansible部署zookeeper OS hostname...
摘要:或許你的第一次微服務(wù)體驗(yàn),就從本文開始在本文中,和等紛紛亮相,并配有詳細(xì)的代碼說明。該角色與本地網(wǎng)絡(luò)及的配置設(shè)置相關(guān)。由于會在虛擬機(jī)初始化過程中自動執(zhí)行配置任務(wù),因此惟一的解決辦法就是將相關(guān)內(nèi)容提取至單獨(dú)的劇本當(dāng)中 這是一篇溫和有趣的技術(shù)文章,如果你初識Docker,對微服務(wù)充滿興趣,不妨一讀。或許你的第一次微服務(wù)體驗(yàn),就從本文開始…… 在本文中,Mesos、Zookeeper、Ma...
摘要:今天小數(shù)給大家?guī)淼氖菙?shù)人云工程師金燁的分享,有關(guān)于自動快速部署服務(wù)相關(guān)組件的一些實(shí)踐。當(dāng)與相遇,雙劍合璧,一切變得如此簡單有趣。通過將服務(wù)注冊到來做健康檢查。 今天小數(shù)給大家?guī)淼氖菙?shù)人云工程師金燁的分享,有關(guān)于自動快速部署DCOS服務(wù)相關(guān)組件的一些實(shí)踐。當(dāng)Ansible與Docker相遇,雙劍合璧,一切變得如此簡單有趣。 本次分享將包括以下內(nèi)容: 云平臺部署使用的服務(wù)、組件 Do...
閱讀 1407·2021-11-24 10:20
閱讀 3649·2021-11-24 09:38
閱讀 2294·2021-09-27 13:37
閱讀 2196·2021-09-22 15:25
閱讀 2270·2021-09-01 18:33
閱讀 3488·2019-08-30 15:55
閱讀 1783·2019-08-30 15:54
閱讀 2081·2019-08-30 12:50