shell实现多进程,对数据库进行备份。
2015-09-11 09:26
645 查看
#!/bin/bash
PATH=$PATH:$HOME/binexport PATH=/veris/usr/bin:/veris/usr/sbin:$PATHexport LD_LIBRARY_PATH=/veris/usr/lib64:$LD_LIBBRARY_PATH
THREAD_NUM=3tmp_fifofile="/tmp/$$.fifo"mkfifo "$tmp_fifofile"exec 6<>"$tmp_fifofile"rm $tmp_fifofilefor ((i=0;i<$THREAD_NUM;i++))do echodone >&6
db_port=5310db_list=`mysql -h127.0.0.1 -uroot -pxxxxx -A -P ${db_port} -ss -e "select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME not in('information_schema','mysql','test','performance_schema')"`for db_name in ${db_list}do read -u6 { echo ${db_name} mysqldump -h127.0.0.1 -uroot -pxxxxx -P${db_port} -B -R --default-character-set=utf8 --opt --max-allowed-packet=64M --net_buffer_length=163840 --single-transaction -f ${db_name} > /tmp/${db_port}.${db_name}.sql echo >&6 } & pid=$! echo $piddone
waitexec 6>&-exit 0
PATH=$PATH:$HOME/binexport PATH=/veris/usr/bin:/veris/usr/sbin:$PATHexport LD_LIBRARY_PATH=/veris/usr/lib64:$LD_LIBBRARY_PATH
THREAD_NUM=3tmp_fifofile="/tmp/$$.fifo"mkfifo "$tmp_fifofile"exec 6<>"$tmp_fifofile"rm $tmp_fifofilefor ((i=0;i<$THREAD_NUM;i++))do echodone >&6
db_port=5310db_list=`mysql -h127.0.0.1 -uroot -pxxxxx -A -P ${db_port} -ss -e "select SCHEMA_NAME from information_schema.SCHEMATA where SCHEMA_NAME not in('information_schema','mysql','test','performance_schema')"`for db_name in ${db_list}do read -u6 { echo ${db_name} mysqldump -h127.0.0.1 -uroot -pxxxxx -P${db_port} -B -R --default-character-set=utf8 --opt --max-allowed-packet=64M --net_buffer_length=163840 --single-transaction -f ${db_name} > /tmp/${db_port}.${db_name}.sql echo >&6 } & pid=$! echo $piddone
waitexec 6>&-exit 0
相关文章推荐
- php最短一句话后门webshell
- Shell脚本-良好的习惯
- jenkins 通过shell启动java应用程序会随着job完成而被自动关闭的解决方法
- Android系统在超级终端下必会的命令大全(adb shell命令大全)
- shell 自动执行参数脚本并判断(一个折腾的下午)
- Bash基础
- Android 设备,如何root,执行adb shell,查看设备中的数据库信息等
- bash编程实现插入排序
- shell脚本集合
- shell中的${},##和%%的使用
- shell脚本中报错dirname:无效选项 -- b
- 简单shell脚本1
- Shell编程中的“局部变量”和“导出变量”
- xshell命令大全
- 同时新建AD账号、邮箱、添加通讯组的powershell脚本
- UEFI Shell命令操作总结
- shell 获取 目录名 当前目录名
- bash内建命令type简介
- Bash shell常用技巧
- bash