使用 Navicat For Mysql 导入数据库的时候,报错 [Err] 1153 - Got a packet bigger than 'max_allowed_packet' bytes
,因为 LNMP 一键安装包默认 MySQL 配置 最大允许文件包为 1M 所致
登陆终端,编辑 MySQL 配置文件 vim /etc/my.cnf
修改或添加 max_allowed_packet=512M
保存退出 :wq
重启MySQL lnmp restart
学习日志 LIUGUOFENG
原数据盘 20G 扩容至 25G,购买后通过 SSH 登陆实例进行操作;
操作步骤完全参考阿里云帮助即可:https://help.aliyun.com/document_detail/25452.html
[root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 15G 23G 39% / tmpfs 939M 0 939M 0% /dev/shm /dev/vdb1 20G 13G 6.7G 65% /home/wwwroot [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# umount /dev/vdb1 [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 15G 23G 39% / tmpfs 939M 0 939M 0% /dev/shm [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# fdisk -l Disk /dev/vda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00020f03 Device Boot Start End Blocks Id System /dev/vda1 * 1 5222 41940992 83 Linux Disk /dev/vdb: 26.8 GB, 26843545600 bytes 16 heads, 63 sectors/track, 52012 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x78d92770 Device Boot Start End Blocks Id System /dev/vdb1 1 41610 20971408+ 83 Linux [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# fdisk /dev/vdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): d Selected partition 1 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-52012, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-52012, default 52012): Using default value 52012 Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# e2fsck -f /dev/vdb1 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/vdb1: 95741/1310720 files (0.8% non-contiguous), 3228283/5242852 blocks [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# resize2fs /dev/vdb1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/vdb1 to 6553504 (4k) blocks. The filesystem on /dev/vdb1 is now 6553504 blocks long. [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# mount /dev/vdb1 /home/wwwroot [root@iZ2ze4knyxhkgpnbo7brn7Z ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 15G 23G 39% / tmpfs 939M 0 939M 0% /dev/shm /dev/vdb1 25G 13G 12G 52% /home/wwwroot
值得注意的点是 fdisk 命令操作时, 是使用 fdisk /dev/vdb
而不是 fdisk /dev/vdb1
,这里没仔细看坑了我好长时间,一直扩容失败;
扩容成功。
rsync 是很好用的同步软件,使用增量方式同步。不过使用 rsync 时有没有尾部斜杠效果是不同的
使用方法 rsync src dest
总结一下规律:
src 目录没有带斜杠:则在 dest 下面有 src 文件夹
src 目录没有带斜杠:则在 dest 目录下面只有 src 目录下面的文件
换言之:如果忽略了源文件斜杠 rsync 将创建源文件目录的最后一个文件夹名字并且包含它的所有文件,如果添加了斜杠 rsync 将跳过那个目录直接复制里面的内容
dest 带不带斜杠没有任何影响。 Continue reading rsync 带不带尾部斜杠的不同作用
错误
[root@iZ25xpwwmfnZ ~]# umount /dev/vdb5 umount: /data/wwwroot/www.1001alading.com/Uploads: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
查看
[root@iZ25xpwwmfnZ ~]# fuser -m -v /data/wwwroot/www.1001alading.com/Uploads USER PID ACCESS COMMAND /data/wwwroot/www.1001alading.com/Uploads: www 2925 f.... nginx www 2927 F.... nginx root 18365 f.... AliYunDun root 28557 f.... pick.sh
杀进程
[root@iZ25xpwwmfnZ ~]# fuser -m -v -i -k /data/wwwroot/www.1001alading.com/Uploads USER PID ACCESS COMMAND /data/wwwroot/www.1001alading.com/Uploads: www 2925 f.... nginx www 2927 F.... nginx www 2928 F.... nginx root 18365 f.... AliYunDun root 28557 f.... pick.sh Kill process 2925 ? (y/N) y Kill process 2927 ? (y/N) y Kill process 2928 ? (y/N) y Kill process 18365 ? (y/N) y Kill process 28557 ? (y/N) y
再次卸载
mkdir /home/Uploads mkdir /home/temp mv /home/wwwroot/ald.1001ald/Uploads/* /home/Uploads umount /dev/vdb1 mount /dev/vdb1 /home/temp mv -rf /home/Uploads /home/wwwroot/ald.1001ald mv /home/wwwroot/ald.1001ald/ /home/temp umount /dev/vdb1 mount /dev/vdb1 /home/wwwroot
vim /etc/rc.d/rc.local mount /dev/vdb1 /home/wwwroot
\cp -rf
远程复制示例
从 12.23.34.45 复制到当前服务器
rsync -avzu --progress root@12.23.34.45:/data/wwwroot/ald.com/Uploads/ /home/wwwroot/ald.com/Uploads/
> crontab -e
0 3 * * * /sbin/reboot
设置凌晨 3 点重启服务器,但未生效
原因是 crontab 程序需重启
> /etc/init.d/crond restart
CentOS 7 使用
service crond restart
systemctl restart crond
以下为测试: