分类 默认分类 下的文章

解决python pip 安装报语法错误sys.stderr.write(f“ERROR: {exc}“)

https://bootstrap.pypa.io/ 下载相应python版本的 get-pip.py 文件

wget https://bootstrap.pypa.io/2.7/get-pip.py
python get-pip.py

安装成功:Successfully installed pip-20.3.4 wheel-0.36.2

再运行我想要的bt系统,结果报错了

# bt start
Starting Bt-Panel... failed
------------------------------------------------------
Traceback (most recent call last):
  File "main.py", line 16, in <module>
    import sys,web,io,os
ImportError: No module named web
------------------------------------------------------
Error: BT-Panel service startup failed.

原因是web.py模块没有安装,用pip安装试试, 还是报错,不过这次是不一样的错误,原因是6.10的系统2.7的python需要安装指定版本的web.py

pip install web.py==0.51

结果成功,bt也成功运行起了

PS:测试环境 centos 6.10, python 2.7

安装脚本setuptools:

wget https://bootstrap.pypa.io/ez_setup.py -O - | python

一. 透明代理(Transparent Proxies) 目标服务器能够检测到真实的源IP。
使用透明代理,对方服务器可以知道你使用了代理,并且也知道你的真实IP。透明代理访问对方服务器所带的HTTP头信息如下:

REMOTE_ADDR = 代理服务器IP
HTTP_VIA = 代理服务器IP
HTTP_X_FORWARDED_FOR = 你的真实IP              

透明代理还是将你的真实IP发送给了对方服务器,因此无法达到隐藏身份的目的。
二. (普通)匿名代理(Anonymous Proxies)目标服务器无法检测到真实的源IP,但能够检测到使用了代理。
匿名代理访问对方服务器所带的HTTP头信息如下:

REMOTE_ADDR = 代理服务器IP
HTTP_VIA = 代理服务器IP
HTTP_X_FORWARDED_FOR = 代理服务器IP              

匿名代理隐藏了你的真实IP,但是向访问对象透露了你是使用代理服务器访问他们的。

三. 高匿名代理(High Anonymity Proxies -Elite proxies) 目标服务器无法检测到你在是使用代理。
高匿名代理访问对方服务器所带的HTTP头信息如下:

REMOTE_ADDR = 代理服务器IP
HTTP_VIA 不显示
HTTP_X_FORWARDED_FOR 不显示              

高匿名代理隐藏了你的真实IP,同时访问对象也不知道你使用了代理,因此隐蔽度最高。

squid搭建高匿名代理服务: https://www.jianshu.com/p/96c8f1f7fd17

查看系统版本:

cat /etc/redhat-release
uname -a 

centos8安装zabbix-agent:

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
dnf install zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agent

centos7安装zabbix-agent:

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
yum install -y zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agent

centos6安装zabbix-agent:

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/6/x86_64/zabbix-release-5.0-1.el6.noarch.rpm
yum clean all
yum install -y zabbix-agent
service zabbix-agent restart
chkconfig --level 35 zabbix-agent on

如果使用yum出现repomd.xml 404, 可以先备份一下yum的源配置文件,再恢复成centos官网yum源

cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.`date +%Y%m%d%H%I%S`
curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo
mv epel.repo epel.repo.`date +%Y%m%d%H%I%S`
curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo
yum makecache

修改zabbix-agent配置文件:
vim /etc/zabbix/zabbix_agentd.conf

LogFileSize=50
Server=172.19.0.16
ListenIP=172.19.0.9 #客户端IP
ServerActive=172.19.0.16:10051
Hostname=sem

BT面板安全设置里面,开放端口:10050 zabbix-agent

BT服务器,需要将mysqladmin命令添加到全局

ln -s /www/server/mysql/bin/mysqladmin /usr/bin/

添加数据库监控账号及授权:

mysql -uroot -p

CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '<password>';
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zabbix'@'localhost';
flush privileges;

===mysql config:
mkdir /var/lib/zabbix
vim /var/lib/zabbix/.my.cnf

[client]
user=zabbix
password=saYdX5G2FJs2iEMZ
socket=/tmp/mysql.sock

修改数据库配置的访问权限(新版mysql要求,不然进不了数据库):
chmod 644 /var/lib/zabbix/.my.cnf

===test数据库配置是否可用,能成功进入即可:
mysql --defaults-file=/var/lib/zabbix/.my.cnf

