Chinaunix首页 | 论坛 | 博客
  • 博客访问: 409807
  • 博文数量: 43
  • 博客积分: 613
  • 博客等级: 中士
  • 技术积分: 756
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-01 11:25
文章分类

全部博文(43)

文章存档

2016年(1)

2015年(5)

2014年(5)

2013年(14)

2012年(18)

分类: Mysql/postgreSQL

2012-10-22 15:13:21

需要整理mysql主从的方案,但是又懒得多安装个虚拟机来截图什么的,就搞个单机启动多实例来操作,记录下操作步骤:
 
1、编辑一个新的 my.cnf 文件用于新的server
cp -p /etc/my.cnf /etc/my3307.cnf    ###-p是保留权限
 
   修改配置,防止和原有配置冲突。主要需要修改的有:
 
  • 端口(port)、socket 文件路径 (socket)、数据文件路径 (datadir);
  • 如果用到 InnoDB(一般都会用到),则要修改 InnoDB 数据文件路径 (innodb_data_home_dir)、InnoDB 日志文件路径 (innodb_log_group_home_dir);
  • 如果用到replication时,还要修改server的唯一id (server-id)、下载到master的binlog的存放路径 (relay-log)等。其他配置修改,则根据具体情况自行调整。

以我测试环境修改为例:

  1. less /etc/my.cnf
  2. [mysqld]
  3. datadir=/data/dbdata/
  4. skip-name-resolve
  5. #lower_case_table_names=1
  6. character-set-server = utf8
  7. event_scheduler=ON
  8. skip-name-resolve
  9. innodb_file_per_table=1
  10. log_bin_trust_function_creators=1
  11. wait_timeout=300
  12. interactive_timeout=300
  13. #federated
  14. # generic configuration options
  15. port = 3306
  16. socket = /usr/local/mysql/tmp/mysql.sock

修改my3307.cnf

  1. vi /etc/my3307.cnf
  2. [mysqld]
  3. datadir=/data/dbdata3307/
  4. skip-name-resolve
  5. #lower_case_table_names=1
  6. character-set-server = utf8
  7. event_scheduler=ON
  8. skip-name-resolve
  9. innodb_file_per_table=1
  10. log_bin_trust_function_creators=1
  11. wait_timeout=300
  12. interactive_timeout=300
  13. #federated
  14. # generic configuration options
  15. port = 3307
  16. socket = /tmp/mysql3307.sock

2、初始化DB

  1. /usr/local/mysql/bin/mysql_install_db --defaults-file=/etc/my3307.cnf
  2. chown -R mysql.mysql /data/dbdata3307


3、启动mysql


  1. mysqld_safe --defaults-file=/etc/my3307.cnf &
  2. 登陆
  3. mysql -S /tmp/mysql3307.sock
  4. mysql -S /tmp/mysql3307.sock
  5. Welcome to the MySQL monitor. Commands end with ; or \g.
  6. Your MySQL connection id is 2
  7. Server version: 5.1.50-log Source distribution
  8. Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  9. This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  10. and you are welcome to modify and redistribute it under the GPL v2 license
  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  12. root@(none) 15:12>show databases;
  13. +--------------------+
  14. | Database |
  15. +--------------------+
  16. | information_schema |
  17. | mysql |
  18. | test |
  19. +--------------------+



 

 

阅读(2605) | 评论(0) | 转发(5) |
给主人留下些什么吧!~~