运维片段 - 奇谭世界 热衷开源 拥抱LINUX 不过空幻

Nginx+Keepalived双机互备搭建文档

  一、目的 搭建nginx+keepalived双机互备,实现nginx服务器的高可用性,实现故障自动切换。 二、环境 Nginx1 (Master) OS: CentOS 6.2 Minimal HOSTNAME: nginx1.catjia.com IP: eth0 172.16.51.9 Nginx2 (Backup) OS: CentOS 6.2 Minimal HOSTNAME: nginx2.catjia.com IP: eth0 172.16.51.7 VIP (Virtual IP) : 172.16.51. 三、搭建 源码包存放位置:/usr/local/src 获取软件包 Nginx 1.2.1 # cd /usr/local/src # wget http://nginx.org/download/nginx-1.2.1.tar.gz   Keepalived 1.2.2 # wget http://keepalived.org/software/keepalived-1.2.2.tar.gz   编译安装nginx 1、在主备机上都安装nginx # yum install make aotumake gcc gcc-c++ pcre pcre-devel openssl openssl-devel # useradd www -s /sbin/nologin # tar xf nginx-1.2.1.t…

Read More

django+bootstrap运维平台

一直想写个运维平台,无奈前端太差(虽然也不懂开发语言),所以没实现。。 还好有不少人共享了各种各样的平台,其中就有OMS运维平台,所以自己拿来捣鼓,根据自己的需求,也算是写了点东西出来(批量管理、文件管理等),再用docker部署来玩玩 (PS:python太差,也没点开发思维,就只能自己玩玩先,看看有哪些bug需要修复,然后视乎原作者的意愿再决定是否公开) 在这里先展示一下效果图     OMS平台开源项目主页:https://github.com/binbin91/oms

Shell脚本的乐趣–linux遍历目录及其子目录下的所有文件

shell脚本太强大了,接触到的始终是冰山的冰山一角。。 今天记录一个遍历目录下的所有子目录及其文件的脚本。 12345678910111213141516171819202122232425#!/bin/sh read -p "Input Path:" SPATH FILELIST() { filelist=`ls $SPATH` for filename in $filelist; do if [ -f $filename ];then echo File: $filename elif [ -d $filename ];then #echo Directory: $filename cd $filename SPATH=`pwd` echo $SPATH FILELIST cd .. else echo "$SPATH/$filename is not a common file." fi done } cd $SPATH FILELIST echo "Done." 通过定义一个函数实现目录及其子目录的遍历。。

How to install Debian Squeeze on Buffalo LS-WXL

This guide(a Work In Progress) will explain how to install Debian GNU/Linux “Squeeze” on the LinkStation™ Duo LS-WXL using the Debian “debootstrap” procedure. The original kernel will be preserved, as well as the original bootloader (U-Boot). This Procedure is based on the Lenny procedure of the same name and is offered here as all the procedures for installing Squeeze on the LS-WXL led to an eventual endless reboot cycle. As the “lenny” procedure installs a squeeze kernel in any case and the lenny procedure produces a sane machine I just altered it by the change of the bootstrap fetched and the a…

Read More

Debian Squeeze on Buffalo ‘V’ and ‘X’ Series (LS-WXL and others)

Credits This is based on Debian Lenny on LS-CHLv2 and Open Stock Firmware LS-XHL and was published first here [1] by user benoqkuke. What will you get? You will not have to open your box (at least not unless you make a fatal mistake)! You will have a Debian Squeeze userland and the stock Buffalo kernel of your already installed firmware. So it is not a full replacement of Buffalos firmware, but mostly. ;-) To have a “complete” Debian Squeeze installation one would need to replace the kernel also. But user benoqkuke hasn’t managed to build his own kernel (newer than 2.6.31) yet. So stay tuned, if you want to have a …

Read More

Buffalo LS-WXL系列固件(获取SSH权限、安装ipkg及optware)

LinkStation Duo (LS-WXL) Variants 1.0TB LS-WX1.0TL/R1 2.0TB LS-WX2.0TL/R1 4.0TB LS-WX4.0TL/R1 Commercial description LS-WXL : LinkStation™ Duo @ BUFFALO The LinkStation™ Duo is a high performance, multimedia, shared RAID network storage solution for the home and small office that requires a central location to share data files, photos, video and music. The unit is a two drive NAS solution that can be configured in RAID 0 for performance or RAID 1 for redundant storage. In addition to the storage capabilities, stream multimedia to a PC, a Mac, a Buffalo™ LinkTheater™ and other DLNA CERTIFIED™ or UPNP media player, as well as sharing …

