最近升级到macOS Catalina 10.15, Python 3.8.0后安装Pillow出现以下错误,费了一番功夫才碰巧解决了,特别记录一下。
$ pip install Pillow
Collecting Pillow
Using cached https://files.pythonhosted.org/packages/87/dc/7597336c48796d4a836007460148b7baf7f278ad42b73d49047eb0e8194c/Pillow-6.2.0.tar.gz
Installing collected packages: Pillow
Running setup.py install for Pillow ... error
...
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
...
根据提示安装zlib
$ brew install zlib
Warning: zlib 1.2.11 is already installed and up-to-date
To reinstall 1.2.11, run `brew reinstall zlib`
再链接zlib
$ brew link zlib --force
Warning: Refusing to link macOS-provided software: zlib
For compilers to find zlib you may need to set:
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
For pkg-config to find zlib you may need to set:
expor
最近用到几个不算常用的Docker命令,记录下来备忘参考。
更新容器配置
docker update [OPTIONS] CONTAINER [CONTAINER...]
主要是在忘记 --restart=always 时用:
docker update --restart=always container
修改容器名称
docker rename old_container_name new_container_name
主要是在升级容器时用:
docker pull new_image docker stop container docker rename container old_container docker run -d --volumes-from old_container --name container new_image
从容器复制文件到主机
docker cp <containerId>:/file/path/within/container /host/path/target
主要是在需要把容器里的数据拷贝出来放到挂载卷上时用。
参考:
https://docs.docker.com/engine/reference/commandline/docker/
最近升级ELK到7.3.0版遇到 "Kibana server is not ready yet" 一直打不开的问题,重启也解决不了问题。
查日志首先发现Kibana升级后要求所有Elastisearch节点都要升级到同一版本。按要求升级所有Elastisearch节点到7.3.0版后问题还没解决。
重启Kibana再查看日志发现以下报错信息:
"Another Kibana instance appears to be migrating the index. Waiting for that migration to complete. If no other Kibana instance is attempting migrations, you can get past this message by deleting index .kibana_3 and restarting Kibana."
看来要把没完成迁移所遗留的.kibana_* index删除掉(后面的数字可能不同):
curl -XDELETE 'http://localhost:9200/.kibana_3' --header "contentent-type: application/JSON"
检查:
curl -XGET localhost:9200/.kibana_3
重启:
systemctl restart kibana
终于正常打开了。
后记:
偶然出现以下错误:
[circuit_breaking_exception] [parent] Data too large, data for [<http_request>] would be [3959585884/3.6gb], which is larger than the limit of [3944244838/3.6gb]...
原因:字段缓存不够。
解决办法:设置字段缓存,比例根据需要调整,如下:
curl -XPUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d '{ "persistent" : { "indices.breaker.fielddata.limit" : "40%" } }'
后记:
Elastic
1. 在CentOS 7上安装
https://www.postgresql.org/download/linux/redhat/
安装yum repo RPM:
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
安装客户端:
yum install postgresql11
安装服务端:
yum install postgresql11-server
初始化数据库并设置开机启动服务
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
2. 调整配置
2.1 允许外部连接
cd /var/lib/pgsql/11/data
vim postgresql.conf
#listen_addresses = 'localhost'
listen_addresses = '*'
vim pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
systemctl restart postgresql-11
2.2 防火墙放开5432端口
sudo firewall-cmd --zone=public --add-port=5432/tcp
3. 设置密码
sudo -u postgres psql postgres # \password postgres Enter new password:
OK!
最近CentOS7系统盘容量不足,需要把docker工作目录从 /var/lib/docker 迁移到 /home/docker。
首先修改 /lib/systemd/system/docker.service:
vim /lib/systemd/system/docker.service
找到命令启动行
ExecStart=/usr/bin/docker daemon -H fd://
修改为
ExecStart=/usr/bin/docker daemon -g /home/docker -H fd://
注意:每次更新Docker需要更新以上配置
然后停止Docker服务, 更新系统服务配置,创建/home/docker目录,把旧文件从 /var/lib/docker 拷贝到 /home/docker (注意这一步需要的时间比较长)。
systemctl stop docker systemctl daemon-reload mkdir /home/docker rsync -aqxP /var/lib/docker/ /home/docker systemctl start docker ps aux | grep -i docker | grep -v grep
最后重新启动docker服务,并检查, OK!
最近升级Elasticsearch时遇到了“此时不应有 \Common“的错误。
查Windows系统的环境变量 PATH 的设置, 发现Java的执行环境有两处,删掉第一个路径名里带空格的问题就解决了。
我们的开发服务器是在裸机上安装的CentOS 7,最近更新后开机不引导出现如下报错:
Invalid Parameters
修复办法:
用CentOS 7安装盘(U盘)启动后选择进入RESCUE模式,根据提示选择把原文件系统按读写权限安装到/mnt/sysimage后:
cd /mnt/sysimage cd boot/efi/EFI/centos cp grubx64.efi shimx64.efi reboot
系统正常启动
参考:
https://blog.uncooperative.org/blog/2014/02/06/the-efi-system-partition/
经常需要用命令行根据文件内容查找文件,做一个alias方便使用:
alias findx="find . -type f -print | xargs grep"
可以在~/.bash_profile文件里添加以上内容。
使用方式:
进入目标目录后:
findx "example"
会在当前目录及其子目录查找内容包含”example"的文件。
6.2及之前的版本使用x-pack需要申请license,基本版免费。
https://license.elastic.co/registration/
通过注册邮箱收到license文件下载链接,下载license文件后参考以下更新license。
https://www.elastic.co/guide/en/elasticsearch/reference/6.2/update-license.html
curl -XPUT -u <user> 'http://<host>:<port>/_xpack/license' -H "Content-Type: application/json" -d @license.json
注意!使用curl更新license时注意license文件名前冠一个@, 否则会有json解释错误。
Pypy3.5 v6.0在2018年4月26日发布了,我在MacBook上试用一下,效果还不错 :-)
首先安装并配置虚拟环境:
brew install pypy3 pypy3 -m venv pypy3 source pypy3/bin/activate
重新安装项目需要的依赖:
pip install -r requirements.txt
结果发现Pillow报错:
RequiredDependencyException:
The headers or library files could not be found for jpeg, a required dependency when compiling Pillow from source.
Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html
按Pillow官网的建议重新安装Pillow的依赖:
brew install libtiff libjpeg webp little-cms2 pip install pillow
问题解决了。
另:CentOS7上需要在官网下载pypy的安装包,解压后设置虚拟环境。同样,安装Pillow报错,需要提前单独安装Pillow的依赖:
sudo yum install libtiff-devel libjpeg-devel zlib-devel freetype-devel \ lcms2-devel libwebp-devel tcl-devel tk-devel libraqm-devel \ libimagequant-devel
后记:
pypy3.6 v7.2 稳定版已于2019年10月14日发布,兼容Python 3.6.9: https://morepypy.blogspot.com/2019/10/pypy-v72-released.html
参考:
PYPY官网:https://pypy.org/download.html
PILLOW官网:https://pillow.readthedocs.io/en/latest/installation.htm