CentOS 6.2企业级LNMP环境搭建

准备CentOS yum源,编译环境,各种源码包
1,编译和源码包准备
gcc环境和源码包下载(所有的源码包都放在/usr/local/src目录下)

yum update
yum groupinstall -y "Development Libraries" "Development Tools"

wget
wget
wget
wget MySQL.com/get/Downloads/MySQL-5.5/mysql-5.5.22.tar.gz/from/http://mysql.he.net/
wget
wget
wget
wget
wget
wget
wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
wget
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
wget
wget

2,(1)编译安装mysql

cd /usr/local/src/
tar xf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./bootstrap
gmake
gmake install
cd ../
tar zxvf bison-2.5.tar.gz
cd bison-2.5
./configure
make
make install
cd ../
groupadd -r mysql
useradd -g mysql -M -r -s /bin/nologin mysql
mkdir -p /data/3306/mysql    
chown -R mysql. /data/3306/mysql
mkdir -p /usr/local/mysql    
tar xf mysql-5.5.22.tar.gz
cd mysql-5.5.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/3306/mysql
make && make install
cd ../

(2)配置mysql
添加mysql环境变量
vim /etc/profile 添加PATH=$PATH:/usr/local/mysql/bin并重读环境变量
source /etc/profile
添加mysql的库文件
vim /etc/ld.so.conf.d/mysql.cnf 添加/usr/local/mysql/lib这一行代码并重新加载库文件
ldconfig -v
初始化mysql,设置sv启动mysql和mysql的配置文件

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/3306/mysql/ --user=mysql
ln -sv /usr/local/mysql/include /usr/include/mysql
mkdir -p /data/3306/mysql/data/
mkdir -p /data/3306/mysql/binlog/
mkdir -p /data/3306/mysql/relaylog/
chown -R mysql:mysql /data/3306/mysql/
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start

优化mysql -->修改其配置文件内容为

# Example MySQL config file for large systems.
#
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
#
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
character-set-server = utf8
port        = 3306
socket    = /tmp/mysql.sock

[mysqld]
character-set-server = utf8
port        = 3306
socket    = /tmp/mysql.sock
user        = mysql
basedir = /usr/local/mysql
datadir = /data/3306/mysql
log-error = /data/3306/mysql/mysql_error.log
pid-file = /data/3306/mysql/mysql.pid
open_files_limit        = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /data/3306/mysql/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /data/3306/mysql/relaylog/relaylog
relay-log-info-file = /data/3306/mysql/relaylog/relaylog
relay-log = /data/3306/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover

interactive_timeout = 120
wait_timeout = 120

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

#master-host         =     192.168.1.2
#master-user         =     username
#master-password =     password
#master-port         =    3306

server-id = 1

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0

#log-slow-queries = /data/3306/mysql/slow.log
#long_query_time = 10

replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
[mysqldump]
quick
max_allowed_packet = 32M

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/cda7205e809647dcb90cad78f57207a0.html