一、安裝python
1、下載Python-3.6.7.tgz的安裝文件
2、拷貝到linux usr/local/src
3、tar -zxvf Python-3.6.7.tgz 解壓
4、cd Python-3.6.7
5、 ./configure --prefix=/usr/local/python36 --with-ssl
6、make 編譯二進制文件
7、make install
可能遇到的問題:
報錯:zipimport.ZipImportError: can’t decompress data
執行:yum -y install zlib*
再make install就行了
參考博客:https://blog.csdn.net/u014749862/article/details/54430022
到python bin目錄“配置環境變量”
8、export PATH=/usr/local/python36/bin:$PATH;
配好之後在哪個目錄都能使用python命令了
python3 -V
查看安裝的python版本
9、創建虛擬環境
10、進入到python_locust 的bin目錄執行source activate打開虛擬環境
二、安裝locust pip install locust
A:出現問題: locations that require TLS/SSL
查看openssl安裝包,發現缺少openssl-devel包
[root@localhost ~]# rpm -aq|grep openssl
openssl-0.9.8e-20.el5
openssl-0.9.8e-20.el5
[root@localhost ~]#
yum安裝openssl-devel
[root@localhost ~]# yum install openssl-devel -y
查看安裝結果
[root@localhost ~]# rpm -aq|grep openssl
openssl-0.9.8e-26.el5_9.1
openssl-0.9.8e-26.el5_9.1
openssl-devel-0.9.8e-26.el5_9.1
openssl-devel-0.9.8e-26.el5_9.1
重新對python3.6進行編譯安裝:
./configure --with-ssl
make
make install
B: pip install locust安裝報錯 ConnectTimeoutError錯誤:
解決方法:pip install locust -i https://pypi.douban.com/simple 即可
3、運行locust 腳本
4、主機瀏覽器中輸入地址:http://192.168.195.130:8089/
if網址打不開,關閉虛擬機防火牆,再刷新:
進入etc文件夾
[root@localhost etc]# systemctl stop firewalld.service
[root@localhost etc]# systemctl start firewalld.service
最終在windows系統上看到效果