# Uncomment the following if you are using BDB tables #set-variable = bdb_cache_size=384M #set-variable = bdb_max_lock=100000 # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /usr/local/MySQL/var/ #innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend #innodb_log_group_home_dir = /usr/local/MySQL/var/ #innodb_log_arch_dir = /usr/local/MySQL/var/ # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #set-variable = innodb_buffer_pool_size=384M #set-variable = innodb_additional_mem_pool_size=20M # Set .._log_file_size to 25 % of buffer pool size #set-variable = innodb_log_file_size=100M #set-variable = innodb_log_buffer_size=8M #innodb_flush_log_at_trx_commit=1 #set-variable = innodb_lock_wait_timeout=50 [MySQLdump] quick set-variable = max_allowed_packet=16M [MySQL] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [isamchk] set-variable = key_buffer=256M set-variable = sort_buffer=256M set-variable = read_buffer=2M set-variable = write_buffer=2M [myisamchk] set-variable = key_buffer=256M set-variable = sort_buffer=256M set-variable = read_buffer=2M set-variable = write_buffer=2M [MySQLhotcopy] interactive-timeout ********************************************************************
配置完毕,重启主数据库,由于配置文件中加入了log-bin参数,因此开始有index产生,在/var/lib/MySQL目录下有.index档案纪录数据库的异常log。
配置Slave数据库
将192.168.1.4 master 的备份MySQL.tar.gz复制到192.168.1.5 slave上
- #cd /var/lib/
- #tar xzvf MySQL.tar.gz
- #chown –R MySQL:MySQL MySQL
配置一般在MySQL命令行下进行。
- #MySQL -h192.168.1.5 –uroot –p
- MySQL>; change master to master_log_file='ephdb05-bin.003',master_log_pos=169;
启动Slave数据库:
- MySQL>; start slave;
- MySQL>; show slave status;
查看Slave数据同步操作的依据Master_Log_File,Read_Master_Log_Pos是否与当前Master的一致。这时在/var/lib/MySQL目录会出现master.info,此档案纪录了Master MySQL server的信息。
数据库优化
采用了blob的数据类型,长时间运行会造成数据碎片,需要进行整理。
在处理数据优化前,需要关闭MySQL服务。
/usr/local/MySQL/bin/MySQLadmin shutdown
修复和整理数据库
/usr/local/MySQL/bin/myisamchk -r /usr/local/MySQL/var/hello/1_tbl
对第一个索引进行重索引
/usr/local/MySQL/bin/myisamchk -R 1 /usr/local/MySQL/var/hello/1_tbl
将索引按照倒序排序,加快检索速度
/usr/local/MySQL/bin/myisamchk -S /usr/local/MySQL/var/hello/1_tbl
对数据库关联优化
/usr/local/MySQL/bin/myisamchk -a /usr/local/MySQL/var/hello/1_tbl
(其他数据库、表的操作类似)
四、总结
Ppache+PHP+MySQL越来越多被应用于网站建设,如何才能更安全,更有效的保护好数据是系统管理员的头等大事,希望能有越来越多的好工具,好方法,好思路来协助我们做好这个工作,而且我坚信,以后的路是越走越宽的,套用老话结束这个文章------技术无极限!!
时间:2010-10-20 10:02
来源:phpchina
作者:phpchina
原文链接