批量get url服务器环境部署

1、运行环境:
  1. [root@localhost ~]# cat /etc/redhat-release
  2. CentOS release 6.5 (Final)
  3. [root@localhost ~]# python --version
  4. Python 2.6.6
2、优化系统内核

在”/etc/sysctl.conf”文件尾部追加

  1. # Add
  2. net.ipv4.tcp_syncookies = 1 # 表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭
  3. net.ipv4.tcp_fin_timeout = 30 # 表示如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间
  4. net.ipv4.tcp_tw_reuse = 1 # 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭
  5. fs.file-max = 6553560 # 设置系统所有进程一共可以打开的文件数量
  6. net.ipv4.ip_local_port_range = 1024 65535 # 表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000
3、调整用户打开文件的个数

在”/etc/security/limits.conf”文件尾部追加

  1. # 这个文件主要是用来限制用户对系统资源的使用
  2. # *:所有用户 nofile:打开文件的最大数目
  3. # Add
  4. * soft nofile 1024000
  5. * hard nofile 1024000
4、安装系统软件包

安装python第三方模块gevent之前需要先安装gcc和python-devel,否则会报错

  1. yum -y install gcc python-devel python-lxml libffi-devel openssl-devel
5、安装pip(python模块的仓库,类似于linux下的yum仓库一样)

安装pip之前需要先安装setuptools,否则会报错

  1. wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
  2. tar zxvf setuptools-0.6c11.tar.gz
  3. cd setuptools-0.6c11
  4. python setup.py build
  5. python setup.py install

安装pip

  1. wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
  2. tar -zxf 1.5.5.tar.gz
  3. cd pip-1.5.5/
  4. python setup.py install
6、安装运行程序需要的python模块
  1. pip install requests # 用来请求url
  2. pip install redis # python操作redis
  3. pip install gevent # 异步IO
  4. pip install pyopenssl ndg-httpsclient pyasn1
7、svn部署代码
  1. svn co svn://111.204.117.99/python/work
8、代码
  1. request_proxy # 程序根目录
  2. ├── check_DaiLiIp.py # 测试
  3. ├── __init__.py
  4. ├── put_DaiLiIp.py # 从接口获取代理IP,写到redis中
  5. ├── RedisQueue.py # 将redis的列表功能封装成一个队列的模式
  6. └── request_DaiLiIp.py # get url

9、安装redis

  1. redis安装挪步至
  2. http://www.cnblogs.com/CongZhang/p/5390532.html




posted on 2016-04-14 08:05  奋斗中的码农  阅读(205)  评论(0编辑  收藏  举报

导航