CentOS 6.2实战部署Nginx+MySQL+PHP(2)
时间:2014-12-27 23:31 来源:linux.it.net.cn 作者:IT
#系统环境:
[root@dba01 ~]# cat /etc/RedHat-release
CentOS release 6.2 (Final)
[root@dba01 ~]# uname -a
Linux dba01 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@dba01 ~]# rz -y
rz waiting to receive.
zmodem trl+C ȡ
100% 5349 KB 2674 KB/s 00:00:02 0 Errors
100% 23727 KB 988 KB/s 00:00:24 0 Errors
[root@dba01 ~]# ll cmake-2.8.4.tar.gz mysql-5.5.19.tar.gz
-rw-r--r--. 1 root root 5477628 Sep 19 2011 cmake-2.8.4.tar.gz
-rw-r--r--. 1 root root 24296942 Dec 19 2011 mysql-5.5.19.tar.gz
#安装cmake
[root@dba01 ~]# tar -zxf cmake-2.8.4.tar.gz
[root@dba01 ~]# cd cmake-2.8.4
[root@dba01 cmake-2.8.4]# ./configure && gmake && gmake install
#安装mysql
[root@dba01 cmake-2.8.4]# cd ..
[root@dba01 ~]# groupadd mysql
[root@dba01 ~]# useradd -g mysql mysql
[root@dba01 ~]# tar -zxf mysql-5.5.19.tar.gz
[root@dba01 ~]# cd mysql-5.5.19
[root@dba01 mysql-5.5.19]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STOPAGE_ENGINE=1 -DWITH_BLACKHOLE_STOPAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP-PORT=3306
参数说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录
-DMYSQL_DATADIR=/var/mysql/data数据库存放目录
-DWITH_MYISAM_STORAGE_ENGINE=1 //安装myisam存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 //安装innodb存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 //安装archive存储引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 //安装blackhole存储引擎
-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all //安装所有扩展字符集
-DMYSQL_TCP_PORT=3306 //MySQL监听端口
-DMYSQL_USER=mysql //MySQL用户名
其他参数:
-DWITH-EMBEDDED_SERVER=1 //编译成embedded MySQL library (libmysqld.a)
-DSYSCONFDIR=/etc //MySQL配辑文件
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock //Unix socket 文件路径
-DWITH_READLINE=1 //快捷键功能
-DWITH_SSL=yes //SSL
-DWITH_MEMORY_STORAGE_ENGINE=1 //安装memory存储引擎
-DWITH_FEDERATED_STORAGE_ENGINE=1 //安装frderated存储引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 //安装数据库分区
-DINSTALL_PLUGINDIR=/usr/local/mysql/plugin //插件文件及配置路径
[root@dba01 mysql-5.5.19]# make && make install
[root@dba01 mysql-5.5.19]# chmod +w /usr/local/mysql
[root@dba01 mysql-5.5.19]# chown -R mysql:mysql /usr/local/mysql
[root@dba01 mysql-5.5.19]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/
[root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/data
[root@dba01 mysql-5.5.19]# mkdir -p /var/mysql/log
[root@dba01 mysql-5.5.19]# chown -R mysql:mysql /var/mysql/
[root@dba01 mysql-5.5.19]# cd support-files/
[root@dba01 support-files]# cp my-large.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? yes
[root@dba01 support-files]# cp mysql.server /etc/init.d/mysqld
[root@dba01 support-files]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/var/mysql/data/ --user=mysql
[root@dba01 support-files]# chmod +x /etc/init.d/mysqld
[root@dba01 support-files]# vim /etc/init.d/mysqld +46
在basedir=/usr/local/mysql (添加)
datadir=/var/mysql/data (添加)
[root@dba01 support-files]# chkconfig --add mysqld
[root@dba01 support-files]# chkconfig --level 345 mysqld on
[root@dba01 support-files]# chkconfig --list|grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@dba01 support-files]# ln -s /usr/local/mysql/bin/* /bin/
[root@dba01 support-files]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.......................... SUCCESS!
[root@dba01 support-files]# netstat -lntp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 46116/mysqld
[root@dba01 support-files]# mysqladmin -uroot password '123456'
[root@dba01 support-files]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.19-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show engines; #查看mysql存储引擎
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)
mysql> show variables like 'innodb_version'\G; #查看innodb存储引擎版本。
*************************** 1. row ***************************
Variable_name: innodb_version
Value: 1.1.8
1 row in set (0.00 sec)
mysql> show variables like 'log_error'; #查看mysql错误日志存放路径
+---------------+---------------------------+
| Variable_name | Value |
+---------------+---------------------------+
| log_error | /var/mysql/data/dba01.err |
+---------------+---------------------------+
1 row in set (0.00 sec)
mysql> system hostname; #查看mysql主机名
dba01
mysql> show create table mysql.slow_log; #查看mysql慢查询日志结构
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| slow_log | CREATE TABLE `slow_log` (
`start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`query_time` time NOT NULL,
`lock_time` time NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show variables like 'log_output'; #查看mysql慢查询的格式
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | FILE |
+---------------+-------+
1 row in set (0.00 sec)
mysql> set global log_output='TABLE';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
1 row in set (0.00 sec)
mysql> select sleep(10);
+-----------+
| sleep(10) |
+-----------+
| 0 |
+-----------+
1 row in set (10.00 sec)
mysql> \q
Bye
#安装pcre
[root@dba01 support-files]# cd
[root@dba01 ~]# tar -zxvf pcre-8.31.tar.gz && cd pcre-8.31
[root@dba01 pcre-8.31]# ./configure && make && make install
(责任编辑:IT)
#系统环境:
rz waiting to receive.
[root@dba01 pcre-8.31]# ./configure && make && make install |