Rootop 服务器运维与web架构

2018-06-20
发表者 Venus
WebDriverException: Message: unknown error: call function result missing ‘value’已关闭评论

WebDriverException: Message: unknown error: call function result missing ‘value’

python + selenium + chrome 模拟操作

WebDriverException: Message: unknown error: call function result missing ‘value’

出现此错误一般是chrome浏览器版本更新了,但是chromeDriver的版本过低导致。升级chromeDriver版本即可解决。

chromeDriver下载地址:https://sites.google.com/a/chromium.org/chromedriver/downloads
更新原先 chromedriver.exe 文件,我这里更新 C:\Windows\System32\chromedriver.exe 下再次运行解决。

2018-05-24
发表者 Venus
etcd+confd+nginx实现服务注册及自动发现已关闭评论

etcd+confd+nginx实现服务注册及自动发现

etcd:etcd是一个高可用的键值存储系统,主要用于共享配置和服务发现。
confd:confd是一个配置管理工具。通过查询etcd,结合配置模板引擎生成正式配置文件,同时具备定期探测机制(根据参数手动指定间隔秒数)来生成新的配置,配置变更自动重载。

# 安装 etcd 单机版,直接github下载二进制版本即可运行。

nohup etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 > etcd.log &

# 安装 confd 直接github下载二进制版
# 创建配置文件目录及模板目录

mkdir -p /etc/confd/{conf.d,templates}

# 配置文件内容,注意后缀名

[root@localhost confd]# cat conf.d/test2.toml
[template]
src = "nginx2.conf.tpl"
dest = "/tmp/nginx2.conf"
keys = [
 "/myapp/web/nginx2/user",
 "/myapp/web/nginx2/root",
 "/myapp/web/nginx2/upstream"
]

check_cmd = "/usr/sbin/nginx -t -c {{.dest}}"
reload_cmd = "/usr/sbin/nginx -s reload"

如果有多个,可以写多个 [template]

注释:
src 模板文件路径
dest 生成的配置文件路径
keys 去etcd抓取的key
check_cmd 可以检测配置文件是否有问题
reload_cmd 是检测成功才执行的命令

# 模板文件内容

aaa
bbb
ccc
user = {{getv "/myapp/web/nginx2/user"}}
root = {{getv "/myapp/web/nginx2/root"}}
ddd
eee

upstream aaa {
 {{range getvs "/myapp/web/nginx2/upstream/*"}}
 server {{.}}
 {{end}}
}

#这里随便写了点东西测试效果
这样通过读src的模板路径,生成到dest路径下,根据定义的keys去etcd抓取回来后,赋值给模板中。
可以看到有getv和getvs,前面是抓取单个key,getvs是批量抓取,根据定义的前缀(key的前缀)循环写入模板。(比如nginx的upstream会用到多个server)

# 往 etcd 中添加key

etcdctl set /myapp/web/nginx2/user www
etcdctl set /myapp/web/nginx2/root /home/www2
etcdctl set /myapp/web/nginx2/upstream/s1 1.1.1.1:80
etcdctl set /myapp/web/nginx2/upstream/s1 1.1.1.2:80
etcdctl set /myapp/web/nginx2/upstream/s1 1.1.1.3:80

# 运行 confd ,每隔1秒抓取一次etcd

confd -interval=1 -backend etcd -node http://192.168.10.64:2379

# 运行 confd ,单次

confd -onetime -backend etcd -node http://192.168.10.64:2379

# 查看生成结果

[root@localhost ~]# cat /tmp/nginx2.conf
aaa
bbb
ccc
user = www
root = /home/www2
ddd
eee

upstream aaa {

 server 1.1.1.2:80

 server 1.1.1.3:80

 server 1.1.1.3:80

}

这样就自动生成想要的配置文件了。

2018-05-22
发表者 Venus
windows远程桌面提示 CredSSP加密Oracle修正 问题已关闭评论

windows远程桌面提示 CredSSP加密Oracle修正 问题

win10远程连接server2008提示出现错误:
出现身份验证错误
要求的函数不受支持
这可能是由于 CredSSP加密Oracle修正
原因可能是win10更新以后出现的,版本大都是 Microsoft Windows [Version 10.0.17134.48] 这个版本。

解决方法一,修改组策略,但是家庭版win10还打不开组策略,可能有其它方法调出来,这里不用这个方法。
本地组策略:
计算机配置>管理模板>系统>凭据分配>加密Oracle修正
选择启用并选择易受攻击。

解决方法二,修改注册表。保存以下内容为 .reg 文件,导入注册表。

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters]
"AllowEncryptionOracle"=dword:00000002

再次连接即可。

2018-05-09
发表者 Venus
mysql打开普通日志已关闭评论

mysql打开普通日志

打开普通日志 general_log 可以记录所有类型的sql语句,但是比较耗磁盘空间及IO资源,所以一般只开启错误日志。
在排查问题时才打开此功能。

# 查看general_log开关状态

SHOW VARIABLES LIKE '%general%';

会返回两条数据,一个是开关状态,一个是日志路径。
general_log # 状态,ON开启,OFF关闭
general_log_file # 日志路径

# 临时打开general_log日志

SET GLOBAL general_log='ON';

# 关闭

SET GLOBAL general_log='OFF';

 

2018-04-28
发表者 Venus
python版本问题导致pip install出现证书错误问题已关闭评论

python版本问题导致pip install出现证书错误问题

在python下执行pip install,报错:

$ ./pip install pyopenssl ndg-httpsclient pyasn1
Collecting pyopenssl
Could not fetch URL https://pypi.python.org/simple/pyopenssl/: There was a problem confirming the ssl certificate: [Errno 1] _ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_H ELLO:tlsv1 alert protocol version – skipping
C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name In dication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This preven ts urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https: //urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not find a version that satisfies the requirement pyopenssl (from versions: )
No matching distribution found for pyopenssl
C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This preven ts urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https: //urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning

alading@venus MINGW64 /c/Python27/Scripts

最后查原因是python版本低了,老版本中的tls 1.0版本ssl不再支持,需要更新python2.7到最后一个版本。这里更新到python 2.7.14 解决。
$ ./pip.exe install redis
Collecting redis
Downloading https://files.pythonhosted.org/packages/3b/f6/7a76333cf0b9251ecf49efff635015171843d9b977e4ffcf59f9c4428052/redis-2.10.6-py2.py3-none-any.whl (64kB)
Installing collected packages: redis
Successfully installed redis-2.10.6
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.