Chinaunix首页 | 论坛 | 博客
  • 博客访问: 875509
  • 博文数量: 204
  • 博客积分: 2433
  • 博客等级: 大尉
  • 技术积分: 2205
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-05 13:32
文章分类

全部博文(204)

分类: LINUX

2017-09-11 16:16:45

节点上的zookeeper.service不指定JAVA_HOME的写法:
[Unit] 
Description=hadoop
After=network.target 

[Service] 
Type=forking
PIDFile=/opt/zookeeper/data/zookeeper_server.pid
ExecStart=/bin/su - hadoop -c "/usr/local/zookeeper/bin/zkServer.sh start"
ExecStop=/bin/su - hadoop -c "/usr/local/zookeeper/bin/zkServer.sh stop"
PrivateTmp=true 

[Install] 
WantedBy=multi-user.target
====================
节点上的zookeeper.service指定JAVA_HOME的写法:
[Unit] 
Description=zookeeper
After=network.target 

[Service] 
Type=forking 
User=hadoop
Group=hadoop
Environment=JAVA_HOME=/usr/local/lib/jdk1.8.0_144
PIDFile=/opt/zookeeper/data/zookeeper_server.pid
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
PrivateTmp=true 

[Install] 
WantedBy=multi-user.target
================
Master hbase.service
[Unit] 
Description=hbase
After=network.target

[Service] 
Type=forking
User=hadoop
Group=hadoop
Environment=JAVA_HOME=/usr/local/lib/jdk1.8.0_144
#Environment=HBASE_HOME=/opt/hbase-1.2.6
#WorkingDirectory=/opt/hbase-1.2.6
PIDFile=/var/hadoop/pids/hbase-hadoop-master.pid
ExecStart=/opt/hbase-1.2.6/bin/start-hbase.sh
ExecStop=/opt/hbase-1.2.6/bin/stop-hbase.sh
#PrivateTmp=true 

[Install] 
WantedBy=multi-user.target
==============
Master节点上的hadoop.service:
[Unit] 
Description=hadoop
After=network.target

[Service] 
Type=forking
User=hadoop
Group=hadoop
Environment=JAVA_HOME=/usr/local/lib/jdk1.8.0_144
Environment=HADOOP_HOME=/usr/local/hadoop
WorkingDirectory=/usr/local/hadoop
PIDFile=/var/hadoop/pids/yarn-hadoop-resourcemanager.pid
PIDFile=/var/hadoop/pids/hadoop-hadoop-secondarynamenode.pid
PIDFile=/var/hadoop/pids/hadoop-hadoop-namenode.pid
ExecStart=/usr/local/hadoop/sbin/start-dfs.sh
ExecStop=/usr/local/hadoop/sbin/stop-dfs.sh
#PrivateTmp=true 

[Install] 
WantedBy=multi-user.target

以上hadoop.service不支持多列execstart,所以在start-dfs.sh和stop-dfs.sh尾行分别加入/usr/local/hadoop/sbin/start-yarn.sh和/usr/local/hadoop/sbin/stop-yarn.sh,这样启动和停止dfs也顺带启动停止yarn,最后重启所有服务器:
因为Master上的hadoop.service已经设定了JAVA_HOME,所以Masters上的zookeeper.service,可以不需要再指定JAVA_HOME,如下:
[Unit] 
Description=zookeeper
After=network.target 

[Service] 
Type=forking
User=hadoop
Group=hadoop
#PIDFile=/opt/zookeeper/data/zookeeper_server.pid
Restart=always
RestartSec=0s
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
ExecReload=/usr/local/zookeeper/bin/zkServer.sh restart
#PrivateTmp=true 

[Install] 
WantedBy=multi-user.target


==================

master:
3184 Jps
1872 NameNode
2288 ResourceManager
2741 HMaster
2077 SecondaryNameNode
1550 QuorumPeerMain

node:
2450 DataNode
2360 QuorumPeerMain
2568 NodeManager
2747 HRegionServer
3052 Jps
systemd unit文件启动没问题。

其他问题,如果节点的zookeeper.service不指定JAVA_HOME,会启动不了,出现以下错误:
Sep 11 16:23:12 hbase-test systemd[1]: Starting hadoop...
Sep 11 16:23:12 hbase-test zkServer.sh[867]: ZooKeeper JMX enabled by default
Sep 11 16:23:12 hbase-test zkServer.sh[867]: Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Sep 11 16:23:14 hbase-test zkServer.sh[867]: Starting zookeeper ... STARTED
Sep 11 16:23:14 hbase-test systemd[1]: PID 1379 read from file /opt/zookeeper/data/zookeeper_server.pid does not exist or is a zombie.
Sep 11 16:23:14 hbase-test systemd[1]: Failed to start hadoop.
Sep 11 16:23:14 hbase-test systemd[1]: Unit zookeeper.service entered failed state.
Sep 11 16:23:14 hbase-test systemd[1]: zookeeper.service failed.

注意事项,zookeeper通过systemd启动,在jps命令下,不会出现,要使用zkServer.sh status查看,这个原因有可能是privatetmp=true造成,
zookeeper.service节点修改如下:
[Unit] 
Description=zookeeper
After=network.target 

[Service] 
Type=forking
User=hadoop
Group=hadoop
Environment=JAVA_HOME=/usr/local/lib/jdk1.8.0_144
#PIDFile=/opt/zookeeper/data/zookeeper_server.pid
Restart=always
RestartSec=0s
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
ExecReload=/usr/local/zookeeper/bin/zkServer.sh restart
#PrivateTmp=true 

[Install] 
WantedBy=multi-user.target
=======================
Master zookeeper.service修改如下:
[Unit] 
Description=zookeeper
After=network.target 

[Service] 
Type=forking
User=hadoop
Group=hadoop
#PIDFile=/opt/zookeeper/data/zookeeper_server.pid
Restart=always
RestartSec=0s
ExecStart=/usr/local/zookeeper/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop
ExecReload=/usr/local/zookeeper/bin/zkServer.sh restart
#PrivateTmp=true 

[Install] 
WantedBy=multi-user.target










阅读(4292) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~