分类目录归档:PHP

beanstalkd 安装和配置

安装
安装以centos为例

yum  install beanstalkd

配置

使用centos yum安装,通过查看服务脚本发现有这个配置文件

cat /etc/sysconfig/beanstalkd

主要修改几个地方
ADDR=-l 10.1.3.16 # 修改为内网或本地地址,否则会开放外网非常危险
PORT=-p 11111 # 修改下端口
BINLOG_DIR=-b /var/lib/beanstalkd/binlog # 启用二进制日志防止意外断电或重启导致数据丢失

 

客户端连接问题:

Connection error 113: No route to host

解决办法:防火墙开放对应端口

性能:

$start = microtime(true);
for ($i = 0; $i < 100000; $i ++) {
    $beansClient->useTube('myAwesomeTube')->put("哈哈哈job's payload呵呵呵呵");
}
echo microtime(true) - $start, "\n";

插入一万条数据一秒(本地连接)

插入十万条数据十秒(本地连接)

插入一万条数据14秒(内网连接)

本地取出1w条数据要1.5秒

内网取出1w条数据要33秒

本地取出 1173359条数据 要 200秒

结论:吃内存,快还是慢你觉得呢?

RabbitMQ 简单队列

我想要的是定时任务延时队列,似乎不满足需求,现在用redis做的队列又可以满足大部分需求,先放着吧

    # 推送到队列
    public function aa032() {
        $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
        $channel = $connection->channel();
        
        $channel->queue_declare('hello', false, false, false, false);
        
        $msg = new AMQPMessage('Hello World 233!');
        $channel->basic_publish($msg, '', 'hello');
        
        echo " [x] Sent 'Hello World 233!'\n";
        
        $channel->close();
        $connection->close();
    }

    # 守护处理队列
    public function aa033() {
        $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
        $channel = $connection->channel();
        
        $channel->queue_declare('hello', false, false, false, false);
        
        echo " [*] Waiting for messages. To exit press CTRL+C\n";
        
        $callback = function ($msg) {
            echo ' [x] Received ', $msg->body, "\n";
        };
        
        $channel->basic_consume('hello', '', false, true, false, false, $callback);
        
        while (count($channel->callbacks)) {
            $channel->wait();
        }
    }

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

CURL证书错误问题正确解决方法

方法1:自己自己下载一个根证书(不推荐)
下载地址:https://github.com/bagder/ca-bundle

// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_CAPATH, __DIR__);
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/ca-bundle.crt');

方法2:自动找到系统里的证书路径(推荐)

# 安装
composer require composer/ca-bundle
# 通过下面方法即可返回证书路径
\Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_CAPATH, __DIR__);
curl_setopt($ch, CURLOPT_CAINFO, \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath());

GuzzleHttp https证书问题解决

$client = new \GuzzleHttp\Client([
    \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
]);

pecl update mongodb 1.1.* to 1.2.* 导致 php-fpm 全部立即段错误并失去控制,systemctl restart php-fpm失败

第二次遇到了~
ps -ef | grep php-fpm | cut -c 9-15 | xargs kill && systemctl restart php-fpm


Dec 15 20:40:02 web4 systemd: Removed slice User Slice of root.
Dec 15 20:40:02 web4 systemd: Stopping User Slice of root.
Dec 15 20:40:25 web4 kernel: traps: php-fpm[10171] general protection ip:7f4046d83120 sp:7ffc76043de0 error:0 in mongodb.so[7f4046d57000+be000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1770] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1771] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1772] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1773] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1774] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1775] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1776] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1777] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:25 web4 kernel: traps: php-fpm[1778] general protection ip:7f4054402542 sp:7ffc76045578 error:0 in ld-2.17.so[7f40543e9000+21000]
Dec 15 20:40:26 web4 systemd: Stopping LSB: starts php-fpm...

org.apache.solr.common.SolrException: Exception writing document id 663b167f2d661568 to the index; possible analysis error: cannot change DocValues type from SORTED_SET to NUMERIC for field “is_original”

org.apache.solr.common.SolrException: Exception writing document id 663b167f2d661568 to the index; possible analysis error: cannot change DocValues type from SORTED_SET to NUMERIC for field "is_original"

我这里修改tints类型为tint类型,导致新数据无法写入,字段删除完毕了,也reload了没有,只要清理的数据才行

<delete><query>*:*</query></delete>
<commit/>