1,调整最大文件数限制
ulimit -n
1024 #这个是默认值
echo ulimit -n 65535 >>/etc/profile
source /etc/profile #加载修改后的profile
ulimit -n #显示65535,修改完毕!
2,修改IO调度器设置
[root@mysql support-files]# cat /sys/block/sda/queue/scheduler
noop anticipatory [deadline] cfq #采用deadline的io调度器,重启后失效
title CentOS (2.6.32-220.el6.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=5b4002c7-52b5-4749-8d87-ac61bacd0c8d rd_NO_LUKS rd_NO_LVM LANG=en_US
.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 elevator=deadline numa=off rhgb crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_
DM
initrd /boot/initramfs-2.6.32-220.el6.x86_64.img #修改IO调度器和关闭numa,修改内核启动参数
3,修改swappiness设置
vi /etc/sysctl.conf
vm.swappiness = 0
sysctl -p
4,磁盘分区及文件类型
/ 根分区采用ext4
/opt 采用xfs
6,手工安装gcc
rpm -ivh gcc-4.4.6-3.el6.x86_64.rpm cloog-ppl-0.15.7-1.2.el6.x86_64.rpm cpp-4.4.6-3.el6.x86_64.rpm glibc-devel-2.12-1.47.el6.x86_64.rpm \
libgomp-4.4.6-3.el6.x86_64.rpm mpfr-2.4.1-6.el6.x86_64.rpm ppl-0.10.2-11.el6.x86_64.rpm glibc-headers-2.12-1.47.el6.x86_64.rpm kernel-headers-2.6.32-220.el6.x86_64.rpm
手工安装gcc-c++
rpm -ivh gcc-c++-4.4.6-3.el6.x86_64.rpm libstdc++-devel-4.4.6-3.el6.x86_64.rpm
7,开始安装
chown -R mysql.mysql /opt/mysql/data
cmake的安装
./configure --prefix=/usr/local/cmake2.8.4 && make && make install
修改~/.bash_profile
PATH=$PATH:/opt/mysql/bin:/usr/local/cmake2.8.11/bin:$HOME/bin
编译mysql
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DSYSCONFDIR=/opt/mysql/etc \
-DMYSQL_DATADIR=/opt/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DEXTRA_CHARSETS=all \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1
make && make install
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
8,初始化数据库
[root@mysql mysql]# pwd
/opt/mysql
[root@mysql mysql]# vi my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@mysql mysql]# cp -r -f my.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
/opt/mysql/scripts/mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql
[root@mysql mysql]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[root@mysql mysql]# service mysqld start
Starting MySQL. SUCCESS!
[root@mysql mysql]#
[root@mysql mysql]#
#vi /etc/init.d/mysqld(编辑此文件,查找并修改以下变量内容:)
basedir=/opt/mysql
datadir=/opt/mysql/data
加入启动项:
#chkconfig --add mysqld
#chkconfig --level 345 mysqld on
#service mysqld start