日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python安装lap_一个python脚本解决安装mq的依赖问题

發(fā)布時(shí)間:2025/3/12 python 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python安装lap_一个python脚本解决安装mq的依赖问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

import tarfile

import sys,os

from _utils.patrol2 import run_cmd

import zipfile

def get_version(filename):

cmd="rpm -U {}".format(filename)

code,res=run_cmd(cmd,cwd=pkg_unzip_path)

if 'is already installed' in res or '已安裝' in res:

return True

else:

return False

def install_pkg(filename):

cmd = "yum -y localinstall {}".format(filename)

code,res=run_cmd(cmd,cwd=pkg_unzip_path)

if code:

print res

sys.exit(1)

if get_version(filename):

return True

else:

return False

def extract(tar_path, target_path):

try:

tar = tarfile.open(tar_path, "r:gz")

file_names = tar.getnames()

for file_name in file_names:

tar.extract(file_name, target_path)

tar.close()

except Exception, e:

print Exception, e

sys.exit(1)

def search(path, word):

for filename in os.listdir(path):

fp = os.path.join(path, filename)

if os.path.isfile(fp) and word in filename:

return filename

elif os.path.isdir(fp):

search(fp, word)

return False

def unpack_zip(filename, destpath, fix_path=None):

zf_obj = zipfile.ZipFile(filename)

if destpath.endswith(':'):

destpath = destpath + os.sep

zf_obj.extractall(path=destpath)

zf_obj.close()

if fix_path:

destpath = os.path.join(destpath, fix_path)

return destpath

if pkg_file.endswith('.gz'):

extract(pkg_file, pkg_unzip_path)

elif pkg_file.endswith('.zip'):

pkg_name=pkg_name.split('.zip')[0]

pkg_unzip_path=unpack_zip(pkg_file, pkg_unzip_path,fix_path=pkg_name)

print '-->解壓成功'

code,res=run_cmd('chmod 755 ./lap/jre/jre/bin/java', cwd=pkg_unzip_path)

if code:

print 'java執(zhí)行權(quán)限賦權(quán)失敗',res

sys.exit(1)

else:

print 'java執(zhí)行權(quán)限賦權(quán)成功'

#接受授權(quán)認(rèn)證

cmd = "sh mqlicense.sh<

code,res = run_cmd(cmd,cwd=pkg_unzip_path)

if code:

print res

sys.exit(1)

else:

print res

print '-->權(quán)限認(rèn)證成功'

#1、安裝系統(tǒng)依賴包

print '開始安裝rpm包,請等待'

names=["MQSeriesRuntime","MQSeriesSDK","MQSeriesJava","MQSeriesClient","MQSeriesSamples","MQSeriesServer"]

for name in names:

filename=search(pkg_unzip_path, name)

if not filename:

print '{}相關(guān)的包不存在'.format(name)

sys.exit(1)

elif get_version(filename):

print '{}已安裝'.format(filename)

elif filename and not get_version(filename):

res=install_pkg(filename)

if res:

print '安裝{}成功'.format(filename)

else:

print '安裝{}失敗'.format(filename)

sys.exit(1)

print '-->依賴包安裝成功'

#2、修改系統(tǒng)limits參數(shù)

with open('/etc/security/limits.conf','a') as f:

f.write("mqm soft nofile 10240\nmqm hard nofile 10240\nmqm soft nproc 4096\n")

print '-->修改系統(tǒng)limits參數(shù)成功'

#3、修改系統(tǒng)核心參數(shù)

with open('/etc/sysctl.conf','a') as f:

f.write("kernel.sem = 500 256000 250 1024\nfs.file-max = 524288\nnet.ipv4.tcp_keepalive_time = 300\n")

cmd = "sysctl -p"

code,res=run_cmd(cmd,cwd=pkg_unzip_path)

if 'kernel.sem = 500 256000 250 1024\nfs.file-max = 524288\nnet.ipv4.tcp_keepalive_time = 300' in res:

print '-->修改系統(tǒng)核心參數(shù)成功'

else:

print '-->修改系統(tǒng)核心參數(shù)失敗'

sys.exit(1)

總結(jié)

以上是生活随笔為你收集整理的python安装lap_一个python脚本解决安装mq的依赖问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。