(免编译版)linux系统mysql安装配置优化手册v2.1

上传人:第*** 文档编号:30969047 上传时间:2018-02-03 格式:DOC 页数:13 大小:68.50KB
返回 下载 相关 举报
(免编译版)linux系统mysql安装配置优化手册v2.1_第1页
第1页 / 共13页
(免编译版)linux系统mysql安装配置优化手册v2.1_第2页
第2页 / 共13页
(免编译版)linux系统mysql安装配置优化手册v2.1_第3页
第3页 / 共13页
(免编译版)linux系统mysql安装配置优化手册v2.1_第4页
第4页 / 共13页
(免编译版)linux系统mysql安装配置优化手册v2.1_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《(免编译版)linux系统mysql安装配置优化手册v2.1》由会员分享,可在线阅读,更多相关《(免编译版)linux系统mysql安装配置优化手册v2.1(13页珍藏版)》请在金锄头文库上搜索。

1、(免编译版)linux 系统 mysql 安装配置优化手册 V2.1Version: 2.1Author: reedTime: 2012-05-141. 适用的安装包1.1 mysql-5.1.48-linux-x86_64-glibc23.tar.gz(64 位)1.2 安装 mysql-5.1.48 的 32 位版本请参考(编译版) linux 系统 mysql 安装配置优化手册 V2.01.3 mysql-5.0.41-linux-i686-glibc23.tar.gz(32 位)注:本次安装的 linux 系统环境为 64 位(查看版本:#uname -m) ,则 mysql 也对应要

2、 64 位。2. 建立 mysql 需要的用户和组2.1 #groupadd mysql2.2 #useradd g mysql mysql s /sbin/nologin(s /sbin/nologin 参数为设置不允许mysql 用户进行系统登录)3. 解压缩# cd /usr/local# tar -xzvf mysql-5.1.48-linux-x86_64-glibc23.tar.gz# ln -s /usr/local/mysql-5.1.48-linux-x86_64-glibc23 mysql4. 生成系统数据库#cd /usr/local/mysql# scripts/mys

3、ql_install_db -user=mysql5. 修改 mysql 目录权限# chown -R root /usr/local/mysql# chgrp -R mysql /usr/local/mysql# chown -R mysql /usr/local/mysql/data注:操作 mysql 数据库的用户是 mysql 所以要拥有数据库目录的所有权6. 修改配置文件把配置文件复制到/etc 下# cp /usr/local/mysql/support-files/my-f /etc/f注:如果你的内存64M,则复制 my-f 为/etc/f如果内存是 128M,则复制 my-f

4、 为/etc/f如果内存是 512M,则复制 my-f 为/etc/f如果内存是 1-2G,则复制 my-f 为/etc/f如果内存是 4G,则复制 my-innodb-heavy-4G.cnf 为/etc/f7. 设置 mysql 中文编码问题注:这一步在创建用户数据库之前完成,并要重启 MYSQL#vi /etc/fclient#password = your_passwordport = 3306socket = /tmp/mysql.sock#添加的内容default-character-set=gb2312mysqldport = 3306socket = /tmp/mysql.so

5、ck#添加的内容default-character-set=utf88. 设置 Mysql 执行程序的 path 环境变量#vi /etc/profile在最后处添加:PATH=$PATH:/usr/local/mysql/bin export PATH保存退出。#source /etc/profile9. 设置随系统开机启动9.1 启动 mysql,如果一切正常的话,运行此命令后,不会有错误提示#/usr/local/mysql/bin/mysqld_safe -user=mysql &注:在 Unix 和 NetWare 中推荐使用 mysqld_safe 来启动 mysqld 服务器。m

6、ysqld_safe 增加了一些安全特性,例如当出现错误时重启服务器并向错误日志文件写入运行时间信息。9.2 将 mysql.server 这个文件 copy 到/etc/init.d/目录下,并更名为 mysql#cp support-files/mysql.server /etc/init.d/mysql9.3 给/etc/init.d/mysql 这个文件赋予“执行”权限#chmod 755 /etc/init.d/mysql9.4 加入到开机自动运行,运行级别为 3 4 5#chkconfig -level 345 mysql on9.5 重启 mysql 服务#ps ef|grep

7、mysql#kill -9 id#service mysql start注:如果这里启动失败报错,类似这样的错误信息“Starting MySQL.Manager of pid-file quit without updating file.失败” ,不要担心,先看下 mysql 的日志究竟报了什么错,#vi /usr/local/mysql/data/*.err(星号表示你主机的名字) ,错误的日志如下:InnoDB: Error: data file ./ibdata1 is of a different sizeInnoDB: 640 pages (rounded down to MB)

8、InnoDB: than specified in the .cnf file 64000 pages!InnoDB: Could not open or create data files.InnoDB: If you tried to add new data files, and it failed here,InnoDB: you should now edit innodb_data_file_path in f backInnoDB: to what it was, and remove the new ibdata files InnoDB createdInnoDB: in t

9、his failed attempt. InnoDB only wrote those files full ofInnoDB: zeros, but did not yet use them in any way. But be careful: do notInnoDB: remove old data files which contain your precious data!120410 9:43:24 ERROR Plugin InnoDB init function returned error.120410 9:43:24 ERROR Plugin InnoDB registr

10、ation as a STORAGE ENGINE failed.120410 9:43:24 ERROR Unknown/unsupported table type: InnoDB120410 9:43:24 ERROR Aborting从日志看到,文件 ibdata1 跟配置文件里面设置的值不一致,无法创建或打开该文件,如果你想新增一个 datafile,同时又失败了,你应该把移除旧的datafile,然后重新启动 mysql,这样就 OK 啦。10. 修改 mysql 超级用户 root 密码# mysqladmin -u root -p password 123456 (注:此处改密

11、码为 123456 为例)Enter password: 回车就行 ,默认的密码为空11. 优化、安全设置#vi /etc/f添加以下内容(注:所设置的某些参数要根据实际进行调整):default-storage-engine=InnoDBinnodb_file_per_tableinnodb_data_file_path=ibdata1:1000M;ibdata2:1000M;ibdata3:1000M;ibdata4:1000M;ibdata5:1000M:autoextendinnodb_log_file_size = 500Minnodb_log_files_in_group = 4i

