Python压缩指定路径中的目录并删除
压缩指定路径中的目录,压缩完成后删除该目录。
import os
import zipfile
import shutil
dirname = '/opt/backup/seeyon_logs/'
listdir = os.listdir(dirname)
def compress_directory(directory_path, output_path):
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk(directory_path):
for file in files:
file_path = os.path.join(root, file)
zipf.write(file_path, arcname=os.path.relpath(file_path, directory_path))
def delete_directory(path):
if os.path.exists(path):
shutil.rmtree(path)
for file in listdir:
if os.path.isdir(dirname+file):
compress_directory(dirname+file, '/opt/backup/seeyon_logs/%s.zip'%(file))
print('目录压缩成功')
delete_directory(dirname+file)
致远协同V9.0 oracle配置及版本过期的解决办法
oracle需要做如下配置:
ALTER TABLESPACE undotbs1 ADD DATAFILE '/opt/oracle/oradata/V3X/undotbs12.dbf' SIZE 20481M;
ALTER SYSTEM SET processes=1024 SCOPE=SPFILE;
ALTER SYSTEM SET open_cursors=1024 SCOPE=SPFILE;
ALTER TABLESPACE TEMP ADD TEMPFILE'/opt/oracle/oradata/V3X/temp3.dbf' SIZE 20481M;
alter system set deferred_segment_creation=false;
安装协同的时候提示版本过期要求下载新版本,解决办法如下:
vi /etc/resolv.conf
注释掉所有的dns地址,保存退出重新安装协同。
解决The MySQL server is running with...
mysql配置文件中添加skip-grant-tables后登录修改密码,报错如下:
mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决方法:先刷新一下权限表,把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
再去执行给用户赋值、修改密码操作,就成功了。
mysql启动后不监听3306问题解决
故障现象是mysql启动正常,本地登录正常,网络登录不正常提示无法连接,服务器上查看3306端口未监听。
故障的原因可能是my.cnf中存在以下配置:
skip-network
或者:
skip-grant-tables
去掉如上配置,重启后监听恢复。
解决ModuleNotFoundError: No module...
报错如下:
ModuleNotFoundError: No module named 'Crypto'
尝试:
pip3 install Crypto
无用,遂搜索,找到解决方法:
pip3 install pycryptodome
重新执行,故障消失。
解决linux重装mysql无法启动
服务器上原本安装了mysql8.0版本,但是项目需要mysql5.7。
删除mysql8.0后安装mysql5.7,无法启动,出现故障如下:
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack...