1、首先安装mysql数据库
图省事,使用宝塔安装(建议不要这样安装)
wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --db_option 2 --dbinstallmethod 1 --dbrootpwd 123456 --pureftpd --redis --memcached --reboot
安装后初始化
mysql_secure_installation
进入mysql数据库
mysql -u root -p123456
create database rundeck character set utf8 collate utf8_bin;
grant ALL on rundeck.* to 'rundeckuser'@'10.0.0.9' identified by 'rundeckpassword';
mysql -u root -p
2、添加jar包到rundeck的lib目录下,如果是yum或者rpm安装记得手动创建下lib目录,此处记得mysql版本要与mysql-connect-java要一致,查看mysql版本mysql -V
https://blog.csdn.net/bobozai86/article/details/103244103
下图是踩过的坑(配置mysql为rundeck数据库的前提)
https://docs.rundeck.com/docs/administration/configuration/database/
3、配置rundeck配置文件使其连接数据库
vim /etc/rundeck/rundeck-config.properties
grails.serverURL=http://10.0.0.9:4440
dataSource.dbCreate = update
#dataSource.url = jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true
dataSource.url = jdbc:mysql://10.0.0.9:3306/rundeck?autoReconnect=true&useSSL=false
dataSource.username=rundeckuser
dataSource.password=rundeckpassword
dataSource.driverClassName=com.mysql.jdbc.Driver
查看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
重启生效,需要同时修改这两个参数
正常运行无报错
mysql权限问题报错
Caused by: java.sql.SQLException: null, message from server: “Host ‘10.0.0.9’ is not allowed to connect to this MySQL server”
解决方案:
mysql -uroot -p123456
grant ALL on rundeck.* to ‘rundeckuser’@‘10.0.0.9’ identified by ‘rundeckpassword’;
flush privileges;
连接不上数据库:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up
解决方案:
把下面这个包放到 /var/lib/rundeck/lib目录下,记得不可用和数据库版本不匹配的的,版本不匹配会报错
各个版本的mysql-connect-java下载
https://mvnrepository.com/artifact/mysql/mysql-connector-java/
官网显示所需操作未配置