分类 电脑 下的文章

更新 magento2 产品索引时,elastic search 报错 - status 429

问题:magento2.4的站点,执行 bin/magento indexer:reindex 后,elastic search 报错。内容如下:

Catalog Search index process error during indexation process:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"}],"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"},"status":429}

尝试:按网上说的,调整elastic search设置后就可以了:

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

参考:https://stackoverflow.com/questions/63689953/magento-2-4-reindex-issue-with-elasticsearch

发自139.com的邮件,不能在电信内网的邮局中收到 - iredmail

环境:电信的线路,在内网的一台机子上安装了 iredmail 邮局
问题:邮局与腾讯的收发邮件,正常。但发自139.com的邮件,不能收到
现象:邮局中的日志有如下字样:

Aug  5 21:57:29 mail postfix/smtpd[22485]: connect from n169-113.mail.139.com[120.232.169.113]
Aug  5 21:57:29 mail postfix/smtpd[22485]: Anonymous TLS connection established from n169-113.mail.139.com[120.232.169.113]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Aug  5 21:57:29 mail postfix/smtpd[22485]: 4LznGd6ykCz9w4l: client=n169-113.mail.139.com[120.232.169.113]
Aug  5 21:59:27 mail postfix/anvil[21946]: statistics: max connection rate 1/60s for (smtpd:120.232.169.113) at Aug  5 21:49:27
Aug  5 21:59:27 mail postfix/anvil[21946]: statistics: max connection count 1 for (smtpd:120.232.169.113) at Aug  5 21:49:27
Aug  5 21:59:27 mail postfix/anvil[21946]: statistics: max cache size 1 at Aug  5 21:49:27
Aug  5 22:00:45 mail clamd[1737]: SelfCheck: Database status OK.
Aug  5 22:02:30 mail postfix/smtpd[22485]: timeout after DATA (0 bytes) from n169-113.mail.139.com[120.232.169.113]
Aug  5 22:02:30 mail postfix/smtpd[22485]: disconnect from n169-113.mail.139.com[120.232.169.113]

尝试:看起来,自建邮局能与139.com邮局的IP互访,但为什么自建邮局不能成功收信呢?

依照网上的帖子,这可能是因为内网的机子拨号后,以太网的默认的mtu 1500值显得大,需要调小以适合传送。

[root@mail ~]# ping -M do -s 1430 n169-113.mail.139.com
PING n169-113.mail.139.com (120.232.169.113) 1430(1458) bytes of data.
ping: local error: Message too long, mtu=1400
ping: local error: Message too long, mtu=1400
ping: local error: Message too long, mtu=1400

果然,将mtu调小到1400后,自建的邮局就可以成功从139.com收到邮件了。

参考:

postfix 多实例多配置运行 - postmulti - 各实例用各自的发信出口IP

需求:配置有多个IP地址的机子,想让postfix用不同的IP地址发出邮件。

尝试:可以使用 postmulti 配置多个不同的postfix实例:每个实例使用自己的main.cf配置文件,在各实例的main.cf里绑定指定的IP地址。

参考:

cPanel - WHM - The SMTP restriction - 限制用户使用外部smtp发信

问题:cPanel用户无法通过php使用外部smtp服务器发信。

尝试:执行如 openssl s_client -connect smtp.gmail.com:465 的命令,显示cPanel/WHM本机的ssl证书,并不是gmail的。

解决:登录到WHM,禁用 The SMTP restriction 功能即可。

This feature prevents users from bypassing the mail server to send mail, a common practice used by spammers.
It will allow only the MTA, mailman, and root to connect to remote SMTP servers.

This control is also adjustable in Tweak Settings.

The SMTP restriction is enabled.

参考:https://docs.cpanel.net/whm/security-center/smtp-restrictions/

用 Xidel 提取出目标网页的数据 然后通过 REST API 发布到 WordPress 站

需求:复制指定网页上某部分的文字,然后以文章的形式发布到wordpress站,采集。

尝试:xidel 这个软件很好地自动分析文件上标签,并导出数据。将导出的数据以参数递给 curl,通过 WordPress 的 REST API 发布文章。

如:

for i in $(seq -w 1000)
do
    caijiurl=https://liujia.anqun.org/index.php/archives/${i}/
    # curl $caijiurl | iconv -f gb2312 > out.html
    wget -O out.html $caijiurl
    title=$(xidel out.html -e "(css('h1'))")
    content=$(xidel out.html -e "(css('div.post-content'))")

    curl --user "admin:apppassword" -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"title":"'$title'","content":"'$content'","type":"post","status":"publish","categories":[25]}' https://wp.anqun.org/wp-json/wp/v2/posts
done

参考: