mysql5.6升级为mysql5.7部署jboss/wildfly应用项目
一、部署mysql5.7二进制版
解压tar -xvf
mv mysql-5.7 /usr/local/mysql5.7 或者其他文件夹
cd /usr/local/mysql.57
useradd -s /sbin/nologin -m mysql
mkdir -p /usr/local/mysql5.7/etc
启动初始化数据
bin/mysqld --initialize --basedir=/usr/local/mysql5.7 --datadir=/usr/local/mysql5.7/data
修改配置文件
chown –r mysql:mysql /usr/local/mysql5.7
vim /usr/local/mysql5.7/etc/my.cnf
详见文件my.cnf
制作systemd启动mysql服务
vim /lib/systemd/system/mysqld.service ,详见文件
启动服务
systemctl start mysqld
systemctl enable mysqld
更改环境变量
vim /etc/profile
export path=$path:/usr/local/mysql5.7/bin
source /etc/profile
进入mysql,第一次登录mysql,没有root密码,解决方式:
在/usr/local/mysql5.7/etc/my.cnf 中添加 skip-grant-tables 参数。此参数的作用是登录mysql 数据库不进行用户密码验证。
[mysqld]
skip-grant-tables
保存my.cnf 后,重启msyql
systemctl restart mysqld
然后登录 mysql -uroot
执行以下语句:
update mysql.user set authentication_string=password('密码') where user='root';
flush privileges;
exit;
systemctl restart mysqld
mysql -uroot -p
enter password:在这里输入刚才设置的密码,如果不成功或者提示密码过期需要修改密码,重新登录mysql
use mysql;
update user set password_expired='n' where user='root';
flush privileges;
重新登录,成功。
在my.cnf文件中的skip-grant-tables注释掉,systemctl restart mysqld
二、导入mysql5.6数据
创建授权账户grant all on *.* to '***'@'%' identified by '***';
flush privileges;
create database *** default character set utf8;
在导入sql数据时,会出现有的函数及过程不能导入的情况,在my.cnf文件的mysqld段加入log_bin_trust_function_creators=1,重启mysql导入成功。成功后注释掉该行。
对于外键限制,先行取消限制,导入后在开启限制
set foreign_key_checks=0;
执行sql导入或者用navigat导入,成功后执行set foreign_key_checks=1
三、jboss/wildfly应用项目部署
1、 部署jboss/wildfly
解压,tar xvf ; mv /usr/local/jboss/wildfly
设置路径 vim /etc/profile,加 export
wildfly_home=/usr/local/wildfly;export path=$path:$wildfly_home/bin
source /etc/profile
2、更改配置
修改/usr/local/wildfly/standalone/configuration/standalone.xml
<interface name="management">
<inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
更改默认端口,由8080改为80,也可以改为其他
<socket-binding name="http" port="${jboss.http.port:80}"/>
启动服务:standalone.sh,
3、配置数据源
由console管理wildfly添加数据源,提示add-user.sh,添加用户admin
登陆 本机ip:9990
添加driver:
step 1:下载好mysql-connector-java-5.1.47.jar
step 2: 登陆 本机ip:9990 选择 runtime/manage deployments/add mysql-connector,名称为mysql,runname为mysql,然后save,再enable
step 3: 选 configuration/connctor/datasources , 增加jndi数据源
name: ***,jndi name: java:jboss/datasources/***, driver 为我们刚才导入的jar包的驱动:mysql_com.mysql.jdbc.driver_5_1,connection url: jdbc:mysql://ip/数据库***,其中的ip地址为部署的数据库服务器的ip,username: ***,password:***,save之后enable,同时测试是否连接成功test connection,成功即为创建成功。
4、部署应用项目
编辑standalone.xml文件,在<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">端内增加
<deployment-scanner name="项目名" path="项目所在路径" scan-enabled="true" scan-interval="5000" auto-deploy-zipped="true" auto-deploy-exploded="false" deployment-timeout="60"/>
在“项目所在的路径“目录下mkdir 项目名.war,touch 项目名.dodeploy ,把项目所有文件放入项目名.war目录下。
5.重新启动jboss/wildfly
standalone.sh
四、错误及故障处理
1、error [stderr] (xnio-1 task-4) wed jan 09 15:19:57 cst 2019 warn: establishing ssl connection without server's identity verification is not recommended. according to mysql 5.5.45+, 5.6.26+ and 5.7.6+ requirements ssl connection must be established by default if explicit option isn't set. for compliance with existing applications not using ssl the verifyservercertificate property is set to 'false'. you need either to explicitly disable ssl by setting usessl=false, or set usessl=true and provide truststore for server certificate verification.
排除:在standalone.xml文件中修改
<connection-url>jdbc:mysql://ip地址/数据库名?usessl=true</connection-url> 添加?usessl=true
错误排除
2、启动jboss出现
address "0.0.0.0" is a wildcard address, which will not match against any specific address. do not use the 'inet-address' configuration elementto specify that an interface should use a wildcard address; use 'any-address', 'any-ipv4-address', or 'any-ipv6-address'
解决:在jboss/standalone/configuration/standlone.xml文件中改
<interface name="public">中inet-address为any-ipv4-address重启 jboss/bin/standlone.sh
3、登录应用项目,提示密码错误,无法登陆
经排查,为mysql5.6数据库升级为mysql5.7而出现的故障,需在my.cnf文件中加入sql_mode=,故障消除
4、应用项目查询特别慢问题
经排查为mysql5.6数据库升级为mysql5.7而出现的故障,需要关闭derived_merge,在mysql启动后执行
mysql -u*** -p*** -e "set global optimizer_switch='derived_merge=off';"
重新进入应用项目,查询速度恢复正常。
5、配置jboss/wildfly数据源,因数据源超时问题的解决
caused by: java.lang.runtimeexception: org.springframework.dao.recoverabledataaccessexception:
### error querying database. cause: com.mysql.cj.jdbc.exceptions.communicationsexception: the last packet successfully received from the server was 154,231 milliseconds ago. the last packet sent successfully to the server was 154,231 milliseconds ago. is longer than the server configured value of 'wait_timeout'. you should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the connector/j connection property 'autoreconnect=true' to avoid this problem.
可以更改my.cnf文件中的
wait_timeout=2147483
interactive_timeout=2147483
将两个值改大,也不能改的太大。
重启mysql服务器,重启应用,问题解决。
上一篇: 前后双曲面柔性屏加持 努比亚Z20锦鲤红即将开卖:3699元起
下一篇: 创建型模式:抽象工厂