群晖(黑群晖)的备份

数据很重要、数据很重要、数据很重要!!! 重要的话说三遍,话说自己买了个黑群晖,6盘位的,就是为了保存照片和数据…… 其实1盘和2盘的nas都是耍流氓,根本无用,必须是4盘位以上的才勉强可靠。所以才买的这个黑群晖,只买了3个盘做了raid5,侥是如此,真的是莫名坏了一块,好在在保修期内,更换一块后故障解除,期间倒腾2块盘的数据依然是噩梦啊。 那么数据如此重要,那么怎么做到完全的备份呢? 数据是3盘raid5,已经有保证了,剩下就是系统也必须有备份可恢复才可以 群晖本质是linux,文件系统是mdadm+lvm,所以备份也必须从这个方向开始。 首先是备份启动的usb盘,先fdisk -l 看一下: Disk /dev/sda: 2000.3 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 311 2490240 fd Linux raid autodetect Partition 1 does not end on cylinder boundary /dev/sda2 311 572 2097152 fd Linux raid autodetect Partition 2 does not end on cylinder boundary /dev/sda3 588 243201 1948793440+ fd Linux raid autodetect Disk /dev/sdb: 2000.3 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 311 2490240 fd Linux raid autodetect Partition 1 does not end on cylinder boundary /dev/sdb2 311 572 2097152 fd Linux raid autodetect Partition 2 does not end on cylinder boundary /dev/sdb3 588 243201 1948793440+ fd Linux raid autodetect Disk /dev/sdc: 2000.3 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 311 2490240 fd Linux raid autodetect Partition 1 does not end on cylinder boundary /dev/sdc2 311 572 2097152 fd Linux raid autodetect Partition 2 does not end on cylinder boundary /dev/sdc3 588 243201 1948793440+ fd Linux raid autodetect Disk /dev/sdu: 4227 MB, 4227858432 bytes 4 heads, 32 sectors/track, 64512 cylinders Units = cylinders of 128 * 512 = 65536 bytes Device Boot Start End Blocks Id System /dev/sdu1 * 1 256 16352+ e Win95 FAT16 (LBA) 3块2T的盘,每个盘有3个分区,然后最后是USB盘,盘符sdu,备份它 ...

2024年01月19日 · 4 分钟 · 702 字 · 八戒

如何把jpg合成gif

用ffmpeg就很简单了 首先把要合并的jpg都变成合适的尺寸 convert -resize 300x *.jpg 然后变gif convert -delay 30 -loop 0 1.jpg 2.jpg 3.jpg 4.jpg result.gif -loop 0 表示无限循环 -delay 30 表示每帧之间等待的时间

2024年01月19日 · 1 分钟 · 23 字 · 八戒

mac os下安装openvpn客户端并设置自启动

没办法,网络环境太烂,只能装个openvpn client连接到服务器,系统是mac,要求一直保持连接,还要能重启自动连。 安装过程如下: 1.安装openvpn brew install openvpn 2.安装tun/tap驱动 wget http://downloads.sourceforge.net/tuntaposx/tuntap_20150118.tar.gz tar zxvf tuntap_20150118.tar.gz 然后在mac os桌面下,双击tuntap_20150118.pkg安装 3.准备client.conf文件,这个文件就是标准的client端文件 4.测试是否可以正常启动 /usr/local/opt/openvpn/sbin/openvpn --config /usr/local/etc/openvpn/ddky.conf 5.测试成功后在mac os编写plist文件 vi /Library/LaunchDaemons/net.openvpn.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";> <plist version="1.0"> <dict> <key>Label</key> <string>net.openvpn</string> <key>KeepAlive</key> <dict> <key>NetworkState</key> <true/> </dict> <key>Program</key> <string>/usr/local/opt/openvpn/sbin/openvpn</string> <key>ProgramArguments</key> <array> <string>openvpn</string> <string>--config</string> <string>/usr/local/etc/openvpn/client.conf</string> </array> <key>RunAtLoad</key> <true/> <key>TimeOut</key> <integer>90</integer> <key>WorkingDirectory</key> <string>/usr/local/etc/openvpn</string> </dict> </plist> 6.然后运行 ...

