Red Hat Linux 5 配置(Java&Tomcat&Mysql)

服务器环境配置:

服务器:

CPU:Intel至强双核2.40GHz
MEM:2G
DISK:100G
NET:Intel 82540EM

OS:Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Kernel:2.6.18-53.el5

JAVA:
版本:jdk 1.6
安装文件:jdk-6u5-linux-i586-rpm.bin
安装路径:默认

Tomcat:
版本:6.0.16
安装文件:apache-tomcat-6.0.16.tar.gz
安装路径:/usr/local/tomcat6/

Mysql:
版本:5.1.34 Community Server (Red Hat Enterprise Linux 5 RPM (x86))
安装文件:MySQL-server-community-5.1.34-0.rhel5.i386.rpm
安装路径:默认


安装过程:


Java
1) 使jdk-6u5-linux-i586-rpm.bin变为可执行文件
chmod a+x jdk-6u5-linux-i586-rpm.bin
2) 解压jdk-6u5-linux-i586-rpm.bin
./jdk-6u5-linux-i586-rpm.bin
3) 安装*.rpm
rpm -ivh jdk-6u5-linux-i586.rpm
4) 注意问题:
a) 配置/etc/profile文件增加环境变量(配置内容视具体情况而定)
export JAVA_HOME=/usr/java/jdk1.6.0_05
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/jre/bin

b) Red hat操作系统自带了java代码编译器(GIJ),需要使用sun jdk取代系统默认编译器。
具体操作,删除 /usr/bin/java文件,建立文件软链接 ln –s /usr/java/jdk1.6.0_05/jre/bin/java /usr/bin/java

Tomcat

