一、部署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/mysq ...
一、部署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伺服器,重啟應用,問題解決。