Java开发机器上的配置及zookeeper配置

Java开发机器上的配置及zookeeper配置

/etc/profile 文件的后面加入下面的内容:

# jdk, zookeeper, kafka, ant, maven
export APACHE_HOME=/usr/local/apache
export KAFKA_HOME=$APACHE_HOME/kafka_2.9.2-0.8.1.1
export ZK_HOME=$APACHE_HOME/zookeeper-3.4.6
export ANT_HOME=$APACHE_HOME/apache-ant-1.8.2
export MAVEN_HOME=$APACHE_HOME/apache-maven-3.2.3

export JAVA_HOME=/usr/local/java/jdk1.7.0_67
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$KAFKA_HOME/bin:$ZK_HOME/bin:$ANT_HOME/bin:$MAVEN_HOME/bin:$PATH

$ source /etc/profile


zookeeper在一台机器上(192.168.122.199)配置成3个实例的伪分布式,配置如下:

# /etc/hosts
------------------------------------------------------------------------
192.168.122.199      zk1

# ----------------------------------------------------------------------
# zk1: 192.168.122.199
# echo "1" > /var/lib/zookeeper/server.1/data/myid
#
# /usr/local/apache/zk-cluster/zk1/zookeeper-3.4.6/conf/zoo.cfg:
# ----------------------------------------------------------------------
dataDir=/var/lib/zookeeper/server.1/data
dataLogDir=/var/lib/zookeeper/server.1/datalog
clientPort=2181
server.1=zk1:2881:3881
server.2=zk1:2882:3882
server.3=zk1:2883:3883

# ----------------------------------------------------------------------
# zk2: 192.168.122.199
# echo "2" > /var/lib/zookeeper/server.2/data/myid
#
# /usr/local/apache/zk-cluster/zk2/zookeeper-3.4.6/conf/zoo.cfg:
# ----------------------------------------------------------------------
dataDir=/var/lib/zookeeper/server.2/data
dataLogDir=/var/lib/zookeeper/server.2/datalog
clientPort=2182
server.1=zk1:2881:3881
server.2=zk1:2882:3882
server.3=zk1:2883:3883

# ----------------------------------------------------------------------
# zk3: 192.168.122.199
# echo "3" > /var/lib/zookeeper/server.3/data/myid
#
# /usr/local/apache/zk-cluster/zk3/zookeeper-3.4.6/conf/zoo.cfg:
# ----------------------------------------------------------------------
dataDir=/var/lib/zookeeper/server.3/data
dataLogDir=/var/lib/zookeeper/server.3/datalog
clientPort=2183
server.1=zk1:2881:3881
server.2=zk1:2882:3882
server.3=zk1:2883:3883


如果是真分布式,部署在3台机器上,只需要把下面的配置成一样即可:

# /etc/hosts
------------------------------------------------------------------------
192.168.122.191      zk1
192.168.122.192      zk2
192.168.122.193      zk3

# 192.168.122.191 zk1: 
# echo "1" > /var/lib/zookeeper/data/myid

# 192.168.122.192 zk2: 
# echo "2" > /var/lib/zookeeper/data/myid

# 192.168.122.193 zk3: 
# echo "3" > /var/lib/zookeeper/data/myid

# zk1, zk2, zk3:
# /usr/local/apache/zookeeper-3.4.6/conf/zoo.cfg:
------------------------------------------------------------------------
dataDir=/var/lib/zookeeper/data
dataLogDir=/var/lib/zookeeper/datalog
clientPort=2181
server.1=zk1:2888:3888
server.2=zk2:2888:3888
server.3=zk3:2888:3888


完毕!

你可能感兴趣的:(Java开发机器上的配置及zookeeper配置)