Blog

  • python virtualenv

    开发测试环境在 virtualenv 里进行。

    安装 pip

    yum install python-pip
    

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

    如果遇到 ssl 错误

    python get-pip.py --trusted-host pypi.python.org

    指定 pypi

     pip install -i http://pypi.douban.com/simple/ autobahntestsuite --trusted-host pypi.douban.com

    安装 virtualenv

    sudo pip install virtualenv
    pip3 install virtualenv -i https://mirrors.aliyun.com/pypi/simple

    使用

    virtualenv venv
    source venv/bin/activate
    

    现在已经进入 venv,安装需要的模块

    pip install flask
    pip install redis
    

    将现有的模块 freeze 下来

    pip freeze > requirements.txt
    

    退出虚拟环境

    deactivate
  • systemd使用笔记

    由 chkconfig 转变到 systemd,有点不习惯,查看所有服务

    systemd 是 Linux 内核发起的第一个程序

    systemctl list-unit-files --type=service

    查看具体一个服务信息

    systemctl status keepalived.service

    查看所有服务

    systemctl status

    具体服务的配置文件在

    /usr/lib/systemd/system/mariadb.service

    参考:
    https://linux.cn/article-6888-1.html?utm_source=weibo&utm_medium=weibo

  • vagrant使用笔记

    安装 vagrant

    https://www.vagrantup.com/downloads.html
    

    如果网络不好首先下载 box ,比如 centos6.box centos7.box

    注册一个 box,经常用的可以添加为 base,做为 default box

    vagrant box add base ~/osx-dmg/centos7.box
    vagrant box add centos6 ~/osx-dmg/centos6.box
    vagrant box add centos7 ~/osx-dmg/centos7.box
    

    查看已经导入的 box

    vagrant box list
    #或者
    ls -l ~/.vagrant.d/boxes
    

    如果网络条件好,添加官方的 centos/7 (注意写法)

    $ vagrant box add centos/7
    ==> box: Loading metadata for box 'centos/7'
        box: URL: https://vagrantcloud.com/centos/7
    This box can work with multiple providers! The providers that it
    can work with are listed below. Please review the list and choose
    the provider you will be working with.
    
    1) hyperv
    2) libvirt
    3) virtualbox
    4) vmware_desktop
    
    Enter your choice: 2
    

    工作目录为 ~/test,进入目录,创建一台 centos7 的机器,--minimal 生成的文件没有注释

    vagrant init centos/7 --minimal
    

    启动

    vagrant up

    连接 vagrant

    vagrant ssh
    

    执行 id 命令

    vagrant ssh -c 'id'

    查看当前 vagrant 管理的机器,最前面为机器 id

                                                                                    
    vagrant global-status
    

    修剪 vagrant 已经坏掉的机器

                                                       
    vagrant global-status --prune
    

    如果有不需要的 box

                                                                    
    vagrant destroy id
    

    准备多台虚拟机环境

      config.vm.define "web" do |web|                                               
        web.vm.box = "centos6"                                                      
      end                                                                           
                                                                                    
      config.vm.define "db" do |db|                                                 
        db.vm.box = "centos6"                                                       
      end
    

    查看机器的状态

    vagrant status

    查看 ssh 信息

    vagrant ssh-config

    关闭 vm

    vagrant halt

    不需要的 box 删除

    vagrant box remove centos/7

    vagrant 官方 centos7 box:

    https://vagrantcloud.com/centos/7/

    centos 提供的 box:

    http://cloud.centos.org/centos/7/vagrant/x86_64/images/

    windows 10 将 virtualbox 换为 hyperv
    上面获取 box 步骤时选 hyperv, 将原来 virtualbox 的相关 box 删除

    vagrant.exe box  remove centos/7 --provider virtualbox --all

    切到目录下,删除相关的 vm
    vagrant.exe destroy
    启动

    vagrant up --provider hyperv
  • 2016年5月面试经历

    车享网 国企
    陆金所
    http://www.chinadep.com/

    杨洋,达达运维岗位,面试时间26号周二上午10:00。面试地址:上海市浦东南路1036号隆宇大厦6楼

    wiwidi

    面试职位:OPS运维工程师

    面试时间:2016年4月26日(周二)上午14:00

    面试地址:上海市徐汇区漕东支路81号漕河泾实业大厦9楼(地铁1号线漕宝路站下,3号口出)

    联系电话:021-6283 8830、14782288717(蔡丽莹)

    地 图:

    ele.me

    [email protected]

    iqiyi

  • ssh config 针对某些机器密码登陆

    一些机器不要公钥登陆,在每次连的时候提示密码

    Host kong
    Hostname 192.168.1.200
    User jpuyy                                                              
    Port 22                                                                         
    PreferredAuthentications password
    

    服务端,例如 sftp 可以允许密码登录的话

    Match user jpuyy address 192.168.1.0/24
        PasswordAuthentication yes
        # also since we want only sftp
        ForceCommand internal-sftp
    
    
  • nginx upgrade 失败

    CentOS 下使用 yum 安装。为了平滑升级

    yum update nginx

    安装完成之后

    /etc/init.d/nginx upgrade

    提示失败,nginx_error.log 中出现

    [alert] 10690#0: execve() failed while executing new binary process "nginx" (2: No such file or directory)

    原因是之前启动没有使用 /usr/sbin/nginx -c /etc/nginx/nginx.conf 启动,而是通过环境变量里的 nginx 启动的。这样的话只能想办法把这台踢出集群,然后

    /etc/init.d/nginx restart

    参考:https://groups.google.com/forum/#!topic/openresty/HiV3c-JwTZ4