Read More

[Solved]LinkStation Duo LS-WXL/R1 restarts itself and Install Debian on LS WXL

最近把手里的buffalo ls-wxl 升级到firmware1.68,root权限自然是没了,想着再按照以前的方法修改root密码来通过ssh登录 (链接:http://nas1.cn/thread-12247-1-1.html) 但是修改版固件版本都比较低,不刷修改版固件又获取root失败。 没办法,又谷歌其它方法,找到了一个间接获取root密码的方法 (链接:http://buffalo.nas-central.org/wiki/Category:LS-WXL#Method_2) 原文如下: LinkStation Duo (LS-WXL) Variants 1.0TB LS-WX1.0TL/R1 2.0TB LS-WX2.0TL/R1 4.0TB LS-WX4.0TL/R1 Commercial description LS-WXL : LinkStation™ Duo @ BUFFALO The LinkStation™ Duo is a high performance, multimedia, shared RAID network storage solution for the home and small office that requires a central location to share data files, photos, video and music. The unit is a two drive NAS solu…

Read More

Shell脚本的乐趣 – 批量创建数据库

#!/bin/sh for i in `ls *.sql` do echo ${i%.*} mysql -uroot -ppasswd -n <<EOF create database ${i%.*} default character set utf8; flush privileges; quit EOF mysql -uroot -ppasswd ${i%.*} < $i done 假如有n个数据库需要创建,这时肯定不可能一个一个的手动创建,用脚本来批量创建数据库的效率可想而知。 假如目录a下有a.sql b.sql c.sql …等数据库需要创建并同时导入数据,那么在当前目录下新建个create_sql.sh,内容如上所示,然后执行即可。 但是这个脚本不仅仅只用来批量创建数据库,for i in `ls`;do done;语句的用途可大着。 比如要批量去掉后缀 for i in `ls *.sql` do mv $i ${i%.*} done 批量重命名 for i in `ls *.sql` do mv $i ${i%.*}.bak done 嗯,这个脚本还是挺不错的。。

centos6一键安装pptp vpn脚本

This script will auto install PPTP VPN on CentOS 6 32bit. Before run this script, you need to make sure PPP is enabled on your VPS/Dedicated Server. This script has been tested on OpenVZ VPS with 128mb memory. Check if PPP module is enable. cat /dev/ppp If you receive this message, PPP module is enable. cat:/dev/ppp:No such device or address wget http://www.rockia.com/dl/pptpd6.sh chmod +x pptpd6.sh ./pptpd6.sh edit VPN username and password vim /etc/ppp/chap-secrets   if you got those errors after installation: iptables:Saving firewall rules to /etc/sysconfig/iptables:/etc/init.d/iptables: line 274: restorecon: command not fou…

Read More

Discuz X2.5论坛迁移服务器

论坛采用Discux x2.5搭建,现转移服务器,有几个配置文件需要注意的,故记录于此。 从旧服务器上备份网站文件及数据库文件后,通过scp到新服务器,解压网站文件及导入数据库数据后,由于数据库名和密码都改变了,所以在这里需要相对应的修改几个文件 1. config/config_global.php 2. config/config_ucenter.php 3. uc_server/data/config_inc.php 这里还有一点需要修改的,如果忽略则会报如下错误 UCenter info:MySQL Query Error SQL:SELECT VALUE FROM [Table]vars WHERE name=’noteexists1’ Error:SELECT command denied to user ’***’@’localhost’for table ’pre_ucenter_var Errno:1142 找到config_ucenter.php里的UC_DBTABLEPRE 完整如下: define(‘UC_DBTABLEPRE’, ‘`datadb`.pre_ucenter_’); 将datadb修改为对应的数据库名即可。

shell及awk统计日志中相同ip的访问次数

现有一日志,需要统计出每个ip访问的次数 113.110.176.131 – - [03/Jul/2013:11:59:15 +0800] GET /zycf/ HTTP/1.1 200 19157 – Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 – 113.110.176.131 – - [03/Jul/2013:11:59:16 +0800] GET /zycf/statics/style.css HTTP/1.1 304 0 http://demo.catjia.com/zycf/ Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 – 113.110.176.131 – - [03/Jul/2013:11:59:16 +0800] GET /zycf/statics/script/tools.js HTTP/1.1 304 0 http://demo.catjia.com/zycf/ Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 – 113.110.176.131 – - [03/Jul/2013:11:59:16 +0800] GET /zycf/static…

Read More