月度归档: 2017 年 7 月

  • CentOS6.X 手动配置增加swap分区

    CentOS6.X 手动配置增加swap分区

    有些云vps里面并没有swap分区,比如阿里云搬瓦工VultrLinode等是不提供swap的,下面给出方法手动增加swap分区。

    [title]

    Swap是什么?

    [/title]

    Swap分区在系统的物理内存不够用的时候,把硬盘空间中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到Swap分区中,等到那些程序要运行时,再从Swap分区中恢复保存的数据到内存中。
    下面我们说一下手动增加swap分区的方法:

    [title]1. 查看当前分区情况[/title]

    free -m

    ? ? ? ? ? ? ?total ? ? ? used ? ? ? free ? ? shared ? ?buffers ? ? cached

    Mem: ? ? ? ? ?1861 ? ? ? 1763 ? ? ? ? 98 ? ? ? ? 30 ? ? ? ?162 ? ? ? ? 73

    -/+ buffers/cache: ? ? ? 1526 ? ? ? ?334

    Swap: ? ? ? ? 2047 ? ? ? ?624 ? ? ? 1423

    [title]2. 增加 swap 大小, 2G 左右[/title]

    dd if=/dev/zero of=/swap bs=1024 count=2048000

    记录了2048000+0 的读入

    记录了2048000+0 的写出

    2097152000字节(2.1 GB)已复制,18.4418 秒,114 MB/秒

    [title]3. 设置交换文件[/title]

    mkswap /swap

    mkswap: /swap: warning: don’t erase bootbits sectors

    on whole disk. Use -f to force.

    Setting up swapspace version 1, size = 2047996 KiB

    no label, UUID=5258d5c0-9b75-4380-8b94-0b04f336294d

    [title]4. 立即激活启用交换分区[/title]

    swapon /swap

    [title]5. 添加系统引导时自启动运行[/title]

    vi /etc/fstab

    #

    # /etc/fstab

    # Created by anaconda on Wed Dec 21 08:43:36 2016

    #

    # Accessible filesystems, by reference, are maintained under ‘/dev/disk’

    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

    #

    UUID=b5845b95-3407-4fc6-8c18-d6037a3e6edd / ? ? ? ? ? ? ? ? ? ? ? ext4 ? ?defaults ? ? ? ?1 1

    UUID=4646c812-a919-4969-be4c-ebcc3fa32795 /boot ? ? ? ? ? ? ? ? ? ext4 ? ?defaults ? ? ? ?1 2

    UUID=5f08ac8b-91d6-4bce-b153-534a93b81225 swap ? ? ? ? ? ? ? ? ? ?swap ? ?defaults ? ? ? ?0 0

    tmpfs ? ? ? ? ? ? ? ? ? /dev/shm ? ? ? ? ? ? ? ?tmpfs ? defaults,size=1024m ? ? ? ?0 0

    devpts ? ? ? ? ? ? ? ? ?/dev/pts ? ? ? ? ? ? ? ?devpts ?gid=5,mode=620 ?0 0

    sysfs ? ? ? ? ? ? ? ? ? /sys ? ? ? ? ? ? ? ? ? ?sysfs ? defaults ? ? ? ?0 0

    proc ? ? ? ? ? ? ? ? ? ?/proc ? ? ? ? ? ? ? ? ? proc ? ?defaults ? ? ? ?0 0

    swap ? ? ? ? ? ? ? ? ? ?/swap ? ? ? ? ? ? ? swap ? ?defaults ? ? ? ?0 0

    (更多…)

  • yum update 初始化失败、初始化软件包后端失败、yum-complete-transaction解决方法

    yum update 初始化失败、初始化软件包后端失败、yum-complete-transaction解决方法

    问题简介:最近进入到CentOs6.3的虚拟机里时,每隔几分钟就会跳出一个提示框如下:

    本人新手,直接在终端中输入:“yum-complete-transaction”命令会提示:

    bash: yum-complete-transaction: command not found。

    在网上搜寻很久后,尝试了多种解决方法,最终的解决方法如下

    解决方法:

    1、打开终端,su切换到root权限,并输入命令如下:

    2、根据1中提示,一路‘y’下去,完成安装。

    3、输入问题中提示的“yum-complete-transaction”命令如下:

    希望能够给遇到和我情况相同的朋友做个参考。

  • MacBook MacOS FileZilla 421:too many connections

    MacBook MacOS FileZilla 421:too many connections

    MacBook MacOS 的?Filezilla FTP/SFTP ?链接服务器显示错误:421:too many connections

    Response: 421 Too many connections (8) from this IP Error: Could not connect to server

    显示链接过多的错误,现在贴出解决方法:

    1. Open FileZilla.打开FileZilla
    2. Access the Site Manager. 打开站点管理
    3. Click on Transfer Settings tab 点击传输设置标签
    4. Check the box for Limit number of simultaneous connections, and set the Maximum number of connections to 10 or more. 点击传输设置的数量,修改到10,或者更多
    5. Click the OK button. Now when you are using FileZilla, it will not allow you to go over your limitation of 8 simultaneous FTP connections. 点击OK按钮,现在重新连接即可。
  • AMH WordPress后台地址登录 菜地地址缺失wp-admin路径 解决方法

    AMH WordPress后台地址登录 菜地地址缺失wp-admin路径 解决方法

    这段时间一直被WordPress后台跳转的时候丢失wp-admin路径困扰,猜想过几个原因但找不到原因;
    前端正常没有问题,刚进入后台的时候也正常,点击链接跳转的时候很容易出现丢失wp-admin路径
    例如:写文章的页面地址是http://laji.org.org/wp-admin/post-new.php,丢失路径后变成了http://laoji.org/post-new.php;
    路径不正确自然报错404,手工补全路径后就恢复正常,虽然影响不大但是对后台操作还是造成了很大的不便;
    vps使用的是AMH面板,今天记录导致这一问题的原因所在,原来是Rewrite规则出了问题;

    解决方法:

    进入AMH后台点击模块扩展找到AMRewrite,把wordpress.conf修改成如下:

    location / {
        index index.html index.php;
        if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
    }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

     

  • Debian下crontab默认编辑器nano切换到Vi 实例教程

    Debian下crontab默认编辑器nano切换到Vi 实例教程

    Debian系统在使用crontab默认的编辑器是nano,用起来很不方便,该如何进行切换呢?

    update-alternatives --config editor

    There are 8 choices for the alternative editor (providing /usr/bin/editor).
    Selection? ? Path? ? ? ? ? ? ? ? Priority? Status
    ————————————————————
    0? ? ? ? ? ? /usr/bin/joe? ? ? ? 70? ? ? ? auto mode
    * 1? ? ? ? ? ? /bin/nano? ? ? ? ? ? 40? ? ? ? manual mode
    2? ? ? ? ? ? /usr/bin/jmacs? ? ? 50? ? ? ? manual mode
    3? ? ? ? ? ? /usr/bin/joe? ? ? ? 70? ? ? ? manual mode
    4? ? ? ? ? ? /usr/bin/jpico? ? ? 50? ? ? ? manual mode
    5? ? ? ? ? ? /usr/bin/jstar? ? ? 50? ? ? ? manual mode
    6? ? ? ? ? ? /usr/bin/rjoe? ? ? ? 25? ? ? ? manual mode
    7? ? ? ? ? ? /usr/bin/vim.basic? 30? ? ? ? manual mode
    8? ? ? ? ? ? /usr/bin/vim.tiny? ? 10? ? ? ? manual mode
    Press enter to keep the current choice[*], or type selection number: 7
    update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/editor (editor) in manual mode.

    输入命令之后,提示选择,根据自己喜好进行选择即可,这里我选择的是VI编辑器,输入7。
    现在crontab编辑器已经变成了VI。
    如果没有切换成功,请手动重启一下服务:/etc/init.d/cron restart

  • Mysql 查找 列 全数字的行数

    Mysql 查找 列 全数字的行数

    项目中用到了需要统计某个列是数字的行数,可以使用mysql的 REGEXP 函数:

    select COUNT(1) from tablename where uniacid=123 and touser REGEXP '^[0-9]+$'"

     

  • Mysql经常宕机Unsafe statement written to the binary log解决办法

    Mysql经常宕机Unsafe statement written to the binary log解决办法

    最近数据库老是自动宕机挂掉,然后查看mysql.log发现下面的日志:

    [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted.

    问题原因
    查了下原因,longxibendi这个表上有2个唯一键。则使用 INSERT… ON DUPLICATE KEY UPDATE ,且当前数据库binlog_format是statement格式,这种sql语句就会报unsafe。

    查了下手册

    INSERT … ON DUPLICATE KEY UPDATE statements on tables with multiple primary or unique keys. When executed against a table that contains more than one primary or unique key, this statement is considered unsafe, being sensitive to the order in which the storage engine checks the keys, which is not deterministic, and on which the choice of rows updated by the MySQL Server depends.

    An INSERT … ON DUPLICATE KEY UPDATE statement against a table having more than one unique or primary key is marked as unsafe for statement-based replication beginning with mysql 5.6.6. (Bug #11765650, Bug #58637)

    http://dev.mysql.com/doc/refman/5.6/en/replication-rbr-safe-unsafe.html

    看官方解释,是 server层把数据传给innodb引擎,innodb引擎检查key值比较敏感造成的。
    个人理解,可能与server与innodb每次只传1行数据有关。

    解决办法

    • 修改binlog_format格式为mixed;登陆mysql,执行 set global binlog_format=MIXED;
    • 不要使用这类sql;
  • Centos Debian 锐速破解版一键安装包

    Centos Debian 锐速破解版一键安装包

    脚本已托管在 Github:https://github.com/91yun/serverspeeder

    速锐ServerSpeed并不支持OpenVZ的虚拟化。

    [title]可以支持的VPS:[/title]

    Vultr账号注册及购买使用教程

    Linode全面升级 推出月付5刀的套餐 机房可选东京2

    DigitalOcean注册验证账户、激活账号图文教程

    [title]锐速破解版安装方法:[/title]

    wget -N --no-check-certificate https://raw.githubusercontent.com/91yun/serverspeeder/master/serverspeeder-all.sh && bash serverspeeder-all.sh

    [title]锐速破解版卸载方法:[/title]

    chattr -i /serverspeeder/etc/apx* && /serverspeeder/bin/serverSpeeder.sh uninstall -f

    [title]查看锐速启动状态[/title]

    /serverspeeder/bin/serverSpeeder.sh status

    [title]锐速破解版功能:[/title]

    如果内核完全匹配就会自动下载安装。
    如果没有完全匹配的内核,会在界面提示可选内核,可以手动选个最接近的尝试
    自动下载授权文件
    自动修改配置文件
    已chattr +i /serverspeeder/etc/apx*禁止修改配置文件,可以不用加hosts了

    目前只支持CentOS,ubuntu和debian。锐速不支持openvz架构。所以你查看vps的mac地址都是0的就别试了。

  • Mac XAMPP 环境 PHP 安装 Memcache 扩展 php-memcache memcached

    Mac XAMPP 环境 PHP 安装 Memcache 扩展 php-memcache memcached

    下面记录一下Mac下XAMPP环境中添加php对memcache的扩展,网上的一些资料比较复杂,需要自己编译,下面我们给一个简单的方法。

    [title]安装php-memcache扩展:[/title]

    在终端中运行如下命令:

    brew install autoconf
    sudo /Applications/XAMPP/xamppfiles/bin/pecl install memcache

    然后在php.ini里面添加如下内容:

    php.ini的路径一般为:

    /Applications/XAMPP/xamppfiles/etc/php.ini

    添加内容为:

    extension = memcache.so

    重启apache.

    [title]安装memcached:[/title]

    brew install memcached

    [title]启动memcached:[/title]

    /usr/local/opt/memcached/bin/memcached -m 128 -p 11211 -d

     

  • git代码管理:使用git push时错误:error: unable to rewind rpc post data – try increasing http.postBuffer error: RPC failed; curl 56 SSLRead() return error -36

    git代码管理:使用git push时错误:error: unable to rewind rpc post data – try increasing http.postBuffer error: RPC failed; curl 56 SSLRead() return error -36

    error: unable to rewind rpc post data – try increasing http.postBuffer error: RPC failed; curl 56 SSLRead() return error -36

    大概意思是http.postBuffer太小,需要设置更大的值,应该是我们项目中用到的第三方静态库有400多MB大小的单个.a文件。

    谷歌查了相关资料,在终端执行

    git config --global http.postBuffer 524288000

    命令,将http.postBuffer设置为500MB大小后,可以正常push操作了。

  • Git中从远程的分支获取最新的版本到本地

    Git中从远程的分支获取最新的版本到本地

    Git中从远程的分支获取最新的版本到本地有这样2个命令:

    1.git fetch:相当于是从远程获取最新版本到本地,不会自动merge

    git fetch origin master
    git log -p master..origin/master
    git merge origin/master

    以上命令的含义:
    首先从远程的origin的master主分支下载最新的版本到origin/master分支上
    然后比较本地的master分支和origin/master分支的差别
    最后进行合并

    上述过程其实可以用以下更清晰的方式来进行:

    git fetch origin master:tmp
    git diff tmp
    git merge tmp

    从远程获取最新的版本到本地的test分支上
    之后再进行比较合并

    2. git pull:相当于是从远程获取最新版本并merge到本地

    git pull origin master

    上述命令其实相当于git fetch 和 git merge
    在实际使用中,git fetch更安全一些
    因为在merge前,我们可以查看更新情况,然后再决定是否合并

WeChat