手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表全部文章

How To Add Swap on Ubuntu 14.04

    当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到Swap空间中,等到那些程序要运行时,再从Swap中恢复保存的数据到内存中。这样,系统总是在物理内存不够时,才进行Swap交换。这个是SWAP 交换分区的作用。 实际上,我们更关注的应该是SWAP分区的大小问题。 设置多大才是最优的。 

    一般来说可以按照如下规则设置swap大小: 

  1. 4G以内的物理内存,SWAP 设置为内存的2倍。
  2.  4-8G的物理内存,SWAP 等于内存大小。 
  3. 8-64G 的物理内存,SWAP 设置为8G。
  4.  64-256G物理内存,SWAP 设置为16G。 

实际上,系统中交换分区的大小并不取决于物理内存的量,而是取决于系统中内存的负荷,所以在安装系统时要根据具体的业务来设置SWAP的值。

实际上在启动腾讯云的时候,swap是禁用的(没注意是系统原因还是其他)。所以就需要打开Swap,DO的网站上就有现成的教程:https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04,可以参考 一下

我这里不转贴。不过原文里有几个命令可能运行不了,比如使用:dd if=/dev/zero of=/swapfile bs=1G count=4,1G一个块可能不行,换成256的话,就OK了。原文中的:fallocate,debian可能无法执行。

然后一步步的执行到底就OK了。当然,要将分区信息加到fstab中,才会每次启动都会带上。

旧版debian增加PHP7.2源

 原来的dobdeb对于jessie等都不再支持7.2了,所以新的7.2只能从sury上进行获取

 
执行:
XML/HTML代码
  1. #!/bin/bash  
  2. # To add this repository please do:  
  3.   
  4. if [ "$(whoami)" != "root" ]; then  
  5.     SUDO=sudo  
  6. fi  
  7.   
  8. ${SUDO} apt-get -y install apt-transport-https lsb-release ca-certificates  
  9. ${SUDO} wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg  
  10. ${SUDO} sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'  
  11. ${SUDO} apt-get update  
记不住没关系,打开网址:https://packages.sury.org/php/,就有Readme了。复制粘贴运行一下就行!
 

invalid command code ., despite escaping periods, using sed

 linux上面,如果替换文件中的内容,其实还是比较方便的。比如:sed -i 's/xxx/yyy/g' xxx.txt

然而同样的命令,如果放到mac下面,就会报:sed: 1: "xxx.txt": invalid command code o
到stackoverflow.com就会发现已经有人回复了:https://stackoverflow.com/questions/19456518/invalid-command-code-despite-escaping-periods-using-sed
XML/HTML代码
  1. If you are on a OS X, this probably has nothing to do with the sed command. On the OSX version of sed, the -i option expects an extension argument so your command is actually parsed as the extension argument and the file path is interpreted as the command code.  
  2.   
  3. Try adding the -e argument explicitly and giving '' as argument to -i:  
  4.   
  5. find ./ -type f -exec sed -i '' -e "s/192.168.20.1/new.domain.com/" {} \;  
  6. See this.  
所以上面的代码就改为:sed -i '' -e 's/xxx/yyy/g' xxx.txt ,搞定
 
参考:
1、https://stackoverflow.com/questions/19456518/invalid-command-code-despite-escaping-periods-using-sed
2、https://stackoverflow.com/questions/7573368/in-place-edits-with-sed-on-os-x
 
 
 

Tags: sed

转的关于公众号接收信息的返回

 以下是内容:

 

 
