时间:2021-07-01 10:21:17 帮助过:38人阅读
innodb的innodb_buffer_pool_size 在32机器上只能最大为2G,这样本来增加内存为了提高速度,受这个限制发挥不出来。听说想到64位
innodb的innodb_buffer_pool_size 在32机器上只能最大为2G,这样本来增加内存为了提高速度,受这个限制发挥不出来。听说想到64位的环境可以用超过2G的内存,于是就开始重新部署。
环境:
CentOS 5.3 64位
Mysql 5.1.33
安装
Centos安装没有什么特别,只是要记得下载64的系统,
MYSQL编译安装,对于安装过的人,,也是很简单,这里还是把某些过程写一下,以供参考。
安装完Centos后,就按以下步骤操作:
1.换CentOS的yum源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
wget
2.定时校正服务器时钟
yum install ntp #如果ntp已经安装可以略过
crontab -e
加入如下一行:
15 3 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
3.安装所需的程序
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
4.下载软件
mkdir -p /opt/software
wget ://mysql.he.net/
wget
5.编译安装软件
5.2编译安装mysql
以下内容存为mysql-install.sh
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.1.33.tar.gz
#sphinx安装
cd /opt/software
tar zxvf sphinx-0.9.9-rc1.tar.gz -C /opt
cd /opt/sphinx-0.9.9-rc1
cp -R /opt/sphinx-0.9.9-rc1/mysqlse /opt/mysql-5.1.33/storage/sphinx
cd /opt/mysql-5.1.33
sh BUILD/autorun.sh
cd mysql-5.1.33/
./configure --prefix=/usr/local/webserver/mysql/ --without-debug --without-bench --enable-thread-safe-client --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=latin1 --with-extra-charsets=utf8 --with-plugins=innobase --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-yicike --enable-local-infile --with-plugins=sphinx --with-plugins=all --with-unix-socket-path=/usr/local/webserver/mysql/sock/mysql.sock
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../
执行(如果不是另存为mysql-install.sh的可以忽略这一步)
chmod +x mysql-install.sh
./mysql-install.sh
5.2.1创建MySQL数据库存放目录
mkdir -p /data/mysql/data/
chown -R mysql:mysql /data/mysql/
5.2.2以mysql用户帐号的身份建立数据表
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/data/mysql/data --user=mysql
可能会失败,如果机器里以前安装了mysql,需要将原来的my.cnf名称修改为my.cnf.temp
5.2.3创建my.cnf配置文件
vim /data/mysql/my.cnf
输入以下内容
[client]
default-character-set = utf8
port = 3306
socket = /tmp/mysql.sock
[mysql]
prompt="(\u::)[\d]> "
no-auto-rehash
[mysqld]
default-character-set = utf8
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /data/mysql/data
open_files_limit = 10240
back_log = 600
max_connections = 1000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 1
log_long_format
log-bin = /data/mysql/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7
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_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
skip-name-resolve
master-connect-retry = 10
#slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
server-id = 2
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 8G #由于我的机器是16G
innodb_data_file_path = ibdata1:1024M: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
[mysqldump]
quick
max_allowed_packet = 32M