centos下tomcat+mysql的配置和项目部署_MySQL
CentOSTomcat
TOMCAT服务器的配置
1. jre的安装
1.1 查看centos中原来自带的JDK并卸载
[root@balakids home]# java -version|grep gcj [root@balakids home]# yum -y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
1.2 复制jre-6u38-linux-x64-rpm.bin到目录/opt中
cp /home/jre-6u38-linux-x64-rpm.bin /opt/.
1.3 为该文件赋予执行权限
chmod +x /opt/jre-6u38-linux-x64-rpm.bin
1.4 执行此文件即安装jre
[root@balakids jre]# ./jre-6u38-linux-x64-rpm.bin Unpacking... Checksumming... Extracting... UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu). inflating: jre-6u38-linux-amd64.rpm Preparing... ########################################### [100%] 1:jre ########################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... localedata.jar... plugin.jar... javaws.jar... deploy.jar... Done.
1.5 查看java版本
[root@balakids jre]# java -versionjava version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
2 tomcat的配置
2.1 解压tomcat的压缩包并移动到想要放置的位置
[root@balakids home]# tar -xvf apache-tomcat-6.0.39.tar.gz [root@balakids home]# mv apache-tomcat-6.0.39 /usr/local/tomcat
2.2 复制tomcat的启动脚本
[root@balakids conf]# cd /usr/local/tomcat/bin [root@balakids bin]# cp catalina.sh /etc/init.d/tomcatd[root@balakids bin]# chmod +x /etc/init.d/tomcatd
2.3 更改tomcat的启动脚本,指向JRE和TOMCAT的目录
[root@balakids ROOT]# rpm -ql jre //查询JRE安装的位置[root@balakids conf]# vim /etc/init.d/tomcatd JRE_HOME=/usr/java/jre1.6.0_38 CATALINA_HOME=/usr/local/tomcat
2.4 为tomcat配置用户管理 //可有可无的操作
[root@balakids conf]# vim /usr/local/tomcat/conf/tomcat-users.xml <tomcat-users> <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui"/> </tomcat-users> [root@balakids conf]# /etc/init.d/tomcatd start
2.5 测试 在浏览器中使用IP进行测试,本机IP:10.10.54.178,端口号为8080
刚才所配置的用户管理则是访问这个页面中的选项时使用,如下访问status时弹出来的用户登录
3 安装mysql5.1.50 3.1 安装所需依赖包
//之前先做了yum源
[root@balakids mysql-5.1.50]#yum install gcc-c++ gcc libtermcap-devel.x86_64 -y
3.2 mysql的解压、编译、安装
[root@balakids home]# tar xvf mysql-5.1.50.tar.gz[root@balakids home]# cd mysql-5.1.50 [root@balakids mysql-5.1.50]#./configure --prefix=/usr/local/mysql --datadir=/data/mysql --with-charset=utf8 /--with-extra-charsets=complex / --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock / --with-pthread --enable-assembler --with-mysqld-ldflags=-all-static / --with-client-ldflags=-all-static / --with-plugins=partition,archive,csv,federated,heap,innobase,myisam,myisammrg,innodb_plugin,ndbcluster / --with-mysqld-user=mysql[root@balakids mysql-5.1.50]# make && make install
3.3 创建mysql用户并更改目录所属用户
[root@balakids mysql-5.1.50]# useradd mysql -s /sbin/nologin [root@balakids mysql-5.1.50]# chown mysql.mysql /usr/local/mysql/ -R [root@balakids mysql-5.1.50]# chown mysql.mysql /data/ -R
3.4 复制配置文件和启动脚本 --在解压缩的包中复制
[root@balakids mysql-5.1.50]# cp support-files/my-large.cnf /etc/my.cnf [root@balakids mysql-5.1.50]# cp support-files/mysql.server /etc/init.d/mysqld [root@balakids mysql-5.1.50]# chmod +x /etc/init.d/mysqld //更改配置文件,加入datadir的目录 Vim /etc/my.cnf [mysqld]datadir=/data/mysql
3.4 初始化数据库
[root@balakids mysql-5.1.50]# /usr/local/mysql/bin/mysql_install_db --user=mysql
如果再初始化的时候指定basedir的目录则会报以下错误: FATAL ERROR: Could not find errmsg.sys
3.5 添加环境变量
[root@balakids mysql-5.1.50]# vim /etc/profile.d/mysql.sh PATH=$PATH:/usr/local/mysql/bin [root@balakids mysql-5.1.50]# source /etc/profile.d/mysql.sh
4 balakids项目部署,本机IP:10.10.54.178
把项目复制到tomcat下的webapps下
4.1 对mysql数据库的更改 Balakids项目登录数据库用户为root,密码为mysql,即依此更改数据库
[root@balakids lib]# mysqladmin -uroot -p123456 password 'mysql' mysql> update user set host='10.10.54.178' where host='localhost';
//当然可以自己重新创建用户,但是要注意的时不要忘了对项目中的一些文件进行更改,下面介绍项目中所要配置的内容 4.2 tomcat配置文件的更改 更改tomcat的配置文件
[root@balakids tomcat]# vim /usr/local/tomcat/conf/server.xml
<Engine name="Catalina" defaultHost="10.10.54.178"><Host name="10.10.54.178" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
//上面配置文件中的defaultHost默认为localhost,更改为本机IP
4.3 项目中需注意的文件 项目中最值得注意的文件莫过于对数据库的连接了也就时context.xml
绝对路径: /usr/local/tomcat/webapps/balakids/META-INF/context.xml
其内容为:
<?xml version="1.0" encoding="UTF-8"?><!-- 配置数据源 --> <Context path="/balakids" reloadable="true"> <Resource name="balakids/jdbc" auth="Container" type="javax.sql.DataSource" username="root" //用户名 password="mysql" //密码 driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://10.10.54.178:3306/balakids" //连接数据库 maxActive="8" maxIdle="4"/><!-- 测试JNDI --> <Environment name="onlineexam_jndi" value="Hello JNDI" type="java.lang.String"/></Context>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.
