rundeck入门

This is about rundeck

Posted by PsycheLee on 2015-09-08

rundeck入门

调度工具

  • crontab
  • azkaban
  • rundeck
  • xxl_job

部署

jdk1.8

下载上传到linux

将war包压缩后上传到linux

运行

启动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
新建文件夹rundeck
[bigdata@hadoop001 app]$ ll
total 8
lrwxrwxrwx 1 bigdata bigdata 23 Nov 28 10:28 hadoop -> hadoop-2.6.0-cdh5.16.2/
drwxr-xr-x 18 bigdata bigdata 4096 Nov 28 13:30 hadoop-2.6.0-cdh5.16.2
drwxrwxr-x 2 bigdata bigdata 4096 Nov 29 16:20 rundeck
[bigdata@hadoop001 rundeck]$ ll
total 171112
-rw-r--r-- 1 bigdata bigdata 175217944 Nov 29 14:00 rundeck-3.3.6-20201111.war
#后台运行启动
[bigdata@hadoop001 rundeck]$ nohup java -jar rundeck-3.3.6-20201111.war &
[1] 16764
[bigdata@hadoop001 rundeck]$ nohup: ignoring input and appending output to ‘nohup.out’

[bigdata@hadoop001 rundeck]$ tail -F nohup.out
[2020-11-29T16:23:06,145] INFO rundeckapp.Application - The following profiles are active: production

Configuring Spring Security Core ...
... finished configuring Spring Security Core

[2020-11-29T16:23:29,480] INFO rundeckapp.BootStrap - Starting Rundeck 3.3.6-20201111 (2020-11-12) ...
[2020-11-29T16:23:29,481] INFO rundeckapp.BootStrap - using rdeck.base config property: /home/bigdata/app/rundeck
[2020-11-29T16:23:29,482] INFO rundeckapp.BootStrap - Performing rundeck first-run initialization...
[2020-11-29T16:23:29,539] INFO rundeckapp.BootStrap - Rundeck initialization complete.
[2020-11-29T16:23:29,554] INFO rundeckapp.BootStrap - loaded configuration: /home/bigdata/app/rundeck/etc/framework.properties
[2020-11-29T16:23:29,595] INFO rundeckapp.BootStrap - RSS feeds disabled
[2020-11-29T16:23:29,595] INFO rundeckapp.BootStrap - Using builtin realm authentication
[2020-11-29T16:23:29,595] INFO rundeckapp.BootStrap - Preauthentication is disabled
[2020-11-29T16:23:29,658] INFO rundeckapp.BootStrap - Rundeck is ACTIVE: executions can be run.
[2020-11-29T16:23:29,943] WARN rundeckapp.BootStrap - [Development Mode] Usage of H2 database is recommended only for development and testing
[2020-11-29T16:23:30,144] INFO rundeckapp.BootStrap - workflowConfigFix973: applying...
[2020-11-29T16:23:30,152] INFO rundeckapp.BootStrap - workflowConfigFix973: No fix was needed. Storing fix application state.
[2020-11-29T16:23:30,413] INFO rundeckapp.BootStrap - Rundeck startup finished in 1011ms
[2020-11-29T16:23:30,551] INFO rundeckapp.Application - Started Application in 26.772 seconds (JVM running for 29.475)
Grails application running at http://hadoop001:4440 in environment: production

web界面: http://106.14.23.129:4440

​ 安全组4440端口在云主机控制台配置

默认账号密码:admin

windows配置hosts文件

​ C:\Windows\System32\drivers\etc

​ 106.14.23.129 hadoop001

配置后访问http://hadoop001:4440

创建project和job

  • 创建project 输入name即可

1

  • 准备shell脚本

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [bigdata@hadoop001 rundeck]$ vi date.sh
    #!/bin/bash

    date

    赋权
    [bigdata@hadoop001 rundeck]$ chmod +x date.sh
    [bigdata@hadoop001 rundeck]$ ll
    total 171148
    -rwxrwxr-x 1 bigdata bigdata 18 Nov 29 16:37 date.sh
    [bigdata@hadoop001 rundeck]$ ./date.sh
    Sun Nov 29 16:38:55 CST 2020
  • 创建job

  • create a new job

2

  • 填写名称

    3

  • 填写workflow

    4

  • 添加step5

  • 填写路径

    6

  • 填写crontab 包含秒

    7

  • 执行job 查看结果

    8

关闭

​ ps -ef | grep rundeck 找到pid

​ kill -9 pid

邮箱设置

1606641558729

开启下面的服务

1606641623059

生成授权码

1606641720991

muciyrwfnnpcbcif

安装postfix服务