1) 解压压缩包
tar -zxvf apache-tomcat-6.0.16.tar.gz
2) 移动至安装目录
mv /usr/tomcat6/apache-tomcat-6.0.16/* /usr/tomcat6
3) 修改配置文件
a) 修改默认端口
b) 修改默认http路径指向(默认页面为Tomcat的欢迎页面)
如:Host元素增加:<Context path="" docBase="at" debug="0" reloadable="true" />
4) 启动与停止
启动:/usr/local/tomcat6/bin/startup.sh 后台模式
/usr/local/tomcat6/bin/catalina.sh run 命令行模式
停止:/usr/local/tomcat6/bin/shutdown.sh

Mysql

1) 安装服务器端
Rpm –ivh MySQL-server-community-5.1.34-0.rhel5.i386.rpm MySQL-client-community-5.1.34-0.rhel5.i386.rpm
2) 安装客户端
rpm -ivh MySQL-client-community-5.1.34-0.rhel5.i386.rpm
3) 修改默认的root用户密码(默认为空)
mysqladmin -uroot password newpassword
4) 启动与停止
启动:/etc/rc.d/init.d/mysql start
停止:/etc/rc.d/init.d/mysql stop
其他参数:
[root@localhost ~]# /etc/rc.d/init.d/mysql
Usage: /etc/rc.d/init.d/mysql  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]

5) 选择配置文件
a) 查看所有的配置文件

[root@localhost mysql]# find /usr/share/mysql/ -name 'my-*' -print
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-large.cnf

b) 配置文件说明
i. my-innodb-heavy-4G.cnf
This is a MySQL example config file for systems with 4GB of memory
running mostly MySQL using InnoDB only tables and performing complex
queries with few connections.
ii. my-medium.cnf
Example MySQL config file for medium systems.
This is for a system with little memory (32M - 64M) where MySQL plays
an important part, or systems up to 128M where MySQL is used together with
other programs (such as a web server)
iii. my-huge.cnf
Example MySQL config file for very large systems.
This is for a large system with memory of 1G-2G where the system runs mainly
MySQL.
iv. my-small.cnf
Example MySQL config file for small systems.
This is for a system with little memory (<= 64M) where MySQL is only used
from time to time and it's important that the mysqld daemon
doesn't use much resources.
v. my-large.cnf
Example MySQL config file for large systems.
This is for a large system with memory = 512M where the system runs mainly
MySQL.

c) 配置文件使用
You can copy this file to /etc/my.cnf to set global options, mysql-data-dir/my.cnf to set server-specific options (in this installation this directory is /var/lib/mysql) or ~/.my.cnf to set user-specific options.
set global options 全局
set server-specific options 指定数据库服务器
set user-specific options 指定用户
一般拷贝至 /etc/my.cnf 即可(全局有效)。

6) 安装目录介绍
a) /var/lib/mysql/ 数据库文件,日志文件,mysql.sock
atapp   atest    ib_logfile0  localhost.localdomain.err  mysql             mysql-bin.000002  mysql-bin.000004  mysql.sock
atbase  ibdata1  ib_logfile1  localhost.localdomain.pid  mysql-bin.000001  mysql-bin.000003  mysql-bin.index   test

b) /usr/share/mysql/ 可选配置文件,mysql.server,语言,字符集
binary-configure   czech       fill_help_tables.sql  japanese                my-large.cnf                    mysql.server                  norwegian-ny  serbian
ChangeLog          danish      french                korean                  my-medium.cnf                   mysql_system_tables_data.sql  polish        slovak
charsets           dutch       german                mi_test_all             my-small.cnf                    mysql_system_tables.sql       portuguese    spanish
config.huge.ini    english     greek                 mi_test_all.res         mysqld_multi.server             mysql_test_data_timezone.sql  romanian      swedish
config.medium.ini  errmsg.txt  hungarian             my-huge.cnf             mysql_fix_privilege_tables.sql  ndb-config-2-node.ini         russian       ukrainian
config.small.ini   estonian    italian               my-innodb-heavy-4G.cnf  mysql-log-rotate                norwegian                     SELinux

c) /usr/bin/ mysql客户端和实用工具程序
[root@localhost mysql]# find /usr/bin/ -name 'mysql*' -print
/usr/bin/mysql_install_db
/usr/bin/mysql_fix_privilege_tables
/usr/bin/mysqlimport
/usr/bin/mysql_fix_extensions
/usr/bin/mysql_waitpid
/usr/bin/mysql_find_rows
/usr/bin/mysql_zap
/usr/bin/mysqlhotcopy
/usr/bin/mysql_setpermission
/usr/bin/mysql_upgrade
/usr/bin/mysql_secure_installation
/usr/bin/mysqld_multi
/usr/bin/mysqlslap
/usr/bin/mysqldumpslow
/usr/bin/mysqlcheck
/usr/bin/mysqltest
/usr/bin/mysqlbinlog
/usr/bin/mysqlaccess
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysqldump
/usr/bin/mysql
/usr/bin/mysql_convert_table_format
/usr/bin/mysqladmin
/usr/bin/mysqld_safe
/usr/bin/mysqlshow
/usr/bin/mysqlbug

7) 其他
a) 字符集设定
my.cnf文件 [client],[mysqld]下分别添加 default-character-set=utf8
b) 默认存储引擎设定
my.cnf文件 [mysqld]下添加 default-storage-engine=InnoDB
c) 添加公网访问用户(不限IP)
grant all privileges on *.* to yourname@"%" identified by 'yourpassword';
d) 常用命令
i. show variables; 显示mysql配置信息(修改my.cnf后使用该命令检查配置更新)
ii. show variables like '%character%'; 显示字符集信息
iii. show create table tablename; 显示建表脚本
iv. show index from tablename; 显示表索引
v. mysql.server
Usage: ./mysql.server {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]
vi. mysqladmin
ping                  Check if mysqld is alive
processlist           Show list of active threads in server
reload                Reload grant tables
refresh               Flush all tables and close and open logfiles
shutdown              Take server down
status                Gives a short status message from the server
start-slave           Start slave
stop-slave            Stop slave
variables             Prints variables available
version               Get version info from server

 

你可能感兴趣的:(java,tomcat,mysql,linux,SQL Server)