12、nnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 2innodb_buffer_pool_size = 4Ginnodb_additional_mem_pool_size = 16Mmax_connections = 65535tmp_table_size = 200Mmax_heap_table_size = 256Mquery_cache_size= 64Mquery_cache_limit = 4Mwait_timeout = 300interactive_timeout = 300thread_cache_size =

13、 64skip-external-lockingkey_buffer = 256Mmax_allowed_packet = 4Mtable_cache = 512sort_buffer_size = 6Mnet_buffer_length = 8Kread_buffer_size = 4Mread_rnd_buffer_size = 1024Kmyisam_sort_buffer_size = 64M# Try number of CPUs*2 for thread_concurrencythread_concurrency = 4local-infile = 0#以下这些系统缺省配置,跟上面

14、的配置有冲突,需要屏蔽:#key_buffer_size = 256M#max_allowed_packet = 1M#table_open_cache = 256#sort_buffer_size = 1M#read_buffer_size = 1M#read_rnd_buffer_size = 4M#myisam_sort_buffer_size = 64M#thread_cache_size = 8#query_cache_size= 16M附注解:#缺省存储引擎default-storage-engine=InnoDB#使每个 Innodb 的表,有自已独立的表空间。如删除文件后可以回

15、收那部分空间innodb_file_per_table#数据文件个数及最后一个文件自动扩充 2G 为限innodb_data_file_path=ibdata1:1000M;ibdata2:1000M;ibdata3:1000M;ibdata4:1000M;ibdata5:1000M:autoextend#日志文件大小innodb_log_file_size = 500M#指定日志组的文件个数innodb_log_files_in_group = 4#事务在内存中的缓冲。这个参数设置 InnoDB 用来往磁盘上的日志文件写操作的缓冲区的大小。这有点像 Oracle 的 log_buffer ,

16、通过内存缓冲来延缓磁盘 I/O 以提高访问的效率。 因为 MySQL 每秒都会将日志缓冲区的内容刷新到日志文件,因此无需设置超过 1 秒所需的内存空间。通常设置为 8 16MB 就足够了,默认值是 1MB。innodb_log_buffer_size = 8M#控制事务的提交方式。抱怨 Innodb 比 MyISAM 慢 100 倍?那么你大概是忘了调整这个值。默认值 1 的意思是每一次事务提交或事务外的指令都需要把日志写入(flush)硬盘,这是很费时的。特别是使用电 池供电缓存(Battery backed up cache)时。设成 2 对于很多运用,特别是从 MyISAM 表转过来的是可以的,它的意

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 工程造价

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号