2024年01月19日 · 1 分钟 · 87 字 · 八戒

Ubuntu下如何给所有用户安装nodejs的nvm

最近工作比较多在Ubuntu平台下。 用visualenv和nvm比较多,但是nvm遇到的问题比较多。 比如jenkins调用nvm就比较麻烦 如何用用root用户给所有用户都装上统一的nvm呢? 1、首先安装基本依赖包: apt-get install build-essential openssl libssl-dev curl 2、建个公共组,这个组的成员可以控制nvm: groupadd dev 3、git克隆下载nvm的代码 git clone https://github.com/creationix/nvm.git /opt/nvm 4、建立两个公用目录,一个是放nvm,一个是放nodejs的npm,并设置好权限 mkdir /usr/local/nvm mkdir /usr/local/node chown -R root:dev /usr/local/nvm chmod -R 775 /usr/local/nvm chown -R root:dev /usr/local/node chmod -R 775 /usr/local/node 5、建立好公用的 /etc/profile.d/nvm.sh 供所有人source用,注意,source命令是bash下用的,如果是sh,就用.替代。 export NVM_DIR=/usr/local/nvm source /opt/nvm/nvm.sh export NPM_CONFIG_PREFIX=/usr/local/node export PATH="/usr/local/node/bin:$PATH" 6、断开重新登录,加载nvm nvm --version 7、安装特定版本的node nvm install V18.18.2 8、设置缺省node的版本 nvm alias default V18.18.2 9、随后把用户拉进dev组,然后登陆就可以了。验证命令如下: nvm list node -v

2024年01月19日 · 1 分钟 · 68 字 · 八戒

ulimit的用法

基本常识,各种语焉不详啊,其实ulimit最常用的就两个参数 -u number: 单个用户能运行的最大进程数 -n number: 单个进程可以同时打开的文件描述符的最大值,缺省1024 有两个地方需要设置,Hard和Soft,Hard是Soft的最高限值,天花板。这两个值都可以针对某用户单独设置。 所以设法如下: ulimit -S -n 10240 ulimit -H -n 20480 ulimit -S -u 10240 ulimit -H -u 20480 可以在/etc/security/limits.conf里设置 * soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072 也可以在/etc/rc.d/rc.local中用命令设置 cat /etc/rc.d/rc.local ... ulimit -u 204800 -HSn 204800 ...

2024年01月18日 · 1 分钟 · 52 字 · 八戒

flask/python对mongodb的一些操作

首先是安装mongodb yum install -y mongodb-server mongodb Installing for dependencies: boost-filesystem boost-iostreams boost-program-options boost-system boost-thread gperftools-libs libicu libunwind v8 会装一堆依赖包,boost库,icu库,v8库,gperftools库,都是很厉害的库啊! 启动: service mongod start 导入海量数据: [root@ovs-16-11-2 ~]# mongoimport -d mydb -c prj01 --type csv --file opendata_projects.csv --headerline connected to: 127.0.0.1 Thu Jul 28 09:50:47.002 Progress: 39118658/470754183 8% Thu Jul 28 09:50:47.002 74400 24800/second Thu Jul 28 09:50:50.033 Progress: 80042213/470754183 17% Thu Jul 28 09:50:50.033 150700 25116/second Thu Jul 28 09:50:53.145 Progress: 108143323/470754183 22% Thu Jul 28 09:50:53.145 202700 22522/second Thu Jul 28 09:50:56.004 Progress: 149781879/470754183 31% Thu Jul 28 09:50:56.004 280000 23333/second Thu Jul 28 09:50:59.001 Progress: 179705162/470754183 38% Thu Jul 28 09:50:59.001 336200 22413/second Thu Jul 28 09:51:03.385 Progress: 212197023/470754183 45% Thu Jul 28 09:51:03.385 396400 20863/second Thu Jul 28 09:51:06.015 Progress: 236552399/470754183 50% Thu Jul 28 09:51:06.015 441700 20077/second Thu Jul 28 09:51:09.299 Progress: 264365847/470754183 56% Thu Jul 28 09:51:09.299 493300 19732/second Thu Jul 28 09:51:12.001 Progress: 304790148/470754183 64% Thu Jul 28 09:51:12.001 568500 20303/second Thu Jul 28 09:51:15.033 Progress: 323508057/470754183 68% Thu Jul 28 09:51:15.033 603300 19461/second Thu Jul 28 09:51:18.607 Progress: 361610334/470754183 76% Thu Jul 28 09:51:18.607 674200 19829/second Thu Jul 28 09:51:21.000 Progress: 393748962/470754183 83% Thu Jul 28 09:51:21.000 733700 19829/second Thu Jul 28 09:51:24.007 Progress: 427667505/470754183 90% Thu Jul 28 09:51:24.007 796900 19922/second Thu Jul 28 09:51:27.001 Progress: 459658299/470754183 97% Thu Jul 28 09:51:27.001 857300 19937/second Thu Jul 28 09:51:27.793 check 9 878853 Thu Jul 28 09:51:27.979 imported 878852 objects 进入命令行,看看库的整体情况: ...

