1、基礎環境php
IP:10.29.181.32html
# mkdir -p /opt/software/toolsjava
# ls /opt/software/toolspython
apache-ant-1.9.9-bin.tar.bz2 jdk-8u51-linux-x64.tar.gzmysql
apache-tomcat-8.0.24.tar.gz master.ziplinux
2、安裝MYSQLweb
(1)可使用yum進行安裝redis
# yum -y install mysql-serversql
# yum -y install php-mysqlshell
(2)可使用本身編寫的源碼安裝腳本進行安裝
# cd /opt/software/tools
# unzip mysql-install.zip
# cd mysql-install
# vim mysql_install.sh
更改package_dir爲你存放腳本的正確路徑
# sh mysql_install.sh
# . /etc/profile
# vim /etc/my.cnf
更改:
innodb_buffer_pool_size = 2G
# /etc/init.d/mysqld start啓動
# chkconfig mysqld on設置開機自啓
# mysqladmin -u root password '1qaz@WSX?'設置登陸mysql的用戶密碼
# mysql -uroot -p登陸驗證
> select user,host,password from mysql.user;
> delete from mysql.user where user='';刪除匿名用戶
> grant all privileges on cronhub_manage_system.* to 'cronhub'@'%' identified by '1qaz@WSX?';受權用戶能夠鏈接cronhub使用的庫
建庫建表
# cd /opt/software/tools
# unzip master.zip
# mv CronHub-master/ /usr/local/
# cd /usr/local/CronHub-master/WebRoot/download
# mysql -uroot -p < cronhub_manage_system.sql
# mysql -uroot -p
> show databases;--> cronhub_manage_system
> use cronhub_manage_system
> show tables;查看庫中生成的表,並清空這些表
3、安裝JDK
# cd /opt/software/tools/
# tar zxvf jdk-8u51-linux-x64.tar.gz
# mkdir /usr/local/java
# mv jdk1.8.0_51/ /usr/local/java/
# vim /etc/profile
添加以下內容:
#set JDK enviroment
JAVA_HOME=/usr/local/java/jdk1.8.0_51
JAVA_BIN=/usr/local/java/jdk1.8.0_51/bin
PATH=$PATH:$JAVA_BIN
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
# . /etc/profile
# java -version驗證
java version "1.8.0_51"
4、修改JAVA WEB中央服務器配置文件,打包
(1)安裝ant
# cd /opt/software/tools/
# tar xvf apache-ant-1.9.9-bin.tar.bz2 -C /usr/local/
# vim /etc/profile
添加以下內容:
#set Ant enviroment
export ANT_HOME=/usr/local/apache-ant-1.9.9
export PATH=$PATH:$ANT_HOME/bin
# . /etc/profile
(2)修改配置文件
# cd /usr/local/CronHub-master/ant
# vim 192.168.101.9.properties
包含application.properties和log4j.properties兩個文件的內容。須要更改成本身的數據庫,安裝路徑等信息。內容以下:
db.jdbcurl=jdbc\:mysql\://10.29.181.32\:3306/cronhub_manage_system?useUnicode\=true&characterEncoding\=UTF-8
db.username=cronhub
db.password=1qaz@WSX?
undoReportHttpUrl=http\://10.29.181.32\:8085/record_undo/report.action
serverRootUrl=http\://10.29.181.32\:8085
alertFromUserMail=monitor@66rpg.com
alertFromPassword=YjImayomdhk55nQq
alertHostMail=smtp.exmail.qq.com
alertDestMail={"3004947672@qq.com"\:""}
########################log4j
log4j.rootLogger=info, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.Validate=info, validate
log4j.appender.validate=org.apache.log4j.DailyRollingFileAppender
log4j.appender.validate.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/service.log
log4j.appender.validate.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.validate.layout=org.apache.log4j.PatternLayout
log4j.appender.validate.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.Error=error, err
log4j.appender.err=org.apache.log4j.DailyRollingFileAppender
log4j.appender.err.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/error.log
log4j.appender.err.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.err.layout=org.apache.log4j.PatternLayout
log4j.appender.err.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.DaemonError=error, daemonError
log4j.appender.daemonError=org.apache.log4j.DailyRollingFileAppender
log4j.appender.daemonError.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/daemonError.log
log4j.appender.daemonError.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.daemonError.layout=org.apache.log4j.PatternLayout
log4j.appender.daemonError.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.RecordUndoLogger=info, recordUndoLogger
log4j.appender.recordUndoLogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.recordUndoLogger.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/recordUndoLogger.log
log4j.appender.recordUndoLogger.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.recordUndoLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.recordUndoLogger.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.RecordDoneLogger=info, recordDoneLogger
log4j.appender.recordDoneLogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.recordDoneLogger.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/recordDoneLogger.log
log4j.appender.recordDoneLogger.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.recordDoneLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.recordDoneLogger.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %p\t| %m%n
log4j.logger.RecordDoneError=info, recordDoneError
log4j.appender.recordDoneError=org.apache.log4j.DailyRollingFileAppender
log4j.appender.recordDoneError.File=/usr/local/dispatch_system_tomcat/logs/dispatch_sys/recordDoneError.log
log4j.appender.recordDoneError.DatePattern='.'yyyy-MM-dd'.bak'
log4j.appender.recordDoneError.layout=org.apache.log4j.PatternLayout
(3)運行build.xml進行打包
# cd /usr/local/CronHub-master/ant
# ant -f build.xml
# ls /usr/local/CronHub-master/war/CronhubManageSystem_101.9.war
5、部署war包到tomcat,啓動
(1)安裝tomcat
# cd /opt/software/tools/
# tar zxvf apache-tomcat-8.0.24.tar.gz -C /usr/local/
# cd /usr/local/
# mv apache-tomcat-8.0.24/ dispatch_system_tomcat
(2)部署tomcat及啓動
必定將以前打好的war包放入webapp/ROOT/下
# rm -rf /usr/local/dispatch_system_tomcat/webapps/ROOT/*
# cp /usr/local/CronHub-master/war/CronhubManageSystem_101.9.war \
/usr/local/dispatch_system_tomcat/webapps/ROOT/
# cd /usr/local/dispatch_system_tomcat/webapps/ROOT/
# jar -xvf CronhubManageSystem_101.9.war解壓war包
# vim /usr/local/dispatch_system_tomcat/conf/server.xml
更改啓動端口8080爲8085
<Connector port="8085" protocol="HTTP/1.1"
# cd /usr/local/dispatch_system_tomcat/bin/
# sh startup.sh啓動tomcat
# ps -ef | grep tomcat檢測是否啓動
# lsof -i :8085
(3)訪問測試
在瀏覽器中輸入CronHub-01機器的外網ip及應用端口
http://101.37.21.22:8085/
(4)更改頁面logo
# cd /usr/local/dispatch_system_tomcat/webapps/ROOT/
# vim index.html
更改以下內容:
......
#top-logo {
height: 50px;
line-height: 50px;
float: left;
text-align: center;
width: 279px; /*修改成logo圖片width*/
background: url() no-repeat; /*在這裏添加logo圖片路徑*/
}
<td id="td-top">
<div id="top-logo"><big><font color=blue>橙光遊戲 * CronHub時間調度系統</font></big></div>
<div id="top-right" style="margin-right:20em;display:none">
<div><big><font color=green>運維部</font></big></div>
</div>
......
在瀏覽器中輸入CronHub-01機器的外網ip及應用端口
http://101.37.21.22:8085/
6、安裝daemon
拷貝daemon端安裝腳本/usr/local/CronHub-master/WebRoot/download下的
install_start.sh。默認狀況下這個腳本只支持安裝centos客戶端,通過更改可
以支持ubuntu客戶端
# cp install_start.sh /home/scripts/拷貝到/home/scripts/下
對於除本機外的客戶端(10.26.200.227)可使用以下命令進行:
ansible分發cronhub客戶端程序
# ansible 10.26.200.227 -m copy -a 'src=/home/scripts/install_start.sh dest=/home/scripts/install_start.sh mode=644 owner=root'
# ansible 10.26.200.227 -m shell -a "bash /home/scripts/install_start.sh -d /usr/local/daemon -s 2017 -i 10.29.181.32 -p 8085"
註釋:
# bash /home/scripts/install_start.sh -d /usr/local/daemon -s 2017 -i 10.29.181.32 -p 8085
-d 安裝daemon客戶端的路徑
-s 本地啓動的端口,用於與服務的通訊
-i 服務端的ip地址
-p 服務端的端口,用於下載安裝包
# ps -ef | grep jsvc
執行完腳本就會啓動,啓動後在控制檯上查看進程會發現2個jsvc進程
安裝daemon腳本會對centos加入chkconfig到linux系統啓動項;對ununtu
會在/etc/rc.local中添加開機啓動項。
7、配置、添加計劃任務
(1)增長daemon執行器
查看狀態
(2)添加新任務
添加任務的具體內容:
如下是添加 天天凌晨2點重啓SVN程序的計劃任務
檢測添加的計劃任務
(3)執行結果查詢
8、批量添加
(1)批量添加daemon執行器
# cd /home/scripts/CronHub
# vim info.txt
填入信息以下:
10.27.13.71feed-redis-slave-02
10.26.234.157passport-redis-slave
10.47.134.28rc-rcc-redis-slave-01
# python insert_info.py執行python腳本進行批量添加
(2)批量添加調度任務
# cd /home/scripts/CronHub
# vim list.conf
填入信息以下:
passport-redis-slave redis
chengguang-web-03 web
# python insert_cron.py執行python腳本進行批量添加