1.开机自启动tomcat
vim /etc/rc.d.rc.local
./etc/profile
/app/tomcat/bin/startup.sh
[root@web02 ~]# chmod +x /etc/rc.d/rc.local
[root@web02 ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 515 Sep 2 09:19 /etc/rc.d/rc.local
启动tomcat服务
[root@web02 /app/tools/nginx-1.16.1]# /app/tomcat/bin/startup.sh
Using CATALINA_BASE: /app/tomcat
Using CATALINA_HOME: /app/tomcat
Using CATALINA_TMPDIR: /app/tomcat/temp
Using JRE_HOME: /app/jdk
Using CLASSPATH: /app/tomcat/bin/bootstrap.jar:/app/tomcat/bin/tomcat-juli.jar
Tomcat started.
查看tomcat是否启动
[root@web02 /app/tools/nginx-1.16.1]# ps -ef |grep java
root 7925 1 84 09:37 pts/0 00:00:01 /app/jdk/bin/java -Djava.util.logging.config.file=/app/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -java.endorsed.dirs=/app/tomcat/endorsed -classpath /app/tomcat/bin/bootstrap.jar:/app/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/app/tomcat -Dcatalina.home=/app/tomcat -Djava.io.tmpdir=/app/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 7937 7797 0 09:37 pts/0 00:00:00 grep --color=auto java
把备份库压缩到~/jpress.sql.gz 文件
[root@web02 /app/tools/nginx-1.16.1]# mysqldump -uroot -p123456 -B jpress |gzip > ~/jpress.sql.gz
查看一下家目录下的文件是否存在
[root@web02 ~]# ll
total 24
-rw-------. 1 root root 1774 May 16 22:30 anaconda-ks.cfg
-rw-r--r-- 1 root root 17361 Sep 2 09:44 jpress.sql
把备份库传输到db01数据库
[root@web02 ~]# scp ~/jpress.sql 172.16.1.51:/root
The authenticity of host '172.16.1.51 (172.16.1.51)' can't be established.
ECDSA key fingerprint is SHA256:Btpe0aClmIFPkhkbOMJKk2SQRh+6YgJxzawLWDtz/GU.
ECDSA key fingerprint is MD5:27:01:76:c5:87:fe:04:48:b2:ca:85:95:97:55:04:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.1.51' (ECDSA) to the list of known hosts.
root@172.16.1.51's password:
jpress.sql 100% 17KB 4.2MB/s 00:00
把数据库服务器备份的库文件输入到数据库
[root@db01 ~]# mysql -uroot -p123456 <~/jpress.sql
```[root@db01 ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-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)]> grant all on jpress.* to jpress@'172.16.1.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on jpress.* to jpress@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> drop user ''@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for ''@'localhost'
MariaDB [(none)]>
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;+-----------+------------+
| user | host |
+-----------+------------+
| root | 127.0.0.1 |
| jpress | 172.16.1.% |
| root | 172.16.1.% |
| wordpress | 172.16.1.% |
| jpress | localhost |
| root | localhost |
+-----------+------------+
6 rows in set (0.00 sec)
MariaDB [(none)]> exit
Bye
grant all on jpress.* to jpress@'172.16.1.%' identified by '123456';
all 代表所有权限
.* 表示把 jpress所有的表授权 jpress权限
172.16.1.% 代表所有的网段可以访问
identified by '123456 设置密码为123456
查看用户表
MariaDB [(none)]> select user,host from mysql.user;+-----------+------------+
| user | host |
+-----------+------------+
| root | 127.0.0.1 |
| jpress | 172.16.1.% |
| root | 172.16.1.% |
| wordpress | 172.16.1.% |
| jpress | localhost |
| root | localhost |
+-----------+------------+
6 rows in set (0.00 sec)
查看用户表 查看授权是否成功
MariaDB [(none)]> select * from mysql.user\G;
*************************** 1. row ***************************
Host: localhost
User: root
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
修改java配置文件 数据库连接配置文件
[root@web02 /app/tomcat/webapps/jpress-web-newest/WEB-INF/classes]# ll
total 32
-rw-r--r-- 1 root root 109 Sep 19 2016 db-simple.properties
-rw-r--r-- 1 root root 5054 Sep 19 2016 ehcache.xml
drwxr-xr-x 3 root root 20 Sep 2 10:39 io
-rw-r--r-- 1 root root 206 Sep 19 2016 jpress.properties
-rw-r--r-- 1 root root 80 Sep 19 2016 language_en_US.properties
-rw-r--r-- 1 root root 85 Sep 19 2016 language.properties
-rw-r--r-- 1 root root 107 Sep 19 2016 language_zh_CN.properties
-rw-r--r-- 1 root root 561 Sep 19 2016 log4j.properties
[root@web02 /app/tomcat/webapps/jpress-web-newest/WEB-INF/classes]# cat db-simple.properties
db_host = 127.0.0.1
db_host_port = 3306
db_name = jpress
db_user = root
db_password =
db_tablePrefix = [root@web02 /app/tomcat/webapps/jpress-web-newest/WEB-INF/classes]#
[root@web02 /app/tomcat/webapps/jpress/WEB-INF/classes]# cat db.properties
#Auto create by JPress
#Fri Aug 30 12:40:26 CST 2019
db_name=jpress
db_host_port=3306
db_tablePrefix=jpress_
db_host=172.16.1.51
db_password=123456
db_user=root
效果
image.png
网友评论