2024年01月18日 · 4 分钟 · 711 字 · 八戒

F5 irule之google站长认证别样用法

公司的网站要过google认证,需要在网站根目录下放一个文件,googleb1e6d9a50ea8xxxx.html 内容如下: google-site-verification: googleb1e6d9a50ea8xxxx.html 这个无比简单,怎么又跟F5和irule扯上关系了呢?! 哎,因为居然要做两个域名,m.xxx.com和h.xxx.com,这两个域名都要过认证,而且悲剧的是,这两个域名实际代理的是同一台后端服务器的同一个tomcat进程。 鉴于这个东西这么简单,干脆在F5上来一段irule解决问题: when HTTP_REQUEST { if { ([string tolower [HTTP::path]] starts_with "/googleb1e6d9a50ea8xxxx.html") && ([string tolower [HTTP::host]] equals "m.xxx.com") } { HTTP::respond 200 content "google-site-verification: googleb1e6d9a50ea8xxxx.html" } } 由于没有复用ip,所以在h.xxx.com同样修改以上脚本并应用即可。 如果是穷光蛋作风,在F5上复用了IP做了虚拟主机转发,也修改修改脚本即可。

2024年01月18日 · 1 分钟 · 34 字 · 八戒

mbox文件中的=3D是什么鬼(quoted-printable编码)

最近在搞邮局。有个很奇怪的问题,就是打开mbox的文件,比如说: /var/spool/mail/root 里面信件的部分有奇怪的3D字符: <table cellpadding=3D"0" cellspacing=3D"0" style=3D"text-align:le= ft;color:#454545;background-color:#fff;font-size:14px;border-radius:10px;pa= 注意,中间多了若干个3D,最后也多了=号 这是什么鬼呢? 搜了一圈,原来这是quoted-printable编解码,跟Base64类似,base64和quoted-printable这两种编码都是在电子邮件中常见的编码方式。 基本知识: 如果=号出现在一行最后,表示换行,那么: he= llo 意思就是连起来的hello 如果中间出现=3D,那就是一个=号的意思 所以style=3D"text"意思就是style=“text” 英文字符除了=以外不做处理,其他字符的编码为=加这个字符的两个字节的16进制数。 弄明白了吧。 给一段处理mbox的python程序,可以用来读邮件: #!/usr/bin/env python # -*- coding: utf-8 -*- import mailbox import base64 import os import sys import email import quopri filename = "/var/spool/mail/zrr" mb = mailbox.mbox(filename) nmes = len(mb) for i in range(len(mb)): print "\n\n\n\n\n" print "-------------------------------------------------------------------------------------------------" print "Email", i print "-------------------------------------------------------------------------------------------------" mes = mb.get_message(i) em = email.message_from_string(mes.as_string()) subject = em.get('Subject') if subject.find('=?') != -1: ll = email.header.decode_header(subject) subject = "" for l in ll: subject = subject + l[0] em_from = em.get('From') if em_from.find('=?') != -1: ll = email.header.decode_header(em_from) em_from = "" for l in ll: em_from = em_from + l[0] print "From: %s - Subject: %s" %(em_from, subject) print "-------------------------------------------------------------------------------------------------" if mes.is_multipart(): for part in mes.get_payload(): print quopri.decodestring(part.get_payload()) else: print quopri.decodestring(mes.get_payload())

