LVM安装及使用
解决服务器数据盘随使用时间容量不足问题,故需搭建服务器时安装lvm以便后期新增硬盘可随时调整网站系统所在分区容量等。
【安装】
yum install lvm2
- 格式化硬盘或分区格式为
8e
:fdisk /dev/vdb
n -> p -> 1 -> t -> 8e -> w
- 使用
pvcreate
创建物理卷PVpvcreate /dev/vdb{1,2,3,...}
解决服务器数据盘随使用时间容量不足问题,故需搭建服务器时安装lvm以便后期新增硬盘可随时调整网站系统所在分区容量等。
【安装】
yum install lvm2
8e
:fdisk /dev/vdb
n -> p -> 1 -> t -> 8e -> w
pvcreate
创建物理卷PVpvcreate /dev/vdb{1,2,3,...}
如查询所有跨律所的律师数据:SELECT DISTINCT x.lawyer_id,x.lawfirm_id FROM
answer as x,
answer as y WHERE x.id<1000 and x.lawyer_id=y.lawyer_id and x.lawfirm_id!=y.lawfirm_id
注:性能有限,大数据量不建议使用
应用程序右键点击属性-兼容性-更改高DPI设置-替代高DPI缩放行为打钩
【安装云锁】
cd /usr/local/src
wget http://download.yunsuo.qianxin.com/v3/yunsuo_agent_64bit.tar.gz
tar zxvf yunsuo_agent_64bit.tar.gz
chmod +x yunsuo_install/install
yunsuo_install/install
/usr/local/yunsuo_agent/agent_smart_tool.sh -u cloud_user -p cloud_passwd
ps -ef | grep yunsuo_agent
service yunsuo start/stop/restart/status
/usr/local/yunsuo_agent/uninstall
mysql_bat.php
用于获取线上数据库中的数据或批量更新数据库中的数据。
<?php
//演示脚本 用于查询线上系统数据库问题
$dbs = ['x001', 'x002', 'x003'];
file_put_contents('mysql_bat.txt', '');
foreach ($dbs as $v) {
$mysql_conf = array('host' => 'localhost', 'db' => $v, 'db_user' => 'xxx', 'db_pwd' => 'xxx');
$mysqli = new mysqli($mysql_conf['host'], $mysql_conf['db_user'], $mysql_conf['db_pwd']);
$mysqli->query("set names 'utf8';");//编码转化
$select_db = mysqli_select_db($mysqli, $mysql_conf['db']);
if ($select_db) {
//查询律所部门名称
$deptName = $configName = '';
$sql1 = "select name from {$v}.lawfirm_dept where id=1;";
$res1 = $mysqli->query($sql1);
while ($row = $res1->fetch_assoc()) {
$deptName = $row['name'];
}
file_put_contents('mysql_bat.txt', '[new] '.$deptName.PHP_EOL, FILE_APPEND);
$res1->free();
$mysqli->close();
}else{
file_put_contents('mysql_bat.txt', '[connect error] '.$v.PHP_EOL, FILE_APPEND);
continue;
}
// sleep(1);
}
clear_log.sh
批量清空系统日志文件
#!/bin/bash
#---------------------------------------
# 清空访问日志及错误日志(清理前务必保存6个月以上数据)
# author: SenSen 1050575278
# date: 2022/04/14
# 注意:所有脚本需测试后方可使用!!!
#---------------------------------------
#所在目录
cd /www/wwwlogs/
sysDir=`ls /web/oa`
for f in ${sysDir}
do
echo > ${f}".speaklaw.cn.log"
echo > ${f}".speaklaw.cn.error.log"
echo "${f} done"
done
`clear_file.sh` 批量删除系统中的垃圾文件
#!/bin/bash
#---------------------------------------
# 清理指定文件
# author: SenSen 1050575278
# date: 2021/11/30
# 注意:所有脚本需测试后方可使用!!!
#---------------------------------------
read -p "Warning! Enter 'y' to continue : " input
#判断是否存在参数,不存在则取消
if [ "$input" == 'y' ] || [ "$input" == 'Y' ]; then
#所在目录
dir='/web/oa/'
#自动获取系统目录文件 仅可包含oa系统文件
sysDir=`ls /web/oa`
#排除目录
excluded=()
for f in ${sysDir}
do
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
#排除指定目录
if [[ ${excluded[@]/${f}/} != ${excluded[@]} ]]; then
echo "jump"
continue
fi
#进入目录
cd ${dir}${f}
#执行对应操作 务必将要删除的文件路径填写准确
rm -rf public/tmp/*
rm -rf runtime/*
echo "${curtime} ${f} done"
done
else
echo "Error: invalid input"
fi
create.sh
通过已有的系统文件,排除当前系统的附件等目录,创建为一份新的系统。$1为被复制的老系统,$2为新系统目录名称,create.exclude
为排除复制的目录。
#!/bin/bash
#---------------------------------------
# 创建新的OA系统
# author: SenSen 1050575278
# date: 2021/11/29
# 注意:所有脚本需测试后方可使用!!!
#---------------------------------------
if [ "$1" ] && [ "$2" ]; then
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
#所在目录
cd /web/oa
rsync -av --exclude-from="/web/shell/create.exclude" ${1}/ ${2}/
#拷贝原env配置
cd ${2}
cp -r public/install/.env ./.env
#todo 暂不考虑自动创建网站+配置
else
echo "Error: param1 is source ('like a001') && param2 is target ('like a999')"
fi
create.exlude
runtime/*
public/install/install.lock
public/phpExcel/*
public/uploads/attach/*
public/uploads/doc/*
批量复制程序脚本:
#!/bin/bash
#---------------------------------------
# 批量复制部署系统程序
# author: SenSen 1050575278
# date: 2021/10/16
#---------------------------------------
#确定版本号
read -p "Enter Version Code to continue : " code
if [ "$code" ]; then
#待部署系统文件夹名称 todo 待通过dns文件获取
sysDir=(t001 t002)
#源文件 依据系统版本
sourceDir="/web/source/${code}.zip";
#判断文件是否存在
if [ ! -f "${sourceDir}" ];then
echo "Error: File not found"
exit
fi
#安装目录
baseDir='/web/oa/'
for f in "${sysDir[@]}"
do
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
#复制
cp -rf ${sourceDir} ${baseDir}${f}".zip"
#解压 默认解压到当前
unzip -oq ${baseDir}${f} -d ${baseDir}${f}
#变更用户组
chown -R www:www ${baseDir}${f}
#删除压缩包
rm -rf ${baseDir}${f}".zip"
echo "${curtime} ${f} done"
done
else
echo "Error: param is empty"
fi
清理缓存:
#!/bin/bash
#---------------------------------------
# 清理系统临时文件
# author: SenSen 1050575278
# date: 2021/10/10
#---------------------------------------
read -p "Warning! Enter 'y' to continue : " input
#判断是否存在参数,不存在则取消
if [ "$input" == 'y' ] || [ "$input" == 'Y' ]; then
#所在目录
dir='/web/oa/'
#自动获取系统目录文件 仅可包含oa系统文件
sysDir=`ls /web/oa`
#排除目录
excluded=()
for f in ${sysDir}
do
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
#排除指定目录
if [[ ${excluded[@]/${f}/} != ${excluded[@]} ]]; then
echo "jump"
continue
fi
#进入目录
cd ${dir}${f}
#执行对应操作
#清除runtime 不包含log session等 todo 支持删除缓存或所有
rm -rf runtime/cache/*
rm -rf runtime/index/temp/*
#清除uploads
rm -rf public/phpExcel/*
echo "${curtime} ${f} done"
done
else
echo "Error: invalid input"
fi
批量修改网站配置:
#!/bin/bash
#---------------------------------------
# 批量生成网站配置文件
# author: SenSen 1050575278
# date: 2021/10/16
#---------------------------------------
#进入伪静态目录
cd /www/server/panel/vhost/nginx
baseDir='/web/oa/'
sysDir=`ls /web/oa`
#循环生成伪静态
for f in ${sysDir}
do
#复制
cp "thinkphp_conf.conf" "${f}.speaklaw.cn.conf"
#替换
find "${f}.speaklaw.cn.conf" | xargs sed -i "s/sensen/${f}/"
echo "${f} done"
done
创建新的系统:
#!/bin/bash
#---------------------------------------
# 创建新的OA系统
# author: SenSen 1050575278
# date: 2021/11/29
#---------------------------------------
if [ "$1" ] && [ "$2" ]; then
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
#所在目录
cd /web/oa
rsync -av --exclude-from="/web/shell/create.exclude" ${1}/ ${2}/
#拷贝原env配置
cd ${2}
cp -r public/install/.env ./.env
#todo 暂不考虑自动创建网站+配置
else
echo "Error: param1 is source ('like a001') && param2 is target ('like a999')"
fi
系统升级脚本:
#!/bin/bash
#---------------------------------------
# 批量更新多文件夹内容 支持排除指定目录
# 注:多系统升级时,为避免文件冲突,建议
# 单次单压缩包更新
# author: SenSen 1050575278
# date: 2021/09/10
#---------------------------------------
#添加定时任务 10min
# */10 * * * * /www/upgrade/upgrade.sh
#记录日志
log="/web/upgrade/upgrade.log"
#进入升级包所在目录 升级包必须包含version.txt文件
cd /web/upgrade/fix
#判断目录中是否有文件 原则上一次只能存在一个文件,避免多个升级包导致混乱
count=`ls -l|grep '^-'|wc -l`
#获取所有系统 废弃
# source ./wlt_dir.sh
#所在目录
baseDir='/web/oa/'
#自动获取系统目录文件 仅可包含oa系统文件
sysDir=`ls /web/oa`
#排除目录
excluded=()
#测试示例
#sysDir=('wlt_3163')
#获取当前目录下的升级包
fixFile=`ls`
if [ $count -ne 0 ]; then
for i in ${fixFile}
do
#获取当前时间
curtime=`date +"%Y/%m/%d %H:%M:%S"`
for f in ${sysDir}
do
#排除指定目录
if [[ ${excluded[@]/${f}/} != ${excluded[@]} ]]; then
continue
fi
echo "系统:${f} 升级文件:${i}">>${log}
#解压到对应系统目录
unzip -oq ${i} -d ${baseDir}${f}
echo "${curtime} ${i} done">>${log}
done
done
#移动升级包
mv ${i} /web/upgrade/bak;
echo "${i} upgrade successfully">>$log
else
echo "upgrade_fix is empty"
fi