[TOC]html
Rundeck是一個免費的開源軟件,用於經過計劃做業自動管理服務器(Linux,Windows和MacOS)。java
Rundeck圍繞從一臺管理服務器管理計算機網絡中全部服務器的想法而構建。Rundeck提供了用於執行這些管理任務的Web界面。mysql
Rundeck用Java編程語言編寫,並根據Apache Software 2.0許可發行。linux
Rundeck提供企業版(商業)和社區版(免費)。與Rundeck社區版相比,Rundeck Enterprise提供的功能更多,但須要付費使用。web
Rundeck的核心功能是:spring
使用SSH工具以root用戶身份與rundeck.lianglab.cn鏈接。sql
使用dnf命令升級CentOS 8中全部已安裝的軟件包。shell
[root@mariadb ~]# hostnamectl set-hostname rundeck.lianglab.cn [root@mariadb ~]# dnf update -y Dependencies resolved. Nothing to do. Complete!
咱們的CentOS 8服務器已是最新的,所以與Linux軟件包管理器無關。數據庫
Rundeck用Java編程語言編寫,所以它須要JRE(Java運行時環境)來執行。apache
所以,咱們標準yum存儲庫中的CentOS 8上安裝OpenJDK,以下所示。
[root@mariadb ~]# dnf install -y java-1.8.0-openjdk ... Installed: java-1.8.0-openjdk-1:1.8.0.252.b09-2.el8_1.x86_64 gtk2-2.24.32-4.el8.x86_64 alsa-lib-1.1.9-4.el8.x86_64 copy-jdk-configs-3.7-1.el8.noarch fribidi-1.0.4-7.el8_1.x86_64 gdk-pixbuf2-modules-2.36.12-5.el8.x86_64 giflib-5.1.4-3.el8.x86_64 graphite2-1.3.10-10.el8.x86_64 gtk-update-icon-cache-3.22.30-4.el8.x86_64 harfbuzz-1.7.5-3.el8.x86_64 hicolor-icon-theme-0.17-2.el8.noarch jasper-libs-2.0.14-4.el8.x86_64 java-1.8.0-openjdk-headless-1:1.8.0.252.b09-2.el8_1.x86_64 javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch jbigkit-libs-2.1-14.el8.x86_64 libX11-1.6.7-1.el8.x86_64 libX11-common-1.6.7-1.el8.noarch libXau-1.0.8-13.el8.x86_64 libXcomposite-0.4.4-14.el8.x86_64 libXcursor-1.1.15-3.el8.x86_64 libXdamage-1.1.4-14.el8.x86_64 libXext-1.3.3-9.el8.x86_64 libXfixes-5.0.3-7.el8.x86_64 libXft-2.3.2-10.el8.x86_64 libXi-1.7.9-7.el8.x86_64 libXinerama-1.1.4-1.el8.x86_64 libXrandr-1.5.1-7.el8.x86_64 libXrender-0.9.10-7.el8.x86_64 pixman-0.36.0-1.el8.x86_64 ttmkfdir-3.0.9-54.el8.x86_64 tzdata-java-2019c-1.el8.noarch xorg-x11-font-utils-1:7.5-40.el8.x86_64 xorg-x11-fonts-Type1-7.5-19.el8.noarch avahi-libs-0.7-19.el8.x86_64 cups-libs-1:2.2.6-28.el8.x86_64 dejavu-fonts-common-2.35-6.el8.noarch dejavu-sans-fonts-2.35-6.el8.noarch fontconfig-2.13.1-3.el8.x86_64 fontpackages-filesystem-1.44-22.el8.noarch gdk-pixbuf2-2.36.12-5.el8.x86_64 lksctp-tools-1.0.18-3.el8.x86_64 Complete!
要驗證Java Runtime Environment的安裝,請檢查java命令的版本。
[root@rundeck ~]# java -version openjdk version "11.0.9" 2020-10-20 LTS OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
Rundeck軟件經過其正式的yum存儲庫分發。所以,咱們須要在CentOS 8服務器中添加Rundeck yum存儲庫。
Rundeck提供了一個RPM軟件包以在CentOS 8上安裝yum存儲庫。所以,咱們使用dnf命令進行安裝。
[root@rundeck ~]# dnf install -y http://repo.rundeck.org/latest.rpm Last metadata expiration check: 2:56:08 ago on Sun 27 Dec 2020 07:03:07 PM CST. latest.rpm 1.8 kB/s | 3.0 kB 00:01 Dependencies resolved. ===================================================================================================================== Package Architecture Version Repository Size ===================================================================================================================== Installing: rundeck-repo noarch 4-0 @commandline 3.0 k Transaction Summary ===================================================================================================================== Install 1 Package Total size: 3.0 k Installed size: 181 Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : rundeck-repo-4-0.noarch 1/1 Verifying : rundeck-repo-4-0.noarch 1/1 Installed products updated. Installed: rundeck-repo-4-0.noarch Complete!
爲Rundeck回購構建緩存。
[root@rundeck ~]# dnf makecache CentOS-8 - Base - mirrors.tongdun.cn 1.7 MB/s | 3.9 kB 00:00 CentOS-8 - Extras - mirrors.tongdun.cn 772 kB/s | 1.5 kB 00:00 CentOS-8 - AppStream - mirrors.tongdun.c 2.5 MB/s | 4.3 kB 00:00 MariaDB 4.4 kB/s | 2.9 kB 00:00 bintray--apache-couchdb-rpm 4.2 kB/s | 1.3 kB 00:00 Extra Packages for Enterprise Linux 8 - 3.0 MB/s | 4.7 kB 00:00 Extra Packages for Enterprise Linux 8 - 1.5 MB/s | 3.0 kB 00:00 Extra Packages for Enterprise Linux 8 - 1.8 MB/s | 3.5 kB 00:00 Rundeck - Release 1.1 kB/s | 1.3 kB 00:01 Metadata cache created. [root@rundeck ~]#
已安裝Rundeck yum存儲庫。
七
如今,咱們可使用dnf命令安裝Rundeck軟件。
[root@rundeck ~]# dnf install -y rundeck Last metadata expiration check: 0:00:53 ago on Sun 27 Dec 2020 10:00:45 PM CST. Dependencies resolved. ========================================================================= Package Arch Version Repository Size ========================================================================= Installing: rundeck noarch 3.3.7.20201208-1 rundeck-release-bintray 172 M Transaction Summary ========================================================================= Install 1 Package Total download size: 172 M Installed size: 185 M Downloading Packages: rundeck-3.3.7.20201208-1.noarch.rpm 10 MB/s | 172 MB 00:16 ------------------------------------------------------------------------- Total 10 MB/s | 172 MB 00:16 warning: /var/cache/dnf/rundeck-release-bintray-330204ab97cd1651/packages/rundeck-3.3.7.20201208-1.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID e2d1065b: NOKEY Rundeck - Release 1.7 kB/s | 3.1 kB 00:01 Importing GPG key 0xE2D1065B: Userid : "Rundeck Build (automated builds) <build@rundeck.org>" Fingerprint: 85E9 DBC7 4FCB 329E DEDA DD2E 9077 0E1B E2D1 065B From : http://rundeck.org/keys/BUILD-GPG-KEY-Rundeck.org.key Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Running scriptlet: rundeck-3.3.7.20201208-1.noarch 1/1 Preparing : 1/1 Running scriptlet: rundeck-3.3.7.20201208-1.noarch 1/1 Installing : rundeck-3.3.7.20201208-1.noarch 1/1 Running scriptlet: rundeck-3.3.7.20201208-1.noarch 1/1 Verifying : rundeck-3.3.7.20201208-1.noarch 1/1 Installed products updated. Installed: rundeck-3.3.7.20201208-1.noarch Complete!
開啓並設置自啓動rundeckd服務
[root@rundeck ~]# systemctl enable --now rundeckd.service rundeckd.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable rundeckd
查看rundeckd服務的狀態和服務監聽端口信息
[root@rundeck ~]# systemctl start rundeckd.service [root@rundeck ~]# systemctl status rundeckd.service ● rundeckd.service - SYSV: rundeckd, providing rundeckd Loaded: loaded (/etc/rc.d/init.d/rundeckd; generated) Active: active (running) since Sun 2020-12-27 22:05:33 CST; 1s ago Docs: man:systemd-sysv-generator(8) Process: 140032 ExecStart=/etc/rc.d/init.d/rundeckd start (code=exited, status=0/SUCCESS) Main PID: 140042 (runuser) Tasks: 0 (limit: 49642) Memory: 2.0M CGroup: /system.slice/rundeckd.service ‣ 140042 runuser -s /bin/bash -l rundeck -c java -Drundeck.jaaslogin=true > Dec 27 22:05:33 rundeck.lianglab.cn systemd[1]: Starting SYSV: rundeckd, providing rundeckd.> Dec 27 22:05:33 rundeck.lianglab.cn rundeckd[140032]: Starting rundeckd: [ OK ] Dec 27 22:05:33 rundeck.lianglab.cn systemd[1]: Started SYSV: rundeckd, providing rundeckd. lines 1-14/14 (END) [root@rundeck ~]# netstat -anptl | grep 4440 tcp 0 0 0.0.0.0:4440 0.0.0.0:* LISTEN 140074/java
在CentOS防火牆中容許Rundeck服務端口:4440。
[root@rundeck ~]# firewall-cmd --permanent --add-port=4440/tcp success [root@rundeck ~]# firewall-cmd --reload success
若是從另外一臺計算機訪問Rundeck Web界面,則可能會出現一些錯誤。要解決此問題,咱們須要編輯Rundeck配置文件。
[root@rundeck-01 ~]# vi /etc/rundeck/rundeck-config.properties
查找並更新grails.serverURL參數,以下所示。
修改以前 grails.serverURL=http://localhost:4440 修改以後 grails.serverURL=http://192.168.6.200:4440
從新啓動rundeckd服務以使用新配置從新加載該過程。
[root@rundeck ~]# systemctl restart rundeckd.service [root@rundeck ~]# systemctl status rundeckd.service ● rundeckd.service - SYSV: rundeckd, providing rundeckd Loaded: loaded (/etc/rc.d/init.d/rundeckd; generated) Active: active (running) since Sun 2020-12-27 22:12:07 CST; 20s ago Docs: man:systemd-sysv-generator(8) Process: 140813 ExecStop=/etc/rc.d/init.d/rundeckd stop (code=exited, status=0/SUCCESS) Process: 140848 ExecStart=/etc/rc.d/init.d/rundeckd start (code=exited, status=0/SUCCESS) Main PID: 140858 (runuser) Tasks: 0 (limit: 49642) Memory: 1.9M CGroup: /system.slice/rundeckd.service ‣ 140858 runuser -s /bin/bash -l rundeck -c java -Drundeck.jaaslogin=true > Dec 27 22:12:07 rundeck.lianglab.cn systemd[1]: Starting SYSV: rundeckd, providing rundeckd.> Dec 27 22:12:07 rundeck.lianglab.cn rundeckd[140848]: Starting rundeckd: [ OK ]
默認狀況下,Rundeck使用H2數據庫做爲其存儲庫。可是不建議在生產環境中使用H2數據庫。所以,咱們將MySQL配置爲Rundeck的數據庫後端。
【1】鏈接到MySQL數據庫服務器。若是您沒有正在運行的MySQL數據庫服務器,則須要CentOS 8.2部署MariaDB 10.5.3數據庫服務。
[root@rundeck ~]# mysql -u root -plianglab@123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 12 Server version: 10.5.8-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
【2】爲Rundeck服務器建立數據庫。
MariaDB [(none)]> create database rundeck; Query OK, 1 row affected (0.001 sec)
【3】建立數據庫用戶並授予Rundeck數據庫所需的特權。
MariaDB [(none)]> grant ALL on rundeck.* to 'rundeckuser'@'localhost' identified by 'lianglab123'; Query OK, 0 rows affected (0.001 sec)
【4】從新加載特權表。
MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.001 sec)
從MySQL Shell退出。
MariaDB [(none)]> exit Bye
【5】如今編輯Rundeck配置文件。
[root@rundeck-01 ~]# vi /etc/rundeck/rundeck-config.properties
【6】在此文件中找到並更新如下參數。(若是找不到任何參數,請在其中添加)
修改前 # change hostname here grails.serverURL=http://192.168.6.200:4440 dataSource.dbCreate = update dataSource.url = jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true 修改後 # change hostname here grails.serverURL=http://192.168.6.200:4440 dataSource.dbCreate = update #dataSource.url = jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true dataSource.url = jdbc:mysql://192.168.6.200/rundeck?autoReconnect=true dataSource.username=rundeckuser dataSource.password=lianglab123 dataSource.driverClassName=com.mysql.jdbc.Driver
【7】從新啓動rundeckd服務以應用更改。
[root@rundeck ~]# systemctl restart rundeckd.service [root@rundeck ~]# systemctl status rundeckd.service ● rundeckd.service - SYSV: rundeckd, providing rundeckd Loaded: loaded (/etc/rc.d/init.d/rundeckd; generated) Active: active (running) since Sun 2020-12-27 22:22:50 CST; 9s ago Docs: man:systemd-sysv-generator(8) Process: 141411 ExecStop=/etc/rc.d/init.d/rundeckd stop (code=exited, status=0/SUCCESS) Process: 141451 ExecStart=/etc/rc.d/init.d/rundeckd start (code=exited, status=0/SUCCESS) Main PID: 141461 (runuser) Tasks: 0 (limit: 49642) Memory: 1.9M CGroup: /system.slice/rundeckd.service ‣ 141461 runuser -s /bin/bash -l rundeck -c java -Drundeck.jaaslogin=true > Dec 27 22:22:50 rundeck.lianglab.cn systemd[1]: Starting SYSV: rundeckd, providing rundeckd.> Dec 27 22:22:50 rundeck.lianglab.cn rundeckd[141451]: Starting rundeckd: [ OK ]
【8】若是您在啓動rundeckd服務時遇到困難,則應該在/ var/log/rundeck/目錄中的Rundeck日誌文件中查找錯誤。
[2020-12-27T22:54:48,841] ERROR pool.ConnectionPool [main] - Unable to create initial connections of pool. java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@7a07c5b4;ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@7a07c5b4
配置rundeck配置文件使其鏈接數據庫 vim /etc/rundeck/rundeck-config.properties grails.serverURL=http://192.168.6.200:4440 dataSource.dbCreate = update #dataSource.url = jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true dataSource.url = jdbc:mysql://192.168.6.200:3306/rundeck?autoReconnect=true&useSSL=false dataSource.username=rundeckuser dataSource.password=lianglab123 dataSource.driverClassName=com.mysql.jdbc.Driver [root@rundeck ~]# systemctl restart rundeckd.service 查看rundeck日誌 tailf /var/log/rundeck/service.log Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解決: vim /etc/my.cnf [mysqld] wait_timeout=31536000 interactive_timeout=31536000 重啓生效,須要同時修改這兩個參數
【9】日誌查看
[root@rundeck ~]# ls -alt /var/log/rundeck/ total 3084 -rw-r--r--. 1 rundeck rundeck 1569895 Dec 27 22:23 rundeck.log -rw-rw-r--. 1 root root 1573703 Dec 27 22:23 service.log drwxrwxr-x. 2 rundeck rundeck 4096 Dec 27 22:05 . -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.executions.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.options.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.audit.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.jobs.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.cleanup.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.webhooks.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.api.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.storage.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.project.log -rw-r--r--. 1 rundeck rundeck 0 Dec 27 22:05 rundeck.access.log drwxr-xr-x. 21 root root 4096 Dec 27 22:02 ..
在諸如[Google Chrome 類的瀏覽器中瀏覽URL http://192.168.6.200:4440。
使用默認用戶名:admin和密碼:admin登陸到Rundeck Web界面。
單擊新建項目+按鈕建立一個新項目。
填寫有關項目的必要詳細信息,而後單擊建立。
咱們的項目已建立,如今位於「編輯節點」頁面。
您可能會發如今Rundeck清單中已經添加了一個節點「 Local」。這是咱們的Rundeck服務器計算機,在建立此項目時會自動添加。
本身在linux下的這個路徑:/opt/shell下新建一個shell.sh,並授執行權限,腳本內容:
[root@rundeck shell]# vi shell.sh [root@rundeck shell]# cat shell.sh #!/bin/bash date uptime [root@rundeck shell]# chmod 755 shell.sh
【1】建立咱們的任務
【2】選中一個本地URL路徑,輸入文件路徑後單擊進行保存
【3】Rundeck的定時調度
【4】咱們在ACTIVITY位置能夠查看到實時的任務運行界面:
咱們的Rundeck服務器已成功安裝和配置。有關使用Rundeck Web界面的信息,請參閱Rundeck文檔。