添加mysql模板(参考配置)到配置目录:
下载地址:
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent/template_db_mysql.conf
放到这个路径:
vim /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf
template_db_mysql.conf参考内容:

#template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2
#For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default) 
#For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
#The file must have three strings:
#[client]
#user='zbx_monitor'
#password='<password>'
#
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"

nginx php-fpm监控:
vhost/phpfpm_status.conf (修改 phpfpm_56_status、fastcgi_pass 127.0.0.1:9000)

server {

        listen 80;
        server_name 127.0.0.1;
        allow 127.0.0.1;
        location /nginx_status {
                stub_status on;
                access_log off;
        }

        location /phpfpm_56_status {
                fastcgi_pass unix:/tmp/php-cgi.sock;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
        }

}

php-fpm配置:

pm.status_path = /phpfpm_54_status

我测试的是利用两台机器 ,一台做socks5服务端,一台做客户端,然后利用在客户端机器 利用 Privoxy 将 socks5代理转为http代理,并向外提供服务

安装配置 Shadowsocks Server 端(ssserver)
Shadowsocks 是用 Python 编写的,因此可以通过如下命令直接安装(sslocal 和 ssserver 均已安装):

sudo pip install shadowsocks

接下来编写 Shadowsocks Server 端的配置文件,配置监听端口,加密方式,密码等,新建 /etc/shadowsocks-server.json 文件,填入如下内容:

{
    "server": "0.0.0.0", 
    "server_port": 1851, # SS Server 端口
    "local_address": "127.0.0.1", #SS Local 端配置,不影响Server端使用
    "local_port": 1080,  #SS Local 端配置,不影响Server端使用
    "password": "xxxxx",
    "timeout": 300,
    "method": "aes-256-cfb",
    "fast_open": false
}

使用配置文件启动 SS Server:

ssserver -c /etc/shadowsocks-server.json -d start

安装配置 Shadowsocks 客户端(sslocal)
第一步已将 SS Server 安装并配置完成,服务端口为 1851,接下来在需要安装 http 代理的机器上安装配置 shadowsocks 客户端,安装方法和第一步一样:

sudo pip install shadowsocks

编写 SS Local 客户端配置文件,配置远程连接 SS Server 的 IP,端口,密码,加密方式等,新建 /etc/shadowsocks-client.json 文件,填入如下内容:

{
    "server": "xxx.xxx.xxx.xxx", # SS Server 端服务器公网 IP
    "server_port": 1851, # SS Server 端口
    "local_address": "127.0.0.1", # SS Local 本地监听 IP
    "local_port": 1080, # SS Local 本地监听端口
    "password": "xxxxxx",
    "timeout": 300,
    "method": "aes-256-cfb",
    "fast_open": false
}

使用配置文件启动 SS Local:

sslocal -c /etc/shadowsocks-client.json -d start

若报ERROR already started at pid xxx错误,则使用如下命令启动

nohup sslocal -c /etc/shadowsocks-client.json start &

配置示例
/etc/shadowsocks-server.json

{
  "server": "0.0.0.0",
  "server_port": 8688,
  "password": "123456",
  "timeout": 300,
  "method": "rc4-md5",
  "fast_open": false,
  "workers": 1
}

/etc/shadowsocks-client.json

{
    "server": "127.0.0.1",
    "server_port": 8688,
    "local_address": "127.0.0.1",
    "local_port": 1080,
    "password": "123456",
    "timeout": 300,
    "method": "rc4-md5",
    "fast_open": false
}

安装并配置 Privoxy
Privoxy 是一款代理软件,我们这里用该代理软件实现 HTTP 到 Socks5 的转换,所有来自 Privoxy 的请求被转发到 SS Local,从而实现了一个 HTTP 代理服务,Privoxy 的安装非常简单,直接 yum 一键搞定:

sudo yum install privoxy

编辑 Privoxy 配置文件 /etc/privoxy/config,搜索关键字 listen-address 找到这一句,改成

listen-address 0.0.0.0:8118

表示该代理可以对外访问。
接下来在该配置该文件末尾添加 HTTP 请求转发到 SS Local Socks5 的配置:

forward-socks5t / 127.0.0.1:1080 .

forward-socks5t: 表示 Privoxy 转发请求到 Socks5 协议
127.0.0.1: 第二步中启动 SS Local 本地绑定 IP
1080: 第二步中启动 SS Local 本地监听端口
启动 Privoxy:

systemctl restart privoxy
systemctl enable privoxy

测试代理是否可用

curl -x privoxy_ip:8118 https://www.google.com