Nginx+keepalived做双机热备加tomcat负载均衡


环境说明:

nginx1:192.168.2.47
nginx2:192.168.2.48
tomcat1:192.168.2.49
tomcat2:192.168.2.50
vip:192.168.2.51

一.Nginx配置
1.安装Nginx所需pcre库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz

tar -zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install

2.安装Nginx
wget http://nginx.org/download/nginx-0.8.52.tar.gz

groupadd www
useradd -g www www
tar zxvf nginx-0.8.52.tar.gz
cd nginx-0.8.52/
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_[......]

继续阅读

解决Centos5上升级Python后yum不能用的问题


把Centos5上的Python升级到2.6后,用yum安装东西时提示

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
 
No module named yum
 
Please install a package which provides this module, or
verify that the module is installed correctly.
 
It’s possible that the above module doesn’t match the
current version of Python, which is:
2.6.5 (r265:79063, Jul  2 2010, 16:30:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
&nbsp[......]

继续阅读

解决2个安装keepalived1.2遇到的问题


第一个问题:
vrrp_ndisc.c: In function ‘ndisc_send_unsolicited_na’:
vrrp_ndisc.c:133: error: ‘ETHERTYPE_IPV6′ undeclared (first use in this function)
vrrp_ndisc.c:133: error: (Each undeclared identifier is reported only once
vrrp_ndisc.c:133: error: for each function it appears in.)
make[2]: *** [vrrp_ndisc.o] Error 1
make[2]: Leaving directory `/root/auto/keepalived-1.2.0/keepalived/vrrp’
make[1]: *** [all] Error 1
make[1]: Leaving directory `/root/auto/keepalived-1.2.0/[......]

继续阅读

MySQL 重启后数据出问题导致服务不可用


一台MySQL slave 由于需要把服务重启了一次,用ps -ef  |grep mysql时发现没有进程,看日志发现
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
I[......]

继续阅读

linux命令行连接vpn


本文的vpn server为pptpd.客户端为ubuntu文字模式连接(非图形)

1.安装client

sudo apt-get install pptp-linux

2.连接vpn server

sudo pptpsetup --create pptpd  --server x.x.x.x  --username zhangll   --password  lsanotes  --encrypt --start

注:
–create是创建的连接名称
–server是vpn的ip地址;
–username是用户名
–password是密码,也可以没这个参数,命令稍后会自动询问。这样可以保证账号安全
–encrypt 是表示需要加密,不必指定加密方式,命令会读取配置文件中的加密方式
–start是表示创建连接完后马上连接
(如果不写这个–start参数要连接刚才定义好的vpn只能用 sudo pon lsavpn,断开用sudo poff)

一步步安装MooseFS教程


该文章翻译自http://www.moosefs.org/tl_files/manpageszip/moosefs-step-by-step-tutorial-v.1.1.pdf,由于本人英语水平有限,不当之处请告之谢谢!
概述
MooseFS 在专用机器上的安装过程
Master server 的安装
Backup server(metalogger)的安装
chunk servers 的安装
客户端的安装
单独server上安装MooseFS
MooseFS的基本用法
停止MooseFS
概述
下面我们介绍在Linux平台上一步一步安装MooseFS系统的过程,我们假设系统使用mfs用户运行并且mfs的所属组也为mfs.将要使用FHS(文件系统层次标准)兼容路径和源码mfs-1.6.15.tar.gz并且把它放到/usr/src下. 我们将要说明怎样安装MooseFS系统在不同的专用机上以及怎样在一台服务器上做一个测试安装
MooseFS的最新稳定版下载地址:http://sourceforge.net/projects/moosefs/,并且在客户端你将需要用到FUSE 包,这个[......]

继续阅读

MySQL5.5.4-m3 复制参数问题


在Centos5.4上配置MySQL5.5.4-m3的主从复制时在my.cnf里面设置好主从的参数后,MySQL无法启动,查看/var/log/mysql/mysql_error.log发现
/home/DB/mysql/libexec/mysqld: unknown variable ‘master-host=192.168.3.11′  竟然不认识这个参数?MySQL5.0的一台Slave用这个参数也一直稳定运行.在网上搜索一翻无果,最后只能用手动同步试试去掉/etc/my.cnf里面master-host,master-user这些关于主从配置的参数,启动MySQL,查看日志可以正常启动,进入MySQL后手动执行
mysql> CHANGE MASTER TO
-> MASTER_HOST='master_host_name',
-> MASTER_USER='replication_user_name',
-> MASTER_PASSWORD='replication_passwor[......]

继续阅读

Centos5.4下Moosefs从1.6.13升级到1.6.15


1.6.13版本的安装配置参见
http://www.lsanotes.cn/centos_mfs_1_6_13
升级步骤非常简单官方站也给出了大致步骤
http://www.moosefs.org/mini-howtos.html
1.6.15修复的bugs:
We released a new stable version 1.6.15. This is a maintenance release which includes these changes:
·(daemons) fixed “double free” error
·(metarestore) fixed bugs in “REPAIR” and “SNAPSHOT” entries
·(master) fixed bug in “snapshot” command (“mfsmakesnapshot dir dir/” caused master to hung-up)
·(master) preserving atime and mtime during “snapshot” operation (makes “[......]

继续阅读

Perl单行脚本显示历史命令使用频率


在网上看到这个脚本感觉很不错,记录一下:

history | perl -F"\||<\(|;|\`|\\$\(" -alne 'foreach (@F) { print $1 if /\b((?!do)[a-z]+)\b/i }' | sort | uniq -c | sort -nr
 7 sort
 6 ls
 5 history
 5 clear
 4 uniq
 4 perl
 3 telnet
 3 head
 3 cd
 3 alne
 2 pwd
 1 cat

Perl用Web::Scraper的Xpath方法采集数据放入MySQL


采集新浪一小块新闻的标题.url.内容,并存入MySQL数据库,多谢一位兄弟的帮忙才得以完成.速度还不是很理想,下一步看看能不能用上多线程.一步步提高自己的Perl水平.

#!/usr/bin/perl
use warnings;
use URI;
use Web::Scraper;
use utf8;
binmode(STDIN, ‘:encoding(utf8)’);
binmode(STDOUT, ‘:encoding(utf8)’);
binmode(STDERR, ‘:encoding(utf8)’);
use DBI;
use strict;
my $user = "root";
my $passwd = "123456";
my $data_source = "dbi:mysql:tes20";
my $dbh = DBI->connect($data_source,$user,$passwd, {RaiseError => 1[......]

继续阅读