Skip to content

docker-compose根据镜像去构建php的开发环境;该项目集成了php7,nginx,mariadb,redis;实现数据库的主从配置读写分离.一键构建环境😁😁

Notifications You must be signed in to change notification settings

sheldon9527/docker-compose_php7-mysql-nginx

Repository files navigation

Nginx, PHP7, MariaDB and Redis with Docker Compose based on Images

要求

Install Docker

数据库主从配置

  • 主从配置
    • 进入Master库容器 docker exec -it master-mariadb-service /bin/bash

    • 打开另一个终端进入Slave容器 docker exec -it slave-mariadb-service /bin/bash

    • 进入Master /usr/bin/mysql -uroot -p 密码是root

    • 授权 GRANT REPLICATION SLAVE ON *.* TO 'slaveUser'@'10.5.0.6' IDENTIFIED BY '123456'; IP 参数代表从容器的ip

    • flush privileges;

    • show master status;

         File    | Position  | Binlog_Do_DB| Binlog_Ignore_DB
         master-bin.000005  | 635 |
      
    • 进入Slave /usr/bin/mysql -uroot -p 密码是root

    • 连接Master

          change master to master_host='10.5.0.5',
          master_user='slaveUser',
          master_password='123456',
          master_log_file='master-bin.000005', //例子,自己根据自己系统显示修改
          master_log_pos=635; //例子,自己根据自己系统显示修改
      
    • 启动Slave start slave;

    • 查看是否开启show slave status\G;

        Slave_IO_Running: Yes //这两个为yes开启成功
        Slave_SQL_Running: Yes //这两个为yes开启成功
      
    • 测试

      • 在Master中操作

          create database test;
          CREATE TABLE `admin` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `name` varchar DEFAULT NULL COMMENT 'name',
          PRIMARY KEY (`id`));
          insert into admin values('1','name');
        

star

About

docker-compose根据镜像去构建php的开发环境;该项目集成了php7,nginx,mariadb,redis;实现数据库的主从配置读写分离.一键构建环境😁😁

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published