CentOS 安装/升级Git 1.9.4

Continue Read..

因为yum源的最新版本是1.7.x,所以无法通过yum进行更新,下面描述如何通过编译源码进行安装

1.安装需要的依赖

第一步我们需要做的就是确认系统已经安装了编译git时需要的依赖。使用下面的安装命令即可(已经安装过的不会重新再安装)

yum install curl
yum install curl-devel
yum install zlib-devel
yum install openssl-devel
yum install perl
yum install cpio
yum install expat-devel
yum install gettext-devel
yum install gcc
yum install perl-ExtUtils-MakeMaker

当然,为了快速安装,你可以把上面命令写在一行中,一次执行

yum install crul curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel gcc perl-ExtUtils-MakeMaker

2.下载Git

 cd /usr/src
 wget https://www.kernel.org/pub/software/scm/git/git-1.9.4.tar.gz
 tar xzf git-1.9.4.tar.gz

3.编译

cd git-1.9.4 autoconf
./configure
make
make install

运行autoconf命令时,如果终端提示no command的话就执行yum install autoconf命令后再试

4.重新指定git命令对应的版本

echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrcsource /etc/bashrc

不执行这一步将出现git版本仍然是升级前的

5.检查安装/升级后的版本是否正确

git --version

执行以上命令后应该显示

git version 1.9.4 

6.安装过程中可能遇到的问题

usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale' Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) <span class="goog_qs-tidbit goog_qs-tidbit-0">at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.

出现这个错误的原因是perl-ExtUtils-MakeMaker依赖没有安装成功,执行以下命令重新进行安装

yum install perl-ExtUtils-MakeMaker

yii2 循环执行sql导致内存耗尽的问题解决

Continue Read..

yii2循环执行sql的时候

for ($i = 0; $i < $iterations; $i ++) {
    ...
    Yii::$app->db->createCommand()
        ->batchInsert(static::tableName(), $columns, $rows)
        ->execute();
    echo memory_get_usage();
}

会出现500错误,看下php错误日志,大概会看到内存耗尽的提示

[06-Apr-2017 15:55:43 PRC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 2077602 bytes) in E:\wamp\www\xxx\vendor\yiisoft\yii2-debug\LogTarget.php on line 57

 

这个是由于yii2的日志模块引起的,具体的大家看看代码,不多说了

解决方案

1、在处理循环sql的时候,替换掉自带的日志模块

2、关掉日志模块

 

具体的看这里

I think that problem is in logger of Yii2. Just try to use something like that:

common/components/EmptyLogger.php:

<?php
namespace common\components;

use yii\log\Logger;

class EmptyLogger extends Logger
{
    public function log($message, $level, $category = 'application')
    {
        return false;
    }
}

and then in your action of your controller include next code at the beginning:

Yii::setLogger(new EmptyLogger());

of course also add it in your uses:

use common\components\EmptyLogger;

after all you will receive something like that:

console\controllers\TempController.php:

<?php

namespace console\controllers;

use common\components\EmptyLogger;
use Yii;
use yii\console\Controller;

class TempController extends Controller
{
    public function actionIndex()
    {
        Yii::setLogger(new EmptyLogger());
        ...

        Yii::$app->db->createCommand()
            ->batchInsert(static::tableName(), $columns, $rows)
            ->execute();
        ...

    }
}

Hope it helps. But actually it's not the best solution. Just a hack..

参考:http://stackoverflow.com/questions/27420959/yii2-batchinsert-eats-all-server-memory

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权