小编w00*_*00t的帖子

如何阅读 haproxy 统计页面

对于那些使用 HAProxy 和 stats papge (haproxy?stats) 的人,我该如何解释这个页面?没有像样的解释。

例如:哪个会话列显示当前与后端的活动连接数?会话或会话率?

haproxy

24
推荐指数
2
解决办法
3万
查看次数

Nginx上传PUT和POST

我试图让 nginx 接受 POST 和 PUT 方法来上传文件。我已经编译了 nginx_upload_module-2.2.0。

我找不到任何方法。我只想为此只使用 nginx,没有反向代理,没有其他后端,也没有 php。

这是可以实现的吗?

这是我的配置:

nginx version: nginx/1.2.3TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g' --add-module=/usr/src/nginx-1.2.3/nginx_upload_module-2.2.0


server {
    listen       80;
    server_name  example.com;

    location / {
        root   /html;
        autoindex on;
    }

    location /upload {
        root    /html;
        autoindex on;
        upload_store /html/upload 1;

        upload_set_form_field $upload_field_name.name "$upload_file_name"; …
Run Code Online (Sandbox Code Playgroud)

nginx upload

5
推荐指数
2
解决办法
2万
查看次数

Haproxy 速率限制,conn_rate,conn_cur

尝试通过以下方式实现 haproxy 1.5-18 的速率限制:

frontend
stick-table type ip size 100k expire 30s store conn_rate(3s)   #connection rate
stick-table type ip size 1m expire 10s store gpc0,http_req_rate(10s) #http req rate
stick-table type ip size 100k expire 30s store conn_cur        #concurrent connections
    tcp-request connection track-sc1 src
    tcp-request connection reject if { sc1_conn_rate ge 20 }
    tcp-request connection reject if { src_get_gpc0(front) gt 50 }
    tcp-request connection reject if { sc1_conn_cur ge 50 }

backend
acl abuse src_http_req_rate(front) ge 10
    acl flag_abuser src_inc_gpc0(front)
    tcp-request …
Run Code Online (Sandbox Code Playgroud)

haproxy

5
推荐指数
1
解决办法
5958
查看次数

多台服务器上的相同命令

我只是想知道是否有任何系统管理员需要在多台服务器上执行一个命令。如果是这样,你使用什么技术?

我已经厌倦了 SSH 连接到 3-5 个服务器并一遍又一遍地执行相同的事情,所以我想让我的生活更轻松。
另外,我想我应该创建密钥,这样我就不必再输入密码了(尽管我使用的是 root)。这样做了两年后,我有点懒惰了。

我用谷歌搜索了一下,我知道 cssh、pssh、tentakel(这个看起来很酷),还有更亲的流派 - Puppet(我刚刚听说,没有花时间阅读文档)。

顺便说一句,我正在使用 XP+腻子,所以如果有任何腻子很酷的东西可用,那也很受欢迎。如果没有,我总是可以通过 ssh 连接到一台服务器,然后从那里开始我的其余服务器征服:) *邪恶*

打我。谢谢。

ssh command

4
推荐指数
1
解决办法
4111
查看次数

Statsd、Graphite 和图表

我已经设置了 Graphite 和 statsd,两者都运行良好。我正在使用graphite/examples 中的example-client.py 来测量负载值,这没问题。
我开始用 statsd 做测试,起初看起来还可以,因为它生成了一些图表,但现在看起来不太好。

首先,这是我的storage-schema.conf

priority = 100
pattern = .*
retentions = 1m:395d
Run Code Online (Sandbox Code Playgroud)

我正在使用此命令将数据发送到 statsd:

echo 'ssh.invalid_users:1|c'| nc -w 1 -u localhost 8126
Run Code Online (Sandbox Code Playgroud)

它执行,我在 Graphite Web 界面中单击 Update Graph,它生成一条线,再次点击 Update 并且该线消失。像this1this2
如果我执行以前的命令5次,图线将达到2和它实际上将保存。再次运行相同的命令两次,图形线到达 2 并消失。
我找不到我配置错误的内容。

预期用途是这样的:

tail -n 0 -f /var/log/auth.log|grep --line-buffered "Invalid user" | while read line; do echo "ssh.invalid_users:1|c" | nc -w 1 -u localhost 8126; done
Run Code Online (Sandbox Code Playgroud)

编辑:
在一个全新的系统上,我使用最新版本的石墨、碳、nodejs、statsd 重新安装,它的作用相同。
尾随 /opt/graphite/storage/log/carbon-cache/carbon-cache-a/query.log 时,我得到:
cache query …

graphite statsd

4
推荐指数
1
解决办法
2891
查看次数

无法从脚本中取消设置环境变量

我正在尝试从脚本中取消设置所有环境变量。该脚本运行良好,但如果我运行 env 它仍然显示所有变量集。
如果我从 CLI 运行命令,它会起作用并且变量未设置。

unset `env | awk -F= '/^\w/ {print $1}' | xargs`
Run Code Online (Sandbox Code Playgroud)

知道如何从脚本运行它吗?
另外,知道如何从脚本中获取 /etc/profile 吗?这也行不通。

我需要设置名称相同但路径不同的变量,具体取决于我的用户需要的实例。

稍后编辑:
好的,我最终得到了这个(不是很优雅,但无论如何)解决方案:

. script 
Run Code Online (Sandbox Code Playgroud)

其中包含:

unset `env | awk -F= '/^\w/ {print $1}'|egrep -v "HOSTNAME|TERM|SHELL|HISTSIZE|SSH_CLIENT|SSH_TTY|USER|LS_COLORS|KDEDIR|MAIL|PATH|INPUTRC|PWD|LANG|HISTIGNORE|SSH_ASKPASS|TEST|SHLVL|HOME|LD_ASSUME_KERNEL|LOGNAME|SSH_CONNECTION|LESSOPEN|HISTTIMEFORMAT|G_BROKEN_FILENAMES|_"|xargs`
source env_variable_file
Run Code Online (Sandbox Code Playgroud)

谢谢!

scripting bash environment-variables source

3
推荐指数
1
解决办法
9695
查看次数

一个查询中的多个mysql'select from'

SELECT (SELECT user_id FROM users WHERE user_id=1) AS user_id, (SELECT usersetting_user_id FROM usersettings WHERE usersetting_user_id=1) AS usersetting_user_id;

这将返回:

| user_id | usersetting_user_id |  
|       1 |                   1 |
Run Code Online (Sandbox Code Playgroud)

但我想显示所有用户,而不仅仅是一个。所以我运行以下命令:

SELECT (SELECT user_id FROM users) AS user_id, (SELECT usersetting_user_id FROM usersettings) AS usersetting_user_id;``

并得到:

ERROR 1242 (21000): Subquery returns more than 1 row
Run Code Online (Sandbox Code Playgroud)

知道如何规避这个吗?

mysql

1
推荐指数
1
解决办法
924
查看次数

Postfix chroot jail 不起作用

尝试设置 Postfix 以运行 chrooted。只有一点信息来自手册页,它只是说要按照 master.cf 中的说明进行操作。master.cf 是不言自明的,只需在 chroot 列中设置“y”。但不,它仍然不起作用。

# pgrep master
12661

# ls -lh /proc/12661/root
lrwxrwxrwx 1 root root 0 Feb 23 22:03 /proc/12661/root -> /

还是指向我的root!这意味着它仍然从 /etc/passwd 读取用户相关信息(例如 local_recipient_maps),我不想这样做。我想在 chroot 中使用一个单独的 passwd 文件。我尝试设置:

local_recipient_maps = $maps
maps=/var/spool/postfix/etc/passwd

但仍然没有。它仍然从 /etc/passwd 读取。
Chroot env 设置在 /var/spool/postfix 中,所有需要的文件和库都在那里。

master.cf

smtp      inet  n       -       y       -       -       smtpd
smtpd     pass  -       -       y       -       -       smtpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       - …
Run Code Online (Sandbox Code Playgroud)

postfix chroot passwd

0
推荐指数
1
解决办法
2149
查看次数