2024年01月18日 · 1 分钟 · 133 字 · 八戒

Linux下virtual FTP的搭建pure-ftpd

用过proftpd和vs-ftpd,proftpd有巨恐怖的sftp细粒度控制,特殊场合非常好。 但是总觉得都很复杂,我们文件系统的底层是GlusterFS,在之上建立虚用户,用proftpd和vs-ftpd都感觉复杂。 所以一直在找简单的方法,最后发现了pure-ftpd,很简单!!! 首先建一个无任何登陆权的新用户,注意,uid必须在500以上,不能用系统缺省的用户ftp,后面改pure-ftpd.conf时会有说明: useradd -u1000 -U -s/sbin/nologin -M ftpuser 安装pure-ftpd yum -y install pure-ftpd 修改配置: vi /etc/pure-ftpd/pure-ftpd.conf ChrootEveryone yes AnonymousOnly no NoAnonymous yes PureDB /etc/pure-ftpd/pureftpd.pdb #PAMAuthentication yes UnixAuthentication yes #注意,这里就指出了最小uid,所以第一步建立用户的时候uid不能小于500,否则pure-ftpd无法认证 MinUID 500 CreateHomeDir yes 改完后,我们来增加个用户,注意语法,test是虚拟用户名,-u和-g是虚拟用户对应linux系统的系统用户,就是我们第一步建立的那个无登陆权的ftpuser,-d是home目录,这个不用建,用户第一次登陆的时候pure-ftpd会自动建立: pure-pw useradd test -u ftpuser -g ftpuser -d /var/www/ppp 重建hash pure-pw mkdb 重启pure-ftpd service restart pure-ftpd ok,搞定了,一定要注意uid的问题。其他无复杂的地方。

2024年01月18日 · 1 分钟 · 53 字 · 八戒

GlusterFS的日常应用

基本上搭建glusterfs都是用了2个副本,用来保证数据冗余 建立新卷,/export/test-vol目录不用事先建立,会自动建立的: gluster volume create test-vol replica 2 transport tcp 172.16.8.5:/export/test-vol/ 172.16.8.6:/export/test-vol/ 如上建立新卷后,test-vol的属主是root,如果我们想基于gfs之上做个虚拟的vsftpd,建设用户是virtual.virtual,500.500 设置卷uid/gid属性: gluster volume set test-vol storage.owner-uid 500 gluster volume set test-vol storage.owner-gid 500 设置卷的quota空间配额: gluster volume quota test-vol enable gluster volume quota test-vol limit-usage / 10GB gluster volume quota test-vol limit-usage /path/in/volume 2G gluster volume set test-vol features.quota-timeout 30 gluster volume quota test-vol list gluster volume quota test-vol list /path/in/volume 去掉quota限制: gluster volume quota test-vol remove / gluster volume quota test-Vol remove /path/in/volume 优化tcp参数: gluster volume set test-vol diagnostics.brick-log-level WARNING gluster volume set test-vol diagnostics.client-log-level WARNING gluster volume set test-vol nfs.enable-ino32 on gluster volume set test-vol nfs.addr-namelookup off gluster volume set test-vol nfs.disable on gluster volume set test-vol performance.cache-max-file-size 2MB gluster volume set test-vol performance.cache-refresh-timeout 4 gluster volume set test-vol performance.cache-size 256MB gluster volume set test-vol performance.write-behind-window-size 4M gluster volume set test-vol performance.io-thread-count 32 设置卷访问权限 ...

2024年01月18日 · 1 分钟 · 161 字 · 八戒