Kivi

没有什么远大理想,只是永远都不会满足而已


  • 首页

  • 关于

  • 标签

  • 归档

基于docker搭建mongodb分片集群

发表于 2016-08-16 更新于 2017-07-02 分类于 mongodb
本文字数: 11k 阅读时长 ≈ 10 分钟

什么是mognodb分片集群

官方描述

Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

自己的理解

  • 横向拓展,解决单台服务器磁盘不够用的问题
  • 将写入压力分散到各个分片

为什么要使用分片集群

  • 复制所有的写入操作到主节点
  • 延迟的敏感数据会在主节点查询
  • 单个副本集限制在12个节点
  • 当请求量巨大时会出现内存不足
  • 本地磁盘不足
  • 垂直扩展价格昂贵
阅读全文 »

基于docker搭建mongodb副本集

发表于 2016-08-15 更新于 2017-07-02 分类于 mongodb
本文字数: 6.2k 阅读时长 ≈ 6 分钟

什么是mognodb副本集

官网上这么描述

A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments. This section introduces replication in MongoDB as well as the components and architecture of replica sets. The section also provides tutorials for common tasks related to replica sets.

阅读全文 »

git移除之前没有ignore的文件/文件夹

发表于 2016-07-01 更新于 2017-07-02 分类于 git
本文字数: 175 阅读时长 ≈ 1 分钟

命令git rm

移除一个文件

1
2
3
git rm text.js --cached
git commit -am 'test: rm files'
git push

移除一个文件夹

1
2
3
git rm folder -f --cached
git commit -am 'test: rm folder'
git push

清理docker容器日志

发表于 2016-06-19 更新于 2017-07-02 分类于 docker
本文字数: 186 阅读时长 ≈ 1 分钟

其实就是想清理一下docker容器的日志,网上找了好一会也没有看到直接的答案

  • 确定容器iddocker inspect container-name
  • 找到容器目录
    ubuntu默认容器目录在`/var/lib/docker/containers/container-name`
    
  • 删除日志
    删除目录下的文件`container-name`-json.log
    

就这么简单

siege做简单压力测试

发表于 2016-06-07 更新于 2017-07-02 分类于 Node.js
本文字数: 3.3k 阅读时长 ≈ 3 分钟

准备

1
brew install siege

参数说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
siege --help

SIEGE 3.0.6
Usage: siege [options]
siege [options] URL
siege -g URL
Options:
-V, --version VERSION, prints the version number.
-h, --help HELP, prints this section.
-C, --config CONFIGURATION, show the current config.
#在屏幕上打印显示出当前的配置,配置是包括在他的配置文件$HOME/.siegerc中,
#可以编辑里面的参数,这样每次siege 都会按照它运行.
-v, --verbose VERBOSE, prints notification to screen.
#运行时能看到详细的运行信息
-q, --quiet QUIET turns verbose off and suppresses output.
-g, --get GET, pull down HTTP headers and display the
transaction. Great for application debugging.
-c, --concurrent=NUM CONCURRENT users, default is 10
#模拟有n个用户在同时访问,n不要设得太大,因为越大,siege 消耗本地机器的资源越多
-i, --internet INTERNET user simulation, hits URLs randomly.
#随机访问urls.txt中的url列表项,以此模拟真实的访问情况(随机性)
-b, --benchmark BENCHMARK: no delays between requests.
-t, --time=NUMm TIMED testing where "m" is modifier S, M, or H
ex: --time=1H, one hour test.
#持续运行siege ‘n’秒(如10S),分钟(10M),小时(10H)
-r, --reps=NUM REPS, number of times to run the test.
#重复运行测试n次,不能与 -t同时存在
-f, --file=FILE FILE, select a specific URLS FILE.
#指定用urls文件,默认为siege安装目录下的etc/urls.txt
#urls.txt文件:是很多行待测试URL的列表以换行符断开,格式为:
#[protocol://]host.domain.com[:port][path/to/file]
-R, --rc=FILE RC, specify an siegerc file
#指定用特定的siege配置文件来运行,默认的为$HOME/.siegerc
-l, --log[=FILE] LOG to FILE. If FILE is not specified, the
default is used: PREFIX/var/siege.log
#运行结束,将统计数据保存到日志文件siege.log中,可在.siegerc中自定义日志文件
-m, --mark="text" MARK, mark the log file with a string.
-d, --delay=NUM Time DELAY, random delay before each requst
between 1 and NUM. (NOT COUNTED IN STATS)
#hit每个url之间的延迟,在0-n之间
-H, --header="text" Add a header to request (can be many)
-A, --user-agent="text" Sets User-Agent in request
-T, --content-type="text" Sets Content-Type in request

Copyright (C) 2014 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

编写url文件

get

1
2
server=www.example.com
http://${server}/hello?param=hehe

post

1
2
server=www.example.com
http://${server}/hello POST p1=hehe&p2=haha

开始测试

1
siege -c 100 -r 2 -f url.txt

结果说明

1
2
3
4
5
6
7
8
9
10
11
12
Transactions:				26 hits				#完成26次处理
Availability: 13.00 % #成功率
Elapsed time: 2.36 secs #总共使用时间
Data transferred: 0.12 MB #共数据传输 0.12 MB
Response time: 1.14 secs #响应时间,显示网络连接的速度
Transaction rate: 11.02 trans/sec #平均每秒完成 11.02 次处理
Throughput: 0.05 MB/sec #平均每秒传送数据
Concurrency: 12.55 #实际最高并发连接数
Successful transactions: 26 #成功处理次数
Failed transactions: 174 #失败处理次数
Longest transaction: 0.83 #每次传输所花最长时间
Shortest transaction: 0.05  #每次传输所花最短时间
1…567…12
kivi

kivi

nodejs | server
58 日志
17 分类
32 标签
RSS
© 2019 kivi | 173k | 2:37
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Pisces v7.3.0
|