在实验的3台戴尔服务器上配置了strom集群,简单记录一下。
ubuntu14.04-server系统 3台服务器:172.16.21.1、172.16.21.2、172.16.21.3上 安装storm集群
注意:请先安装jdk和tomact。jdk和tomact的安装以及配置请自行搜索之
注意:以下的安装配置需要在3台服务器上都进行,只是zk和storm的配置文件有所差别。
1.更新源 因为用默认的源更新的话太慢啦
ubuntu 14.04源更新(sources.list)
备份源
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
删除/etc/apt/sources.list文件中内容:ndd( 删除当前行及其后 n-1 行)
编辑/etc/apt/sources.list内容如下(我们使用的是阿里云的源):
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
命令更新
sudo apt-get update
sudo apt-get upgrade
可能出现的问题
使用apt-get进行软件的install或update时,有时会出现以下提示信息:
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
原因是有可能有其他的apt-get进程在活动。
解决办法,把apt-get进程找出来,杀死
ps aux | grep apt-get
sudo kill -9 <PID>
sudo apt-get update
如果再次执行apt-get,还是有这样情况出现,删除/var/lib/dpkg/lock文件,即可
sudo rm -r /var/lib/dpkg/lock
sudo apt-get update
2.安装python
查看当前是否已安装python
python -V
否则进行以下步骤
sudo wget http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tar.bz2
tar -jxvf Python-2.6.6.tar.bz2
cd Python-2.6.6
./configure
make
make install
查看python的版本信息:python -V
3.配置ssh免密码登陆:
cd ~/.ssh/(如果没有这个目录,请先执行一下ssh命令后会自动生成这个目录)
ssh-keygen -t rsa (四个回车)
执行完这个命令后,会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
将公钥拷贝到要免登陆的机器上
scp id_rsa.pub fuwujisuan@172.16.21.2:/home/fuwujisuan/.ssh/authorized_keys
scp id_rsa.pub fuwujisuan@172.16.21.3:/home/fuwujisuan/.ssh/authorized_keys
免登陆后的拷贝形式如下:
scp -r jdk1.7.0_79/ 172.16.21.2:/home/java
scp -r jdk1.7.0_79/ 172.16.21.3:/home/java
如果提示没有权限拷贝则在172.16.21.2 和172.16.21.3进行如下操作:
sudo chown -R fuwujisuan /home/java
ssh 已知主机改变IP后出现的问题解决:
lifei@lifei-ubuntu:~$ ssh fuwujisuan@211.81.52.56
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
91:dc:fc:26:c8:e4:53:06:4e:8e:15:bf:97:d5:7c:04.
Please contact your system administrator.
Add correct host key in /home/lifei/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/lifei/.ssh/known_hosts:1
remove with: ssh-keygen -f "/home/lifei/.ssh/known_hosts" -R 211.81.52.56
ECDSA host key for 211.81.52.56 has changed and you have requested strict checking.
Host key verification failed.
解决方法:
lifei@lifei-ubuntu:~$ cd .ssh
lifei@lifei-ubuntu:~/.ssh$ ls
known_hosts known_hosts~
lifei@lifei-ubuntu:~/.ssh$ sudo vim known_hosts
清空known_hosts内容后保存退出
4.zookeeper的安装配置
1.1解压
sudo tar -zxvf zookeeper-3.4.5.tar.gz -C /home/zk
1.2修改配置
cd /home/zk/zookeeper-3.4.5/conf/
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
修改:dataDir=/home/zk/zookeeper-3.4.5/data
在最后添加:
server.1=172.16.21.1:2888:3888
server.2=172.16.21.2:2888:3888
server.3=172.16.21.3:2888:3888
保存退出
然后创建一个data文件夹
mkdir /home/zk/zookeeper-3.4.5/data
再创建一个空文件
touch /home/zk/zookeeper-3.4.5/data/myid
最后向该文件写入ID
echo 1 > /home/zk/zookeeper-3.4.5/data/myid
1.3将配置好的zookeeper拷贝到其他节点(首先分别在172.16.21.2、172.16.21.3 创建一个zk目录:sudo mkdir /home/zk,sudo chown -R fuwujisuan /home/zk )
scp -r /home/zk/zookeeper-3.4.5/ 172.16.21.2:/home/zk
scp -r /home/zk/zookeeper-3.4.5/ 172.16.21.3:/home/zk
注意:修改172.16.21.2、172.16.21.2对应的/home/zk/zookeeper-3.4.5/data/myid内容
172.16.21.2:
echo 2 > /home/zk/zookeeper-3.4.5/data/myid
172.16.21.3:
echo 3 >/home/zk/zookeeper-3.4.5/data/myid
设置zk的系统环境变量
目录:/home/zk/zookeeper-3.4.5
sudo vim /etc/profile
修改后为:
export JAVA_HOME=/home/java/jdk1.7.0_79
export ZOOKEEPER_HOME=/home/zk/zookeeper-3.4.5
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:${ZOOKEEPER_HOME}/lib
export PATH=${JAVA_HOME}/bin:${ZOOKEEPER_HOME}/bin:$PATH
启动服务
zkServer.sh start
测试服务是否可用
zkCli.sh -server 127.0.0.1:2181
WatchedEvent state:SyncConnected type:None path:null
help
ZooKeeper -server host:port cmd args
connect host:port
get path [watch]
ls path [watch]
set path data [version]
rmr path
delquota [-n|-b] path
quit
printwatches on|off
create [-s] [-e] path data acl
stat path [watch]
close
ls2 path [watch]
history
listquota path
setAcl path acl
getAcl path
sync path
redo cmdno
addauth scheme auth
delete path [version]
setquota -n|-b val path
[zk: 127.0.0.1:2181(CONNECTED) 1] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 2]
启动集群
分别启动zk
zkServer.sh start
查看状态: zkServer.sh status
正常启动2台机器 就可以分配 主从关系了。leader和fallower
演示数据同步
1.在一台机器上启动客户端 zkCli.sh 在一台服务器上启动客户端链接到他自己
2. ls /
get /文件夹 获得里面内容
3.create /storm 123
ls /
get /storm
4.在另外一台机器上启动 ./zkCli.sh
5. ls /
get /storm,得到 123
6.完成数据同步了.
退出客户端 quit
完成内部选举:
1.zkServer.sh status 找到leader
sudo kill -9 进程名
2.查看 其他机器状态zkServer.sh status 看是否有leader
写脚本 通过ssh 启动全部的节点
5.zeroMQ在ubuntu14.04-server 的安装步骤 我已经解决各种问题 安按照此步骤执行即可
http://download.zeromq.org/zeromq-2.1.7.tar.gz
sudo tar -vxzf zeromq-2.1.7.tar.gz -C /home/zeromq
sudo chown -R fuwujisuan /home/zeromq
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install uuid-dev
cd /home/zeromq/zeromq-2.1.7
./configure
sudo apt-get install make
sudo make
sudo make install
6.jzmq在ubuntu14.04-server 的安装步骤 我已经解决各种问题 安按照此步骤执行即可
sudo wget https://github.com/nathanmarz/jzmq/archive/master.zip -O jzmq.zip
sudo apt-get install pkg-config libtool
sudo apt-get install unzip
sudo mkdir /home/jzmq
sudo chown -R fuwujisuan /home/jzmq
sudo unzip jzmq.zip
cd jzmq-master/
sudo apt-get install autoreconf*
sudo ./autogen.sh
./configure
make
touch src/classdist_noinst.stamp
进入目录src/org/zeromq,手动编译Java文件:
cd src/org/zeromq
javac *.java
cd /home/jzmq/jzmq-master
sudo make install
7.storm 在ubuntu14.04-server 的安装步骤 我已经解决各种问题 安按照此步骤执行即可
http://www.storm-project.net/downloads.html
sudo mkdir storm
sudo chown -R fuwujisuan /home/storm
unzip storm-0.8.2.zip
mkdir storm_local
vim conf/storm.yaml
修改storm.yaml文件
storm.zookeeper.servers:
- "172.16.21.1"
- "172.16.21.2"
- "172.16.21.3"
storm.local.dir: "/home/storm/storm-0.8.2/storm_local"
nimbus.host: "172.16.21.1"
supervisor.slots.ports:
- 6700
- 6701
- 6702
- 6703
drpc.servers:
- "172.16.21.1"
worker.childopts: "-Xmx11024m"
scp -r /home/storm/storm-0.8.2 172.16.21.2:/home/storm
scp -r /home/storm/storm-0.8.2 172.16.21.3:/home/storm
设置storm的系统环境变量
目录:/home/storm/storm-0.8.2
sudo vim /etc/profile
修改后为:
export JAVA_HOME=/home/java/jdk1.7.0_79
export ZOOKEEPER_HOME=/home/zk/zookeeper-3.4.5
export STORM_HOME=/home/storm/storm-0.8.2
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:${ZOOKEEPER_HOME}/lib:${STORM_HOME}/lib
export PATH=${JAVA_HOME}/bin:${ZOOKEEPER_HOME}/bin:${STORM_HOME}/bin:$PATH
更新源:
source /etc/profile
启动storm前先启动zk
分别启动zk
zkServer.sh start
storm nimbus >/dev/null 2>&1 & //启动主节点
storm supervisor >/dev/null 2>&1& //启动从节点
storm ui >/dev/null 2>&1 & //启动后台UI管理界面(必须在主节点上启动)
查看Storm是否正常启动
$ jps
关闭客户端仍然可以执行的:
nohup storm nimbus &
nohup storm ui &
nohup storm supervisor &
如果出现 jdk拒接链接的错误,请查看3台服务器的时间是否同步,如不同步请与ntp同步时间
修改ubuntu系统时间
sudo apt-get install ntpdate
sudo ntpdate cn.pool.ntp.org
sudo hwclock --systohc
如果出现文件权限问题可以这样修改:
例如 /home/java出现文件权限问题 fuwujisuan是当前使用的用户名
sudo chown -R fuwujisuan /home/java
注意:以上的安装配置需要在3台服务器上都进行,只是zk和storm的配置文件有所差别。