三:集群安装配置
##############################################################
配置zookeeper集群 (172.16.7.12~13 执行)
###############################################################
1:部署环境介绍:
服务器IP地址主机名安装服务
172.16.7.12ctn-7-12.ptmind.com zookeeper myid=1
172.16.7.13ctn-7-13.ptmind.com zookeeper myid=2
172.16.7.14ctn-7-14.ptmind.com zookeeper myid=3
2:安装软件包
yum -y install mesos mesosphere-zookeeper
3:配置参考(172.16.7.12):
创建id
touch /var/lib/zookeeper/myid
echo 1 > /var/lib/zookeeper/myid #其它节点配置需要修改ID
more /var/lib/zookeeper/myid
添加集群配置文件
cat << EOF >> /etc/zookeeper/conf/zoo.cfg
server.1=ctn-7-12.ptmind.com:2888:3888
server.2=ctn-7-13.ptmind.com:2888:3888
server.3=ctn-7-14.ptmind.com:2888:3888
EOF
启动服务,添加开机启动
systemctl start zookeeper.service
systemctl status zookeeper.service
systemctl enable zookeeper
添加zookeeper 环境变量
vim /etc/profile
#追加zookeeper在尾部 :/opt/mesosphere/zookeeper/bin
。。。。略。。。
export PATH=/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/mesosphere/zookeeper/bin
。。。。略。。。。
指向是环境变量生效
source /etc/profile
故障排查解决:
添加zookeeper配置软连接,解决执行zkServer.sh 报错问题:
ln -s /etc/zookeeper/conf/ /opt/mesosphere/zookeeper/
不添加次软连接会报错:内容如下:
Using config: /opt/mesosphere/zookeeper/bin/../etc/zookeeper/zoo.cfg
grep: /opt/mesosphere/zookeeper/bin/../etc/zookeeper/zoo.cfg: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
grep: /opt/mesosphere/zookeeper/bin/../etc/zookeeper/zoo.cfg: No such file or directory
grep: /opt/mesosphere/zookeeper/bin/../etc/zookeeper/zoo.cfg: No such file or directory
4:验证
(1)
echo ruok|nc 127.0.0.1 2181
imok
(2) 环境变量添加后,输入zk 按tab 键可以补出相应的命令
zkServer.sh status
JMX enabled by default
Using config: /etc/zookeeper/conf/zoo.cfg
Mode: follower
5:按需可以将修改后的配置文件同步到zookeeper集群其它主机,然后修改ID信息;
传输环境变量文件:
for ip in $(cat /workspace/mesoslist);do echo ------$ip-----;rsync -avp /etc/profile root@$ip:/etc/;done
是环境变量生效,检查节点状态:
for ip in $(cat /workspace/mesoslist);do echo ------$ip-----;ssh root@$ip "source /etc/profile && zkServer.sh status";done
查看服务监听端口:
[root@ctn-7-11 conf]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::2181 :::* LISTEN 12975/java
6:修改zookeeper 输出日志文件位置
如果不做修改,默认zookeeper的日志输出信息都打印到了zookeeper.out文件中,这样输出路径和大小没法控制,因为日志文件没有轮转。所以需要修改日志输出方式。具体操作如下:
1、修改$ZOOKEEPER_HOME/bin目录下的zkEnv.sh文件,ZOO_LOG_DIR指定想要输出到哪个目录,ZOO_LOG4J_PROP,指定INFO,ROLLINGFILE的日志APPENDER.
2、建立日志输出文件夹
mkdir -p /var/log/zookeeper
chmod 755 /var/log/zookeeper
vim +57 /opt/mesosphere/zookeeper/bin/zkEnv.sh
55 then
56 # ZOO_LOG_DIR="."
57 ZOO_LOG_DIR="/var/log/zookeeper" #指定想要输出到哪个目录
58 fi
59
60 if [ "x${ZOO_LOG4J_PROP}" = "x" ]
61 then
62 # ZOO_LOG4J_PROP="INFO,CONSOLE"
63 ZOO_LOG4J_PROP="INFO,ROLLINGFILE" #ROLLINGFILE的日志APPENDER.
64 fi
65
4、修改$ZOOKEEPER_HOME/conf/log4j.properties文件的:zookeeper.root.logger的值与前一个文件的ZOO_LOG4J_PROP 保持一致,该日志配置是以日志文件大小轮转的,如果想要按照天轮转,可以修改为DaliyRollingFileAppender.
[root@ctn-7-12 conf]# vim /etc/zookeeper/conf/log4j.properties
1 # Define some default values that can be overridden by system properties
2 zookeeper.root.logger=INFO, ROLLINGFILE #值与前一个文件的ZOO_LOG4J_PROP
3 zookeeper.console.threshold=INFO
.....略......
49 #
50 # Add TRACEFILE to rootLogger to get log file output
51 # Log DEBUG level and above messages to a log file
52 #log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
53 log4j.appender.TRACEFILE=org.apache.log4j.RollingFileAppender #如果想要按照天轮转,可以修改为DaliyRollingFileAppender
54 log4j.appender.TRACEFILE.Threshold=TRACE
55 log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
56
5、配置文件修改完成,重启服务;
service zookeeper restart
6、查看日志,日志输出到修改后位置:
[root@ctn-7-12 conf]# tailf /var/log/zookeeper/zookeeper.log
2016-03-22 16:27:23,704 [myid:2] - INFO [QuorumPeer[myid=2]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:os.name=Linux
2016-03-22 16:27:23,706 [myid:2] - INFO [QuorumPeer[myid=2]/0:0:0:0:0:0:0:0:2181:ZooKeeperSe
7、将修改后的配置文件,可以copy到其它节点
scp zkEnv.sh 172.16.7.13:/opt/mesosphere/zookeeper/bin/
scp /etc/zookeeper/conf/log4j.properties 172.16.7.13:/etc/zookeeper/conf/
###############################################################
Mesos 集群添加 ZooKeeper 信息配置
###############################################################
需要配置zookeeper的地址,写进/etc/mesos/zk ,详细如下:
cat << EOF >/etc/mesos/zk
zk://ctn-7-12.ptmind.com:2181,ctn-7-13.ptmind.com:2181,ctn-7-14.ptmind.com:2181/mesos
EOF
配置mesos-master,需要配置为master的节点都要配置。