日期:2014-05-16 浏览次数:20919 次
两台测试机192.168.0.182和192.168.0.183,root账号登陆,centos系统
1.分别配置hostname:
vi /etc/sysconfig/network
两台分别配置 HOSTNAME=centos-182 和 HOSTNAME=centos-183
2.分别配置本地host解析:
vi /etc/hosts 两台配置一样内容
192.168.0.182 centos-182
192.168.0.183 centos-183
3.分别配置ssh免密码登陆:
ssh-keygen,输出内容直接三个回车,在/root/.ssh/目录下生成id_rsa和id_rsa.pub
cat id_rsa.pub >> authorized_keys
在192.168.0.183上执行
ssh-keygen,输出内容直接三个回车,在/root/.ssh/目录下生成id_rsa和id_rsa.pub
scp id_rsa.pub root@192.168.0.182:/root/.ssh/
在192.168.0.182的/root/.ssh/下
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
再将authorized_keys文件scp到192.168.0.183上
scp authorized_keys root@192.168.0.183:/root/.ssh/
4.分别配置known_hosts:
在192.168.0.182和192.168.0.183上分别执行ssh centos-182 和 ssh centos-183,出现类似以下内容,输入yes之后回车
The authenticity of host 'centos-182 (192.168.0.182)' can't be established. RSA key fingerprint is 75:93:cd:ba:d3:d4:5a:70:8c:dd:4c:11:43:fe:b4:00. Are you sure you want to continue connecting (yes/no)? yes?
配置成功之后,在两台机子上分别执行ssh centos-182 和 ssh centos-183,可以不用输入密码登陆上去说明配置成功。
5.在192.168.0.183上安装MySQL数据库,具体可以参见http://willvvv.iteye.com/blog/1460568
6.在192.168.0.182上安装tsung,具体可以参见http://willvvv.iteye.com/blog/1469324
7.在192.168.0.182上编写tsung脚本,进行测试
mkdir -p /root/.tsung
cd /root/.tsung
vi tsung.xml
<?xml version="1.0"?> <!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd"> <tsung loglevel="debug" dumptraffic="true"> <clients> <client host="localhost" use_controller_vm="true"/> </clients> <!-- Server side setup --> <servers> <server host="centos-183" port="3306" type="tcp"/> </servers> <monitoring> <monitor host="centos-183"/> </monitoring> <load> <arrivalphase phase="1" duration="1" unit="minute"> <users interarrival="3" unit="second"></users> </arrivalphase> </load> <sessions> <session probability="100" name="mysql-example" type="ts_mysql"> <request> <mysql type="connect" /> </request> <request> <mysql type="authenticate" database="yourdb" username="youruser" password="yourpassword" /> </request> <request> <mysql type="sql">SHOW TABLES</mysql> </request> <request> <mysql type="sql">SELECT * FROM yourtable</mysql> </request> <request> <mysql type="close"></mysql> </request> </session> </sessions> </tsung>?
注意:<server host="centos-183" port="3306" type="tcp"/> 和 <monitor host="centos-183"/> host属性需要填写配置的host而不是IP或者localhost
不然就会出现Host key verification failed
tsung start
8.在192.168.0.183上执行tcpdump查看sql执行情况
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings
?
9.执行完毕使用http://willvvv.iteye.com/blog/1469324上python启动web server直接看图形,注意iptables要开启8000端口
?