CentOS java(zookeeper)项目自启动配置及注意事项
2018-01-12 13:48
871 查看
创建新服务脚本/etc/init.d/zookeeper内容如下
注意source /etc/profile
由于java项目都是有java虚拟机启动起来的,如果java程序不在系统目录下,则会因为找不到java导致项目无法启动。CentOS的服务程序需要显式加载环境变量,通常都配置在/etc/profile文件内。
当前的/etc/profile中有如下配置
添加到系统服务,做到开机自启动
[root@localhost init.d]# chkconfig --add zookeeper
[root@localhost init.d]# chkconfig zookeeper on
[root@localhost init.d]# chkconfig
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
myservice 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
zookeeper 0:off 1:off 2:on 3:on 4:on 5:on 6:off
可以看到zookeeper已经成功添加到系统服务。
#! /bin/bash # chkconfig: 2345 20 80 # description: zookeeper # rc=0 source /etc/profile case "$1" in start) cd /usr/local/zookeeper-3.4.6/ sh /usr/local/zookeeper-3.4.6/bin/zkServer.sh start ;; stop) cd /usr/local/zookeeper-3.4.6 sh /usr/local/zookeeper-3.4.6/bin/zkServer.sh stop ;; status) ps aux | grep zookeeper ;; restart|reload|force-reload) cd "$CWD" $0 stop $0 start rc=$? ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" exit 2 esac exit $rc
注意source /etc/profile
由于java项目都是有java虚拟机启动起来的,如果java程序不在系统目录下,则会因为找不到java导致项目无法启动。CentOS的服务程序需要显式加载环境变量,通常都配置在/etc/profile文件内。
当前的/etc/profile中有如下配置
export JAVA_HOME=/usr/local/jdk1.8.0_101 export PATH=$PATH:$JAVA_HOME/bin
添加到系统服务,做到开机自启动
[root@localhost init.d]# chkconfig --add zookeeper
[root@localhost init.d]# chkconfig zookeeper on
[root@localhost init.d]# chkconfig
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
myservice 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
zookeeper 0:off 1:off 2:on 3:on 4:on 5:on 6:off
可以看到zookeeper已经成功添加到系统服务。
相关文章推荐
- Java spring项目配置注意事项
- Java-SpringMVC 项目配置注意事项
- eclipse javaee版发布web项目的设置注意事项
- 配置Hbase Zookeeper 注意事项 配置hbase.zookeeper.quorum property.
- java 项目中 oracle in 使用的注意事项
- 配置Apache Kafka的zookeeper配置文件zookeeper.properties时的一个注意事项
- IReport配置及javabean注意事项
- Java Web项目从Windows移植到Linux注意事项
- centos中安装并配置Java EE开发环境(可以开发java项目和web项目的环境)
- 在centos配置mdcp注意事项
- Java-jdk环境变量配置注意事项
- Java读取Properties配置文件几点注意事项
- 将一个完整的java web 项目中的部分模块做成Webservice服务注意事项
- Hadoop之——CentOS配置ssh无密码登录注意事项
- centos中配置NFS注意事项
- 详解java环境的安装注意事项和环境变量的配置
- Hadoop+Hbase+ZooKeeper 安装配置及需要注意的事项
- 原创:Java基础,参数配置,注意事项! jdk1.5+jsp+mysql+tomcat的配置
- Linux 环境zookeeper HA配置注意事项
- Hadoop+Hbase+ZooKeeper 安装配置及需要注意的事项