EC2通过命令上传文件到S3

爬虫文件在服务器上爬取数据的时候下载了很多的数据,为了保存这些数据,给这些数据做个备份于是就想把文件传到s3存储上。其实要上传文件也比较简单,通过awscli命令行工具即可上传。首选需要去aws的后台创建访问安全凭证。点击用户名,选择访问密钥,创建新的访问密钥,下载之后是一个csv文件包含AWSAccessKeyId和AWSSecretKey

在服务器上安装awscli,执行

sudo apt install awscli

安装aws命令行工具。

安装完成之后执行

aws configure

进行配置,输入key和secret即可:

最后两项可以留空。

Continue Reading

CentOS 6 更新php 从7.0到7.2

# 
yum install epel-release
#  install Remi repo
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm
# centos 7 rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# check installed version
yum list installed php*
# remove old version
yum remove php*
# install new version
yum install --enablerepo=remi-php72 php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
# check php version
php -v

ubuntu uwsgi No module named ‘django’

ubuntu uwsgi 服务器启动之后 链接服务器提示500, 查看系统日志发现没有找到django模块。但是通过pip命令可以看到已经成功安装了。

猜测可能是python路径搜索问题导致的,随便搜了一下找到这么一篇文章:https://blog.csdn.net/dqchouyang/article/details/78762432

Continue Reading

阿里云 EC2 CentOS 6.0 系统分区扩容

阿里云的虚拟主机磁盘空间满了,这个主要是用来放blog的,所以并没有其他的数据盘。所有的数据都是直接放到/dev/vda1磁盘下的,数据库也是在这个盘下。从阿里云的后台扩容了磁盘发现还需要登陆进行扩容,于是开始按照教程操作,事实证明给出的文档(https://help.aliyun.com/document_detail/25452.html?spm=a2c4g.11186623.6.788.666a3f87QwRXFB)里面方法比较蛋疼,对于扩展系统分区不大适用。 

后来发现貌似看的文档有问题,如果要扩展系统盘应该看这个https://help.aliyun.com/document_detail/111738.html?spm=5176.2020520101.0.0.44d34df5aZCEKE。 这个就尴尬了 smile ,没看好文档。

安装growpart

yum install cloud-utils-growpart

然后对系统分区进行扩容:

growpart /dev/vda 1

Continue Reading

git 统计一段时间内提交的代码行数

代码:

 git log --author="obaby" --after="2019-08-04 00:00:01" --before="2019-08-10 12:00:00"
 --pretty=tformat: --numstat | grep -v 'static'  |
 gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "增加行数:%s 删除行数:%s 变化总行数:%s\n",add,subs,loc }'
参数说明:
--author 作者 提交者
--after 开始时间
--before 结束时间
--pretty 格式

上面的代码依赖于linux windows下运行可以使用cgywin 或者mobaxterm,https://mobaxterm.mobatek.net

MobaXterm is your ultimate toolbox for remote computing. In a single Windows application, it provides loads of functions that are tailored for programmers, webmasters, IT administrators and pretty much all users who need to handle their remote jobs in a more simple fashion.

MobaXterm provides all the important remote network tools (SSH, X11, RDP, VNC, FTP, MOSH, …) and Unix commands (bash, ls, cat, sed, grep, awk, rsync, …) to Windows desktop, in a single portable exe file which works out of the box.

There are many advantages of having an All-In-One network application for your remote tasks, e.g. when you use SSH to connect to a remote server, a graphical SFTP browser will automatically pop up in order to directly edit your remote files. Your remote applications will also display seamlessly on your Windows desktop using the embedded X server

systemd 运行celery

However, the init.d script should still work in those Linux distributions as well since systemd provides the systemd-sysv compatiblity layer which generates services automatically from the init.d scripts we provide.

官网已经有了相关的教程http://docs.celeryproject.org/en/latest/userguide/daemonizing.html#usage-systemd, 但是在实际操作的时候发现按照教程来配置无法正常启动。会报错,于是把服务简化了一下,把配置和服务信息写到了一起。如果你也遇到这个问题可以尝试下面的简化脚本:

[Unit]
Description=Celery Service
After=network.target

[Service]
WorkingDirectory=/var/www/html
ExecStart=/usr/local/bin/celery -A proj worker --logfile=/var/log/celery/celery.log  --loglevel="INFO"

Restart=on-failure

#3秒后启动
RestartSec=3s

[Install]
WantedBy=multi-user.target

系统Ubuntu 18.04, systemd版本:

root@mars:/etc/systemd/system# systemctl --version
systemd 229
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP 
+GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN

阿里云蛋疼的pip

qq20161103-1

阿里云的主机确实蛋疼,连pip都更新不了也是醉了。参考这个帖子的办法,修改更新服务器吧:

 
mkdir ~/.pip
cat > ~/.pip/pip.conf < < EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
EOF