centos7安装rabbitMq3.8和erlang22.x步骤


一、安装erlang环境

1、新增文件 /etc/yum.repos.d/rabbitmq_erlang.repo,在文件里面新增下面内容并保存:

[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://pac

Read more

python celery 实现异步任务处理


# 安装celery

pip install celery
pip install eventlet
# eventlet - 具有WSGI支持的异步框架
# eventlet是python库函数,一个是处理和网络相关的,另一个可以通过协程实现并发
# 可以实现'并发'(绿色线程),非阻塞
# 对Python库函数改写,支持协程

#安装broker

可以选择RabbitMQ或者Redis,celery官方推荐的是用rabbitmq,不过我这里,两种broker 我都会安装

  • redis 安装
# 下载编译
wget http://download.redis.io/rele

Read more

vue.js 组件之prop


# prop 的大小写

HTML 中的 attribute 名是大小写不敏感的,所以浏览器会把所有大写字符解释为小写字符。这意味着当你使用 DOM 中的模板时,camelCase (驼峰命名法) 的 prop 名需要使用其等价的 kebab-case (短横线分隔命名) 命名:

Vue.component('blog-post', {
  // 在 JavaScript 中是 camelCase 的
  props: ['postTitle'],
  template: '<h3>{{ postTitle }}</h3>'

Read more

python 分布式进程


参考廖雪峰的官方网站 https://www.liaoxuefeng.com/wiki/1016959663602400/1017631559645600

Python的multiprocessing模块不但支持多进程,其中managers子模块还支持把多进程分布到多台机器上

如果我们已经有一个通过Queue通信的多进程程序在同一台机器上运行,现在,由于处理任务的进程任务繁重,希望把发送任务的进程和处理任务的进程分布到两台机器上。怎么用分布式进程实现?

原有的Queue可以继续使用,但是,通过managers模块把Queue通过网络暴露出去,就可以让其他机器的进程访问Queue了

# task

Read more

mysql修改binlog日志保留时间


#命令行

  • 临时有效,重启mysqld服务后失效.
# 查看
show variables like "%expire_logs_days%";

# 设置保留7天
set global expire_logs_days=7;

#配置文件

  • 永久有效,需重启mysqld服务才生效.
vim /etc/my.cnf
mysqld模块
expire_logs_days=7
  • 说明: 0-表示永不过期; 单位为天。

Read more

进程 vs 线程


我们介绍了多进程和多线程,这是实现多任务最常用的两种方式。现在,我们来讨论一下这两种方式的优缺点。

首先,要实现多任务,通常我们会设计Master-Worker模式,Master负责分配任务,Worker负责执行任务,因此,多任务环境下,通常是一个Master,多个Worker。

如果用多进程实现Master-Worker,主进程就是Master,其他进程就是Worker。

如果用多线程实现Master-Worker,主线程就是Master,其他线程就是Worker。

多进程模式最大的优点就是稳定性高,因为一个子进程崩溃了,不会影响主进程和其他子进程。(当然主进程挂了所有进程就全挂了,但是Ma

Read more

python ThreadLocal


参考廖雪峰的官方网站 https://www.liaoxuefeng.com/wiki/1016959663602400/1017630786314240

import threading

# 创建全局ThreadLocal对象:
local_school = threading.local()

def process_student():
    # 获取当前线程关联的student:
    std = local_school.student
    print('Hello, %s (in %s)' % (std, threading.current_thread(

Read more

python 多线程


参考廖雪峰的博客https://www.liaoxuefeng.com/wiki/1016959663602400/1017629247922688

import time, threading

# 假定这是你的银行存款:
balance = 0

lock = threading.Lock()

def change_it(n):
    # 先存后取,结果应该为0:
    global balance
    balance = balance + n
    balance = balance - n

def run_thread(n):
    for i in range(10

Read more