• 机房迁移,分布式爬虫服务需要重新部署
  • Centos默认Python版本为Python2.6,需升级为Python2.7
  • 自动Shell脚本安装,代码如下,供参考:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    #!/bin/bash
    #author: nemo_chen

    echo "Start update development tools"

    sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
    sudo yum makecache
    sudo yum update
    sudo yum groupinstall -y 'development tools'
    sudo yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
    sudo yum install -y vim
    echo "Development complate!"

    echo "Start install Python2.7"

    cd /opt

    wget -c http://mirrors.sohu.com/python/2.7.10/Python-2.7.10.tar.xz && tar xvf Python-2.7.10.tar.xz

    cd Python-2.7.10 && ./configure --prefix=/usr/local/

    make && sudo make altinstall

    sudo rm /usr/bin/python

    sudo ln -s /usr/local/bin/python2.7 /usr/bin/python

    sudo cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/sqlite3/

    echo "Python2.7 install complate!"

    echo "Pip start install!"

    curl https://bootstrap.pypa.io/get-pip.py | sudo python -

    mkdir ~/.pip

    cat>~/.pip/pip.conf<<EOF
    [global]
    index-url = https://pypi.douban.com/simple
    EOF

    sudo /usr/local/bin/pip install virtualenv -i https://pypi.douban.com/simple

    echo "Pip install complate!"

    sudo cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/sqlite3/

    sudo sed -i '1s/python/python2.6/g' /usr/bin/yum

    echo "Python2.7 install ok!!!!!!"