hadoop systemctl 开机启动

张映 发表于 2018-12-29

分类目录: hadoop/spark/scala

标签:,

找一下官方文档,没发现有开机启动的配置。网上找了一下,基本上都是chkconfig的启动方式,用了centos7以后,chkconfig用的就少了。

1,datanode节点

[root@bigserver3 ~]# cat /usr/lib/systemd/system/hdn.service  //自启动datanode
[Unit]
Description=datanode
After=syslog.target network.target

[Service]
Type=forking
User=root
Group=root
ExecStart=/bigdata/hadoop/sbin/hadoop-daemon.sh start datanode
ExecStop=/bigdata/hadoop/sbin/hadoop-daemon.sh stop datanode
Restart=on-failure

[Install]
WantedBy=multi-user.target

[root@bigserver3 ~]# cat /usr/lib/systemd/system/hnm.service  //自启动nodemanager
[Unit]
Description=nodemanager
After=syslog.target network.target

[Service]
Type=forking
User=root
Group=root
ExecStart=/bigdata/hadoop/sbin/yarn-daemon.sh start nodemanager
ExecStop=/bigdata/hadoop/sbin/yarn-daemon.sh stop nodemanager
Restart=on-failure

[Install]
WantedBy=multi-user.target

[root@bigserver3 system]# systemctl enable hdn
Created symlink from /etc/systemd/system/multi-user.target.wants/hdn.service to /usr/lib/systemd/system/hdn.service.

[root@bigserver3 system]# systemctl enable hnm
Created symlink from /etc/systemd/system/multi-user.target.wants/hnm.service to /usr/lib/systemd/system/hnm.service.

2,master节点

[root@bigserver1 ~]# cat /usr/lib/systemd/system/hadoop.service
[Unit]
Description=hadoop
After=syslog.target network.target

[Service]
User=root
Group=root
Type=oneshot
ExecStart=/bigdata/hadoop/sbin/start-all.sh
ExecStop=/bigdata/hadoop/sbin/stop-all.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

[root@bigserver1 ~]# systemctl enable hadoop
Created symlink from /etc/systemd/system/multi-user.target.wants/hadoop.service to /usr/lib/systemd/system/hadoop.service.

[root@bigserver1 ~]# systemctl list-unit-files |grep hadoop
hadoop.service enabled

 



转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/hadoop/2021.html