mysql容器之间的replication配置实例详解

背景

上周公司培训了MySQL replication, 这个周末打算用所学来实践操作一下。

Master server:MySQL container mysql_master on NAS

  • NAS server IP: 192.168.1.108
  • mysql_master inner ip: 172.17.0.6

Slave server: MySQK container mysql_slave on Mac mini

  • Mac mini docker host IP: 192.168.1.139
  • mysql_slave inner ip: 172.17.0.2

准备MySQL container

准备mysql_master

创建两个目录用来存放MySQL文件

mkdir -p /mnt/md1/disk4/mysql
mkdir -p /mnt/md1/disk4/mysql-files

创建用于测试的master mysql node

[root@TNAS-2664 disk4]# docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql_master -v /mnt/md1/disk4/mysql:/var/lib/mysql -v /mnt/md1/disk4/mysql-files:/var/lib/mysql-files mysql
3bebf0e21df6d9034ce8275b14ebb1616e11f5e2678b1e084d03c087ed91a72a

查看当前NAS上运行的mysql的container ID

[root@TNAS-2664 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40db0be51460 mysql "docker-entrypoint..." 44 seconds ago Up 29 seconds 33060/tcp, 0.0.0.0:3307->3306/tcp mysql_master
db5f6a287a21 mautic/mautic "/entrypoint.sh ap..." 2 weeks ago Up 11 days 0.0.0.0:8082->80/tcp mautic
dc1eac509c70 qianliu/mediawikiwithcomposer "docker-php-entryp..." 2 weeks ago Up 11 days 0.0.0.0:8086->80/tcp sarawiki
b5c0a00f5f42 mysql "docker-entrypoint..." 2 weeks ago Up 11 days 0.0.0.0:3306->3306/tcp, 33060/tcp mysql2
911c0a8987ba qianliu/mediawikiwithcomposer "docker-php-entryp..." 2 weeks ago Up 11 days 0.0.0.0:8083->80/tcp qianliuwiki

使用docker cp命令将my.cnf复制到host机器上进行更改

docker cp 40db0be51460:/etc/mysql/my.cnf .

在my.cnf 加入以下配置

server-id = 1
 gtid-mode = ON # (replicated by GTID)
 enforce_gtid_consistency =1 #(replicated by GTID)
 log-bin = master-log
 binlog_format = mixed
 expire-logs-days = 14
 sync-binlog = 1
 log-bin-trust-function-creators= 1

 # MASTER DB #
 binlog-ignore-db = mysql,information_schema,performance_schema,sys
 auto-increment-increment = 2
 auto-increment-offset = 1

 # SLAVE DB #
 replicate-ignore-db = mysql,information_schema,performance_schema,sys
 relay_log = relay-log
 log-slave-updates = ON

将my.cnf 用docker cp 复制到mysql_master 容器中

docker cp my.cnf 40db0be51460:/etc/mysql/

进入mysql_slave,发现my.cnf因为权限文件 is ignored,这将导致刚刚写入到my.cnf的配置无法生效

[root@TNAS-2664 ~]# docker exec -it mysql_master /bin/bash
root@40db0be51460:/# mysql -uroot -p123456
mysql: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.

更改my.cnf的权限为664

root@40db0be51460:/# chmod 644 /etc/mysql/my.cnf
root@40db0be51460:/# exit

重启mysql_slave以使my.cnf生效

[root@TNAS-2664 ~]# docker restart mysql_master

9.进入mysql_master查看master status

mysql> show master status;
+-------------------+----------+--------------+-------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB  | Executed_Gtid_Set |
+-------------------+----------+--------------+-------------------------------------------------+-------------------+
| master-log.000001 | 156 | | mysql,information_schema,performance_schema,sys |  |
+-------------------+----------+--------------+-------------------------------------------------+-------------------+
1 row in set (0.00 sec)

mysql> exit

准备mysql_slave 容器

在Mac mini上创建两个目录用来存放MySQL文件

mkdir -p /Volumes/MacintoshHDD_Data/mysql_slave_db/mysql
mkdir -p /Volumes/MacintoshHDD_Data/mysql_slave_db/mysql-files

创建用于测试的mysql_slave container

/Volumes/MacintoshHDD_Data/mysql_slave_db  docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql_slave -v /Volumes/MacintoshHDD_Data/mysql_slave_db/mysql:/var/lib/mysql -v /Volumes/MacintoshHDD_Data/mysql_slave_db/mysql-files:/var/lib/mysql-files mysql

查看当前macmini上运行的mysql_slave的container ID

/Volumes/MacintoshHDD_Data/mysql_slave_db  docker ps
CONTAINER ID IMAGE  COMMAND   CREATED  STATUS  PORTS    NAMES
8623ac99e5d4 mysql  "docker-entrypoint.s…" 5 seconds ago Up 4 seconds 33060/tcp, 0.0.0.0:3307->3306/tcp mysql_slave

使用docker cp命令将my.cnf复制到host机器上进行更改

docker cp 8623ac99e5d4:/etc/mysql/my.cnf .

在my.cnf 加入以下配置

server-id   = 2
 gtid-mode   = ON
 enforce_gtid_consistency =1
 log-bin   = slave-log
 binlog_format   = mixed
 expire-logs-days  = 14
 sync-binlog   = 1
 log-bin-trust-function-creators= 1

 # MASTER DB #
 binlog-ignore-db  = mysql,information_schema,performance_schema,sys
 auto-increment-increment = 2
 auto-increment-offset  = 2

 # SLAVE DB #
 replicate-ignore-db  = mysql,information_schema,performance_schema,sys
 relay_log   = relay-log
 log-slave-updates  = ON

将my.cnf 用docker cp 复制到mysql_master 容器中

docker cp my.cnf 8623ac99e5d4:/etc/mysql/

重启mysql_slave以使my.cnf生效

docker restart mysql_slave

进入mysql_slave查看master status

mysql> show master status;
+------------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| File  | Position | Binlog_Do_DB | Binlog_Ignore_DB    | Executed_Gtid_Set   |
+------------------+----------+--------------+-------------------------------------------------+------------------------------------------+
| slave-log.000001 | 1460 |  | mysql,information_schema,performance_schema,sys | f102ae13-5341-11eb-a578-0242ac110002:1-5 |
+------------------+----------+--------------+-------------------------------------------------+------------------------------------------+
1 row in set (0.00 sec)

准备用于复制的mysql用户

准备mysql_master中用来复制的mysql user

mysql> CREATE USER 'slave'@'192.168.1.139' IDENTIFIED BY 'slave';
Query OK, 0 rows affected (0.59 sec)

mysql> CREATE USER 'slave'@'172.17.0.2' IDENTIFIED BY 'slave';
Query OK, 0 rows affected (0.60 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'192.168.1.139';
Query OK, 0 rows affected (0.19 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'172.17.0.2';
Query OK, 0 rows affected (0.19 sec)j

mysql> flush privileges;
Query OK, 0 rows affected (0.10 sec)

mysql> exit

准备mysql_slave中用来复制的mysql user

mysql> CREATE USER 'slave'@'192.168.1.108' IDENTIFIED BY 'slave';
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE USER 'slave'@'172.17.0.6' IDENTIFIED BY 'slave';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'192.168.1.108';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'172.17.0.6';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

replication配置

配置mysql_master

mysql> change master to master_host='192.168.1.139',master_user='slave',master_password='slave',master_log_file='slave-log.000001',master_port=3307, master_log_pos=1460;
Query OK, 0 rows affected, 2 warnings (1.17 sec)

mysql> change master to master_host='192.168.1.139',master_user='slave',master_password='slave',master_auto_position=1,get_master_public_key=1;
Query OK, 0 rows affected, 2 warnings (0.45 sec)

配置mysql_slave

mysql> change master to master_host='192.168.1.108',master_user='slave',master_password='slave',master_log_file='master-log.000001',master_port=3307, master_log_pos=156;
Query OK, 0 rows affected, 2 warnings (0.15 sec)

mysql> change master to master_host='192.168.1.108',master_user='slave',master_password='slave',master_auto_position=1,get_master_public_key=1;
Query OK, 0 rows affected, 2 warnings (0.14 sec)

开启复制

mysql_master上start slave
mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

查看slave status,发现并没有成功启动复制。出现错误 Access denied for user 'slave'@'172.17.0.1' (using password: YES) 需要到mysql_slave上创建响应的用户和权限,

mysql> show slave status \G;
*************************** 1. row ***************************
  Slave_IO_State: Connecting to master
   Master_Host: 192.168.1.139
   Master_User: slave
   Master_Port: 3307
  Connect_Retry: 60
  Master_Log_File:
  Read_Master_Log_Pos: 4
  Relay_Log_File: relay-log.000001
  Relay_Log_Pos: 4
 Relay_Master_Log_File:
  Slave_IO_Running: Connecting
  Slave_SQL_Running: Yes
  Replicate_Do_DB:
  Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
  Replicate_Do_Table:
 Replicate_Ignore_Table:
 Replicate_Wild_Do_Table:
 Replicate_Wild_Ignore_Table:
   Last_Errno: 0
   Last_Error:
   Skip_Counter: 0
  Exec_Master_Log_Pos: 0
  Relay_Log_Space: 156
  Until_Condition: None
  Until_Log_File:
  Until_Log_Pos: 0
  Master_SSL_Allowed: No
  Master_SSL_CA_File:
  Master_SSL_CA_Path:
  Master_SSL_Cert:
  Master_SSL_Cipher:
  Master_SSL_Key:
 Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
  Last_IO_Errno: 1045
  Last_IO_Error: error connecting to master 'slave@192.168.1.139:3307' - retry-time: 60 retries: 2 message: Access denied for user 'slave'@'172.17.0.1' (using password: YES)
  Last_SQL_Errno: 0
  Last_SQL_Error:
 Replicate_Ignore_Server_Ids:
  Master_Server_Id: 0
   Master_UUID:
  Master_Info_File: mysql.slave_master_info
   SQL_Delay: 0
  SQL_Remaining_Delay: NULL
 Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  Master_Retry_Count: 86400
   Master_Bind:
 Last_IO_Error_Timestamp: 210110 13:02:12
 Last_SQL_Error_Timestamp:
  Master_SSL_Crl:
  Master_SSL_Crlpath:
  Retrieved_Gtid_Set:
  Executed_Gtid_Set:
  Auto_Position: 1
  Replicate_Rewrite_DB:
   Channel_Name:
  Master_TLS_Version:
 Master_public_key_path:
 Get_master_public_key: 1
  Network_Namespace:
1 row in set (0.01 sec)

ERROR:
No query specified

mysql> exit

mysql_slave 启动slave并查看slave status发现一切正常

mysql> show slave status;
mysql> show slave status\G;
*************************** 1. row ***************************
  Slave_IO_State: Waiting for master to send event
   Master_Host: 192.168.1.108
   Master_User: slave
   Master_Port: 3307
  Connect_Retry: 60
  Master_Log_File: master-log.000001
  Read_Master_Log_Pos: 156
  Relay_Log_File: relay-log.000002
  Relay_Log_Pos: 373
 Relay_Master_Log_File: master-log.000001
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
  Replicate_Do_DB:
  Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
  Replicate_Do_Table:
 Replicate_Ignore_Table:
 Replicate_Wild_Do_Table:
 Replicate_Wild_Ignore_Table:
   Last_Errno: 0
   Last_Error:
   Skip_Counter: 0
  Exec_Master_Log_Pos: 156
  Relay_Log_Space: 576
  Until_Condition: None
  Until_Log_File:
  Until_Log_Pos: 0
  Master_SSL_Allowed: No
  Master_SSL_CA_File:
  Master_SSL_CA_Path:
  Master_SSL_Cert:
  Master_SSL_Cipher:
  Master_SSL_Key:
 Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
  Last_IO_Errno: 0
  Last_IO_Error:
  Last_SQL_Errno: 0
  Last_SQL_Error:
 Replicate_Ignore_Server_Ids:
  Master_Server_Id: 1
   Master_UUID: 9627309d-5341-11eb-aaa3-0242ac110006
  Master_Info_File: mysql.slave_master_info
   SQL_Delay: 0
  SQL_Remaining_Delay: NULL
 Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  Master_Retry_Count: 86400
   Master_Bind:
 Last_IO_Error_Timestamp:
 Last_SQL_Error_Timestamp:
  Master_SSL_Crl:
  Master_SSL_Crlpath:
  Retrieved_Gtid_Set:
  Executed_Gtid_Set: f102ae13-5341-11eb-a578-0242ac110002:1-5
  Auto_Position: 1
  Replicate_Rewrite_DB:
   Channel_Name:
  Master_TLS_Version:
 Master_public_key_path:
 Get_master_public_key: 1
  Network_Namespace:
1 row in set, 1 warning (0.01 sec)

ERROR:
No query specified

mysql_slave 上创建用户

mysql> CREATE USER 'slave'@'172.17.0.1' IDENTIFIED BY 'slave';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'172.17.0.1';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

再次查看mysql_master上的slave status,一切正常

mysql> show slave status \G;
*************************** 1. row ***************************
  Slave_IO_State: Waiting for master to send event
   Master_Host: 192.168.1.139
   Master_User: slave
   Master_Port: 3307
  Connect_Retry: 60
  Master_Log_File: slave-log.000001
  Read_Master_Log_Pos: 2022
  Relay_Log_File: relay-log.000002
  Relay_Log_Pos: 2237
 Relay_Master_Log_File: slave-log.000001
  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes
  Replicate_Do_DB:
  Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
  Replicate_Do_Table:
 Replicate_Ignore_Table:
 Replicate_Wild_Do_Table:
 Replicate_Wild_Ignore_Table:
   Last_Errno: 0
   Last_Error:
   Skip_Counter: 0
  Exec_Master_Log_Pos: 2022
  Relay_Log_Space: 2440
  Until_Condition: None
  Until_Log_File:
  Until_Log_Pos: 0
  Master_SSL_Allowed: No
  Master_SSL_CA_File:
  Master_SSL_CA_Path:
  Master_SSL_Cert:
  Master_SSL_Cipher:
  Master_SSL_Key:
 Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
  Last_IO_Errno: 0
  Last_IO_Error:
  Last_SQL_Errno: 0
  Last_SQL_Error:
 Replicate_Ignore_Server_Ids:
  Master_Server_Id: 2
   Master_UUID: f102ae13-5341-11eb-a578-0242ac110002
  Master_Info_File: mysql.slave_master_info
   SQL_Delay: 0
  SQL_Remaining_Delay: NULL
 Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  Master_Retry_Count: 86400
   Master_Bind:
 Last_IO_Error_Timestamp:
 Last_SQL_Error_Timestamp:
  Master_SSL_Crl:
  Master_SSL_Crlpath:
  Retrieved_Gtid_Set: f102ae13-5341-11eb-a578-0242ac110002:1-7
  Executed_Gtid_Set: f102ae13-5341-11eb-a578-0242ac110002:1-7
  Auto_Position: 1
  Replicate_Rewrite_DB:
   Channel_Name:
  Master_TLS_Version:
 Master_public_key_path:
 Get_master_public_key: 1
  Network_Namespace:
1 row in set (0.01 sec)

ERROR:
No query specified

测试复制
mysql_slave上创建test_db_slave

mysql> CREATE DATABASE test_db_slave;
Query OK, 1 row affected (0.01 sec)

mysql_master上创建test_db_master

mysql> CREATE DATABASE test_db_master;
Query OK, 1 row affected (0.24 sec)

查看mysql_slave上的databases

mysql> show databases;
+--------------------+
| Database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| sys  |
| test_db_master |
| test_db_slave |
+--------------------+
6 rows in set (0.00 sec)

mysql>

查看mysql_master上的databases

mysql> show databases;
+--------------------+
| Database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| sys  |
| test_db_master |
| test_db_slave |
+--------------------+
6 rows in set (0.00 sec)

mysql>

至此,mysql replication配置完毕。

到此这篇关于mysql容器之间的replication配置的文章就介绍到这了,更多相关mysql容器的replication配置内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Docker创建MySQL容器的方法

    本文目的是创建一个MySQL的image,并且在新创建出来的容器里自动启动MySQL服务接受外部连接 步骤: 1. 首先创建一个目录并在目录下创建一个Dockerfile,文件内容如下 FROM centos:centos6 MAINTAINER Fanbin Kong "kongxx@hotmail.com" RUN yum install -y mysql-server mysql RUN /etc/init.d/mysqld start &&\ mysql -e

  • Docker容器中Mysql数据的导入/导出详解

    前言 Mysql数据的导入导出我们都知道一个mysqldump命令就能够解决,但如果是运行在docker环境下的mysql呢? 解决办法其实还是用mysqldump命令,但是我们需要进入docker的mysql容器内去执行它,并且通过配置volumes让导出的数据文件可以拷贝到宿主机的磁盘上 所以操作步骤就可以分为: 配置docker的volumes 进入docker的mysql容器,导出数据文件 至于数据导入,太过简单,就不说了 先来看看mysqldump命令常见选项: --all-datab

  • 详解通过Docker搭建Mysql容器+Tomcat容器连接环境

    1.实验目的:web容器能访问部署在另外容器中的MySQL 2.步骤1:拉取mysql镜像,拉取命令如下: docker pull mysql//官网的最新mysql进行 3.步骤2:拉取tomcat镜像,拉取命令如下: docker pull tomcat --name xuguokun/jdk-tomcat 4.步骤3:创建mysql的一个容器,容器的名字是mymysql,创建命令如下: 复制代码 代码如下: docker run --name mymysql -p 3306:3306  -

  • C#自动设置IE代理服务器(翻墙软件)代码实现

    C#自动设置IE代理服务器代码如下: 复制代码 代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Win32; using System.Diagnostics; namesp

  • Docker创建Mysql容器的简单步骤

    前言 前面我们已经安装好了Docker,也简单了解了Docker.下面就来给大家介绍下Docker创建Mysql容器的简单步骤,话不多说了,来一起看看详细的介绍吧 步骤如下 1.启动docker服务 [root@docker ~]# systemctl start docker 2.查看docker里面的镜像 [root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos/mysql-57-centos7 la

  • mysql容器之间的replication配置实例详解

    背景 上周公司培训了MySQL replication, 这个周末打算用所学来实践操作一下. Master server:MySQL container mysql_master on NAS NAS server IP: 192.168.1.108 mysql_master inner ip: 172.17.0.6 Slave server: MySQK container mysql_slave on Mac mini Mac mini docker host IP: 192.168.1.1

  • C++利用MySQL API连接和操作数据库实例详解

    1.C++连接和操作MySQL的方式 系列文章: MySQL 设计和命令行模式下建立详解 C++利用MySQL API连接和操作数据库实例详解 在Windows平台,我们可以使用ADO.ODBC或者MySQL API进行连接和操作.ADO (ActiveX Data Objects,ActiveX数据对象)是Microsoft提出的一个用于存取数据源的COM组件.它提供了程序语言和统一数据访问方式OLE DB的一个中间层,也就是Microsoft提出的应用程序接口(API)用以实现访问关系或非关

  • springmvc与mybatis集成配置实例详解

    简单之美,springmvc,mybatis就是一个很好的简单集成方案,能够满足一般的项目需求.闲暇时间把项目配置文件共享出来,供大家参看: 1.首先我们来看下依赖的pom: <!-- spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.ve

  • MySQL数据类型中DECIMAL的用法实例详解

    MySQL数据类型中DECIMAL的用法实例详解 在MySQL数据类型中,例如INT,FLOAT,DOUBLE,CHAR,DECIMAL等,它们都有各自的作用,下面我们就主要来介绍一下MySQL数据类型中的DECIMAL类型的作用和用法. 一般赋予浮点列的值被四舍五入到这个列所指定的十进制数.如果在一个FLOAT(8, 1)的列中存储1. 2 3 4 5 6,则结果为1. 2.如果将相同的值存入FLOAT(8, 4) 的列中,则结果为1. 2 3 4 6. 这表示应该定义具有足够位数的浮点列以便

  • MySQL 清除表空间碎片的实例详解

    MySQL 清除表空间碎片的实例详解 碎片产生的原因 (1)表的存储会出现碎片化,每当删除了一行内容,该段空间就会变为空白.被留空,而在一段时间内的大量删除操作,会使这种留空的空间变得比存储列表内容所使用的空间更大: (2)当执行插入操作时,MySQL会尝试使用空白空间,但如果某个空白空间一直没有被大小合适的数据占用,仍然无法将其彻底占用,就形成了碎片: (3)当MySQL对数据进行扫描时,它扫描的对象实际是列表的容量需求上限,也就是数据被写入的区域中处于峰值位置的部分: 例如: 一个表有1万行

  • ThinkPHP 在阿里云上的nginx.config配置实例详解

    具体代码如下所示: # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log;

  • Mysql 5.7.9 shutdown 语法实例详解

    mysql-5.7.9 终于提供shutdown 语法啦: 之前如果想关闭一个mysql数据库可以通过kill 命令.mysqladmin shutdown .service mysqld stop 等这样的方式. 然而在mysql-5.7.9之后mysql终于提供了SQL接口的shutdown语法啦! SQL接口下的shutdown语法: 语法 shutdown ; -- 这个shutdown要执行成功要有shutdown权限才行. shutdown的一个例子: [root@workstudi

  • mysql表名忽略大小写配置方法详解

    linux下mysql默认是要区分表名大小写的.mysql是否区分大小写设置是由参数lower_case_table_names决定的,其中: 1)lower_case_table_names = 0  区分大小写(即对大小写不敏感),默认是这种设置.这样设置后,在mysql里创建的表名带不带大写字母都没有影响,都可以正常读出和被引用. 2)lower_case_table_names = 1  不区分大小写(即对大小写敏感).这样设置后,表名在硬盘上以小写保存,MySQL将所有表名转换为小写存

  • Nginx 多站点配置实例详解

    Nginx 多站点配置实例详解 在一台 VPS 上,我们有时候需要同时跑几个 virtualenv.比如 virtualenv app1 跑的是 Django 的一个应用,而 virtualenv app2 跑的是 Tornado.那么如何配置 Nginx,让它同时支持这两个 virtualenv 的运行呢? 首先是 Nginx 的主配置,位于 etc/nginx/ngnix.conf,让它保持默认就行: user nginx; worker_processes 1; error_log /va

  • Vue 中axios配置实例详解

    1.GET 请求 //向具有指定ID的用户发出请求 axios.get('/user?ID=12345') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); // 也可以通过 params 对象传递参数 axios.get('/user', { params: { ID: 12345 } }) .then(function (respons

随机推荐