Java popular cloud notes the project and its own independent development of spare parts visualization project basic functions Upon completion has not been deployed to a server running too, are running in the Eclipse development environment, the recently simply to learn a little Linux basics, ready to deploy it to on its own virtual machine Centos7, roughly learn about the basic process of deployment, which will need to install JDK and Tomcat, this is done more smoothly on the basis of the reference blog. But when you install MySql, basically gave up, temporarily unable to handle various error occurred during the uninstall behind the MySql, reinstall an additional reference on the basis of Bowen, the road to success some, but there are still many unknown error, so the record about , and other Linux more knowledge and then come back to see this article, deepen their understanding of the deployment of the Web project.
Installation Preparation
The installation will need to install JDK 1.8, Tomcat, and MySql (version 5.7.17 selecting successful installation)
Baidu Cloud Link
Link: https: //pan.baidu.com/s/1sg7UG9vEfnMZ5AMMIMj8WQ, extraction code: ocl4
JDK installation and configuration environment variable
(1) create java folder in the / usr directory
[root@oldboyedu usr]# mkdir java
(2) into the java folder, upload and download files JDK1.8 good.
[root@oldboyedu java]# rz
View uploaded files, found to have been uploaded successfully.
[root@oldboyedu java]# ll total 181296 -rw-r--r--. 1 root root 185646832 Jun 23 11:03 jdk-8u181-linux-x64.tar.gz
(3) extract the uploaded files in / usr / java / folder.
[root@oldboyedu java]# tar -xvf jdk-8u181-linux-x64.tar.gz
After the extraction is complete view of the current folder is shown below:
Enter jdk1.8.0_181 catalog, is to install jdk under the familiar windows file directory.
(4) After completion of decompression, editing / etc / profile set environment variables.
[root@oldboyedu jdk1.8.0_181]# vim /etc/profile
Press the key to insert into the insertion operation, add the following to the rearmost portion.
export JAVA_HOME=/usr/java/jdk1.8.0_181 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib export JAVA_HOME PATH CLASSPATH
After the addition was complete press esc. When [INSERT] disappear Press shift +:, enter wq exit.
(5) Run the following command for the changes to take effect in the profile file.
[root@oldboyedu etc]# source /etc/profile
View java version, with the same command window terminal.
At this point Java JDK installation is complete.
Tomcat installation and configuration environment variable
(1) in the / usr directory to create tomcat folder
[root@oldboyedu usr]# mkdir tomcat
(2) into the tomcat tomcat folder uploading and downloading files, still using the rz command.
[root@oldboyedu tomcat]# rz
View uploaded files uploaded successfully occur.
[root@oldboyedu tomcat]# ll total 9448 -rw-r--r--. 1 root root 9672485 Jun 23 11:00 apache-tomcat-8.5.39.tar.gz
(3) extract the uploaded files in / usr / tomcat / folder.
[to set a root @ oldboyedu tomcat] # tar xvf-tomcat apache, to 8.5 . 39 . tar gz
After the extraction is complete view of the current folder is shown below:
Into the apache-tomcat-8.5.39 folder to view the contents:
(4) After completion of decompression, editing / etc / profile set environment variables.
[root@oldboyedu tomcat]# vim /etc/profile
Add the following to the rear portion just added.
export JAVA_HOME=/usr/java/jdk1.8.0_181 export CATALINA_HOME=/usr/tomcat/apache-tomcat-8.5.39 export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib:$CATALINA_HOME/lib export JAVA_HOME PATH CLASSPATH CATALINA_HOME
添加完成后按esc键,当[INSERT]消失后按shift+:后,输入wq退出。
(5)执行如下命令让修改的profile文件生效。
[root@oldboyedu etc]# source /etc/profile
进入/usr/tomcat/bin文件夹下,启动tomcat测试。
[root@oldboyedu bin]# ./startup.sh
现在碰到坑了,启动tomcat后,在宿主机登录tomcat没有反应,后面查看如下第一篇博客发现,需要将Centos7对8080的端口进行解除,执行如下如下命令后重启tomcat,发现可以正常的访问tomcat。
[root@oldboyedu ~]# firewall-cmd --permanent --zone=public --add-port=8080/tcp success [root@oldboyedu ~]# firewall-cmd --reload success [root@oldboyedu ~]# firewall-cmd --zone=public --query-port=8080/tcp yes
安装MySQL及配置
接下来安装巨坑的MySQL,现在还有点一头雾水,由于第一次安装了一次,重新安装之前先要卸载Linux系统中已安装的Mysql
第一次安装后启动老是报如下的错,报错没有深入研究直接准备重装。
[root@oldboyedu mysqld]# /etc/init.d/mysqld start Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]
(1)清除已经安装的Mysql
首先执行如下命令查询,将所有查询的mysql相关的文件都删除。
[root@oldboyedu ~]# find /-name mysql
删除一部分的示例
[root@oldboyedu mysql]# rpm -e mysql-community-client-5.7.24-1.el6.x86_64
[root@oldboyedu mysql]# rpm -e mysql-community-devel-5.7.24-1.el6.x86_64
[root@oldboyedu mysql]# rpm -e mysql-community-libs-5.7.24-1.el6.x86_64
[root@oldboyedu ~]# find / -name mysql /etc/selinux/targeted/active/modules/100/mysql /usr/lib64/mysql /usr/share/mysql /usr/mysql [root@oldboyedu ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql [root@oldboyedu ~]# rm -rf /usr/lib64/mysql [root@oldboyedu ~]# rm -rf /usr/share/mysql [root@oldboyedu ~]# find / -name mysql /usr/mysql [root@oldboyedu ~]# cd /usr/mysql/ [root@oldboyedu mysql]# ls mysql-5.7.24-1.el6.x86_64.rpm-bundle.tar mysql-community-client-5.7.24-1.el6.x86_64.rpm mysql-community-common-5.7.24-1.el6.x86_64.rpm mysql-community-devel-5.7.24-1.el6.x86_64.rpm mysql-community-embedded-5.7.24-1.el6.x86_64.rpm mysql-community-embedded-devel-5.7.24-1.el6.x86_64.rpm mysql-community-libs-5.7.24-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.24-1.el6.x86_64.rpm mysql-community-server-5.7.24-1.el6.x86_64.rpm mysql-community-test-5.7.24-1.el6.x86_64.rpm
最后删除到只剩下安装文件即可。
(2)确认是否有安装mariadb,检查是否运行,发现有因此需要将其停止后卸载。
类似下面的命令将其删除,这里找不到以前的记录了暂时用参考博主的替代。
systemctl stop mariadb rpm -qa | grep mariadb rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64 rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64 rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
(3)上传重新下载的mysql到/usr/mysql下,并解压。
[root@oldboyedu mysql]# ls mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz [root@oldboyedu mysql]# tar -zvxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
解压成功。
[root@oldboyedu mysql]# ls mysql-5.7.17-linux-glibc2.5-x86_64 mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
(4)在/usr/local/下创建mysql目录,将刚才解压的文件全部移动到此mysql文件夹下。
[root@oldboyedu mysql]# mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
在/usr/local/mysql下查看移动后的文件。
(5)安装libaio?这个干什么用的。
[root@oldboyedu ~]# rpm -qa|grep libaio [root@oldboyedu ~]# yum -y install libaio
(6)安装配置文件my.cnf,将默认的cnf文件移动到/etc目录下并且重命名为my.cnf。
[root@oldboyedu mysql]# cp ./support-files/my-default.cnf /etc/my.cnf
可以查看默认的文件内容如下:
[root@oldboyedu support-files]# vim ./my-default.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # socket = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
重新设置的路上,也遇上了很多坑,目前按照下面的设置是OK的。
1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the 4 # *** default location during install, and will be replaced if you 5 # *** upgrade to a newer version of MySQL. 6 7 [mysqld] 8 explicit_defaults_for_timestamp=true 9 10 # Remove leading # and set to the amount of RAM for the most important data 11 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 12 innodb_buffer_pool_size = 128M 13 14 # Remove leading # to turn on a very important data integrity option: logging 15 # changes to the binary log between backups. 16 # log_bin 17 18 # These are commonly set, remove the # and set as required. 19 # 设置mysql客户端默认字符集 20 # default-character-set=utf8 21 [client] 22 socket=/var/lib/mysql/mysql.sock 23 [mysqld] 24 # 设置3306端口 25 port =3306 26 socket=/var/lib/mysql/mysql.sock 27 # 设置mysql的安装目录 28 basedir = /usr/local/mysql 29 # 设置mysql数据库的数据存放目录 30 datadir = /usr/local/mysql/data 31 # 允许最大连接数 32 max_connections=200 33 # 服务端使用的字符集默认为8bit的latin1字符集 34 character-set-server=utf8 35 # 创建新表时将使用的默认存储引擎 36 default-storage-engine=INNODB 37 # lower_case_table_name=1 38 max_allowed_packet=16M 39 # server_id = ..... 40 # socket = ..... 41 42 43 # Remove leading # to set options mainly useful for reporting servers. 44 # The server defaults are faster for transactions and fast SELECTs. 45 # Adjust sizes as needed, experiment to find the optimal values. 46 # join_buffer_size = 128M 47 # sort_buffer_size = 2M 48 # read_rnd_buffer_size = 2M 49 50 #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
按照上面的配置完成后,需要根据配置的内容,在/usr/local/mysql/ 下创建如下存放数据的文件夹。
[root@oldboyedu mysql]# mkdir ./data
修改当前local下目录mysql拥有者为 mysql 用户,默认应该是root用户。
[root@localhost mysql]# chown -R mysql:mysql ./
执行如下命令进行初始化,具体意思暂时不懂。
[root@oldboyedu ~]# ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
初始化成功,前面因为my.cnf文件的配置有点问题老是失败,按照上面的初始化后终于成功了,并产生一个初始密码,后面用这个密码登录并重新设置密码用。
(7)将mysql的bin添加到环境变量,以下是我这次设置的。
export MYSQL_HOME=/usr/local/mysql/bin export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$MYSQL_HOME export PATH
可以使用如下命令来查看环境变量,可以查看是否添加进去。
[root@oldboyedu ~]# echo $PATH
(8)启动mysql失败,输入登录密码后报错,后面想都没启动连接什么mysql,肯定报错的。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
具体不知道是什么原因,参考网上博客,在/var/lib下创建mysql文件夹,并执行如下命令。
[root@oldboyedu lib]# chmod 777 /var/lib/mysql
修改后重新启动mysql成功。
继续连接报错,说找不到/tmp/mysql.sock,查找文件在自己配置的文件下,修改/etc/my.cnf文件,将[client]添加到里面成功连接mysql
(9)成功进入mysql后,可以设置登录密码
mysql> SET PASSWORD=PASSWORD('自己的密码); Query OK, 0 rows affected, 1 warning (0.00 sec)
password:update user set authentication_string=PASSWORD('自己的密码') where User='root';
(10)设置开机启动
step1 复制启动脚本到资源目录
[root@oldboyedu mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
step2 增加mysqld服务控制脚本执行权限
[root@oldboyedu mysql]# chmod +x /etc/rc.d/init.d/mysqld
step3 将mysqld添加到系统服务
[root@oldboyedu mysql]# chkconfig --add mysqld
step4 检查mysqld服务是否生效
[root@oldboyedu mysql]# chkconfig --list mysqld
说明2,3,4,5运行级别随着系统启动而自动启动。
step5 启动mysqld
[root@oldboyedu mysql]# service mysqld start
项目war包导入、sql脚本执行
将war包导入到tomcat的webapp目录下,启动tomcat会自动解压war包。
[root@oldboyedu webapps]# rz [root@oldboyedu webapps]# ls Cloud_Note_Clyang.war manager docs PadAndFilterManager examples PadAndFilterManager.war host-manager ROOT
sql脚本执行,需要登录进入mysql后,执行如下命令,其中脚本传入到/usr/sqlscript目录下。
mysql> source /usr/sqlscript/cloud_note.sql
测试结果
在部署完成后登录测试,成功连入云笔记项目,并可以正常使用里面开发的业务。
参考博客:
(1)https://blog.csdn.net/hzr0523/article/details/80554541
(2)https://www.cnblogs.com/jieerma666/p/7527338.html
(3)https://www.cnblogs.com/YangshengQuan/p/8431520.html 参考下载mysql
(4)https://www.cnblogs.com/mujingyu/p/7689116.html 参考安装mysql
(5)https://www.cnblogs.com/taojietaoge/p/10692557.html 参考安装JDK和Tomcat
(6)https://blog.csdn.net/webnum/article/details/81257793