1
2
3
4
5
[root@hadoop001 ~]# service sendmail status
Redirecting to /bin/systemctl status sendmail.service
Unit sendmail.service could not be found.
[root@hadoop001 ~]# yum install -y postfix
[root@hadoop001 ~]# yum install -y mailx

启动

1
2
3
4
5
6
7
8
9
10
11
[root@hadoop001 ~]# service postfix restart
Redirecting to /bin/systemctl restart postfix.service
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
###报错, 定位错误
[root@hadoop001 ~]# which postfix
/usr/sbin/postfix
[root@hadoop001 ~]# postfix check
postfix: fatal: parameter inet_interfaces: no local interface found for ::1
###可能会报其他错误mysql相关的如果卸载过MySQLclient
解决:rpm -qa|grep mysql
yum install mysql-libs

修改配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@hadoop001 ~]# vi /etc/postfix/main.cf 
发现配置为:

inet_interfaces = localhost
inet_protocols = all
改成:
inet_interfaces = all
inet_protocols = all

[root@hadoop001 ~]# service postfix start
Redirecting to /bin/systemctl start postfix.service
[root@hadoop001 ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2020-11-29 17:33:54 CST; 55s ago
Process: 31136 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
Process: 31133 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 31129 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
Main PID: 31208 (master)
CGroup: /system.slice/postfix.service
├─31208 /usr/libexec/postfix/master -w
├─31209 pickup -l -t unix -u
└─31210 qmgr -l -t unix -u

创建认证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@hadoop001 ~]# mkdir -p /root/.certs/
[root@hadoop001 ~]# echo -n|openssl s_client -connect smtp.qq.com:465| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt


depth=2 C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
verify return:1
depth=1 C = BE, O = GlobalSign nv-sa, CN = GlobalSign Organization Validation CA - SHA256 - G2
verify return:1
depth=0 C = CN, ST = guangdong, L = shenzhen, O = Shenzhen Tencent Computer Systems Company Limited, CN = *.mail.qq.com
verify return:1
DONE
[root@hadoop001 ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@hadoop001 ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@hadoop001 ~]# certutil -L -d /root/.certs

Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI

GeoTrust SSL CA C,,
[root@hadoop001 ~]#

[root@hadoop001 ~]# cd /root/.certs/
[root@hadoop001 .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt

Notice: Trust flag u is set automatically if the private key is present.
[root@hadoop001 .certs]#

echo -n|openssl s_client -connect smtp.qq.com:465| sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > ~/.certs/qq.crt

certutil -A -n “GeoTrust SSL CA - G3” -t “Pu,Pu,Pu” -d ./ -i qq.crt

编辑mail.rc配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@hadoop001 ~]# vi /etc/mail.rc 
在文件末尾添加

#QQ
set from=549501669@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=549501669
#授权码
set smtp-auth-password=ufgqsunndyqdbfdi
set smtp-auth=login
set smtp-use-starttls
set ssl-verify=ignore
set nss-config-dir=/root/.certs

测试

1
2
3
4
5

[root@hadoop001 ~]# echo hello world |mail -s "title" 549501669@qq.com
[root@hadoop001 ~]# could not connect: Network is unreachable
"/root/dead.letter" 11/299
. . . message not sent.

阿里云25解封

16066616427871606661712449

1606661787950

申请解封失败, 使用京东云, 一次性成功

  • 发邮件不带附件

    1
    2
    3
    4
    echo -e "`date "+%Y-%m-%d %H:%M:%S"` : The current running \
    $JOB_NAME job num is $RUNNINGNUM in 106.14.23.129 ..." | mail \
    -r "From : alertAdmin<549501669@qq.com>"\
    -s "Warn: Skip the new $JOB_NAME spark job." ${EMAIL}
  • 发邮件带附件

    1
    2
    3
    4
    5
    echo -e "`date "+%Y-%m-%d %H:%M:%S"` :Check the attachment"\
    | mailx \
    -r "From : alertAdmin<549501669@qq.com>"\
    -a $FAILSQL_MONITOR_CURRENT/merge${CURRENT_TIME_SHORT}.log\
    -s "Critical:KSSH fail sql." ${EMAIL}

rundeck集成

脚本准备

1
2
3
4
5
6
7
8
9
10
11
12
[bigdata@hadoop001 rundeck]$ vi date.sh
#!/bin/bash

date

EMAIL=549501669@qq.com,853830320@qq.com

echo -e "`date "+%Y-%m-%d %H:%M:%S"` :Check the attachment"\
| mailx \
-r "From: alertAdmin<549501669@qq.com>"\
-a test.log\
-s "Critical:KSSH fail sql." ${EMAIL}