XML/HTML代码
  1. 首次访问时post的数据   
  2. 获取ticket访问时get的数据($encryptMsg) 
  3. {"signature":"bb539c3ecaddf06040912a836cdeb2060f649b1a","timestamp":"1491385757","nonce":"776481090","encrypt_type":"aes","msg_signature":"472008a1054eab89651ae9c484395e4e54abb01e","action":"get_ticket"}   

  4. 消息接入时get的数据($param) 
  5. {"action":"news","amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;b":"/wx570bc396a51b8ff8","signature":"550a39d2ffa8dbe0b0f8f6cfadd8a9b8981b3752","timestamp":"1491385766","nonce":"947166308","openid":"ozy4qt5QUADNXORxCVipKMV9dss0","encrypt_type":"aes","msg_signature":"d67c434cb7e54a0b51b2cdceba38650ea62a35a2"}   

  6. 消息接入时get的数据($param) 
  7. {"action":"news","amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;b":"/wx570bc396a51b8ff8","signature":"595e8376b3587a8d68c68132417931b6fd0b8f9d","timestamp":"1491385775","nonce":"898963343","openid":"ozy4qt5QUADNXORxCVipKMV9dss0","encrypt_type":"aes","msg_signature":"1d6291da6617638c95d4be800d8394547a8d4137"}   

  8.  消息接入时get的数据($param)
  9.  {"action":"news","amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;b":"/wx570bc396a51b8ff8","signature":"72e0b354fd7b6643335d1035471617441e57e945","timestamp":"1491385783","nonce":"1115275135","openid":"ozy4qt5QUADNXORxCVipKMV9dss0","encrypt_type":"aes","msg_signature":"3d16bee6896984fbf2ba333ef2be389739ddd30a"}    

  10. 获取ticket访问时get的数据($encryptMsg) 
  11. {"signature":"fa4b87ee9574913ac68bd1044c35a48a1bb41a40","timestamp":"1491385789","nonce":"429149520","encrypt_type":"aes","msg_signature"     :"9626625a665c03f128462ace8a5dff0cf2c5d0f8","action":"get_ticket"}   

  12.  通过$encryptMsg与$param获取 component_verify_ticket
  13.  ticket@@@bYIJwVAxqf75BhEVRNhaaf1KTit5zxiqbZ5KR7xJumzniEEy6DTIWHeic1-L_z7LuhPwwSNLm_V_8hkyRYX-PQ 

  14. 通过$encryptMsg与$param验证微信接入测试请求($data)
  15.  {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385765","MsgType":"text","Content":"QUERY_AUTH_CODE:queryauthcode@@@mFZ_yC83hgDZhf-s6pL6UGloyMYzH8MTCEQddsa8U5ceEze4zflgNNk4sU1kkGUkZn37-Su4t9C5gaR09gjkKQ","MsgId":"6405453086801493549"} {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385774","MsgType":"text","Content":"TESTCOMPONENT_MSG_TYPE_TEXT","MsgId":"6405453125456199215"} {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385783","MsgType":"event","Event":"LOCATION","Latitude":"111.000000","Longitude":"222.000000","Precision":"333.000000"}   

  16. 微信接入测试回复 $data 
  17. {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385765","MsgType":"text","Content":"QUERY_AUTH_CODE:queryauthcode@@@mFZ_yC83hgDZhf-s6pL6UGloyMYzH8MTCEQddsa8U5ceEze4zflgNNk4sU1kkGUkZn37-Su4t9C5gaR09gjkKQ","MsgId":"6405453086801493549"} {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385774","MsgType":"text","Content":"TESTCOMPONENT_MSG_TYPE_TEXT","MsgId":"6405453125456199215"} {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385783","MsgType":"event","Event":"LOCATION","Latitude":"111.000000","Longitude":"222.000000","Precision":"333.000000"}   

  18. 1、通过$data获取$query_auth_code
  19.  queryauthcode@@@mFZ_yC83hgDZhf-s6pL6UGloyMYzH8MTCEQddsa8U5ceEze4zflgNNk4sU1kkGUkZn37-Su4t9C5gaR09gjkKQ
  20.  
  21.  2、通过$data获取$access_token 
  22. dZiS58MkUvLOkSBvX2SDu6-P6hGqN5GJj8T8jOlhszo80KuwMgytZb2GIoNlsUMeSpM_WLBMc65KDG80h2-zjh-8PWdE2br8Pchdk6MFJjg13vCjhDVyPyZ3_1XbTmg2GSWgADDLXB 
  23.  
  24. 微信接入测试回应 回应数据 
  25. 1、{"ToUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","FromUserName":"gh_3c884a361561","CreateTime":1491385775,"MsgType":"text","Content":"TESTCOMPONENT_MSG_TYPE_TEXT_callback","FuncFlag":0} 
  26. 2、{"ToUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","FromUserName":"gh_3c884a361561","CreateTime":1491385783,"MsgType":"text","Content":"LOCATIONfrom_callback","FuncFlag":0}   
  27.  
  28. 解密回应数据 
  29. 1、\n\n\n1491385775\n\n
  30. 2、\n\n\n1491385783\n\n   
  31.  
  32. 微信接入测试请求 
  33. {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385765","MsgType":"text","Content":"QUERY_AUTH_CODE:queryauthcode@@@mFZ_yC83hgDZhf-s6pL6UGloyMYzH8MTCEQddsa8U5ceEze4zflgNNk4sU1kkGUkZn37-Su4t9C5gaR09gjkKQ","MsgId":"6405453086801493549"} 
  34. {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385774","MsgType":"text","Content":"TESTCOMPONENT_MSG_TYPE_TEXT","MsgId":"6405453125456199215"} 
  35. {"ToUserName":"gh_3c884a361561","FromUserName":"ozy4qt5QUADNXORxCVipKMV9dss0","CreateTime":"1491385783","MsgType":"event","Event":"LOCATION","Latitude":"111.000000","Longitude":"222.000000","Precision":"333.000000"}  
  36.  
  37.  获取微信开放平台授权信息 
  38. {"authorization_info":{"authorizer_appid":"wx570bc396a51b8ff8","authorizer_access_token":"dZiS58MkUvLOkSBvX2SDu6-P6hGqN5GJj8T8jOlhszo80KuwMgytZb2GIoNlsUMeSpM_WLBMc65KDG80h2-zjh-8PWdE2br8Pchdk6MFJjg13vCjhDVyPyZ3_1XbTmg2GSWgADDLXB","expires_in":7200,"authorizer_refresh_token":"refreshtoken@@@5lb5Jq2giPuJ0gjjyD9J_3y7VhyVgVt6kIuYlGkATFg","func_info":[{"funcscope_category":{"id":1}},{"funcscope_category":{"id":15}},{"funcscope_category":{"id":4}},{"funcscope_category":{"id":7}},{"funcscope_category":{"id":2}},{"funcscope_category":{"id":3}},{"funcscope_category":{"id":11}},{"funcscope_category":{"id":6}},{"funcscope_category":{"id":5}},{"funcscope_category":{"id":8}},{"funcscope_category":{"id":13}},{"funcscope_category":{"id":9}},{"funcscope_category":{"id":10}},{"funcscope_category":{"id":12}}]}}   
  39.  
  40. ComponentAccessToken 
  41. ticket:PrJUyVJYEAlQ75bCbBLk4DkdHefqRM4r_ZV7ivJuahmG1Hap41QHJQ9MVsY4JOdlp21dR7gmUxuUa4eeTM8D1az4fhY8yYjBBGkC7KLyvSEGclB0vgza1xzk65m0GNAQVGMfABAFQW  
 COPY自:http://blog.lwp8800.com/news/detail.html?id=22

cannot create/resize docker.qcow2

mac下面安装过docker,但后来删除过。然后系统又重做过。结果再次安装docker的时候报错,如题(详细 路径不贴了)

找了一下资料,各种各样的都有,最后还是选择了:
XML/HTML代码
  1. sudo rm -r /var/tmp/com.docker.vmnetd.socket  
  2. sudo rm -r ~/Library/Application\ Scripts/com.docker.helper/  
  3. sudo rm -r ~/Library/Containers/com.docker.*  
  4. sudo rm -r ~/Library/Preferences/com.docker.docker.plist  
  5. sudo rm -r ~/Library/Group\ Containers/group.com.docker/  
然后再次运行Docker,一切都解决了
 

Tags: docker