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>

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
