centos6.6 使用sendmail 备份日志发送邮件

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

一、环境描述

1
2
3
[root@mysql-121 ~] # head -n1 /etc/issue
CentOS release 6.6 (Final)
[root@mysql-121 ~] #

二、安装步骤

1.安装sendmail服务器

1
2
3
[root@mysql-121 ~] # yum install sendmail -y
[root@mysql-121 ~] # service sendmail start
[root@mysql-121 ~] # service sendmail status

2.在/etc/mail.rc文件中添加发件人的邮箱认证信息

1
2
3
4
5
6
7
vi  /etc/mail .rc
######add below############# 
set  from=xxx@163.com
set  smtp=smtp.163.com
set  smtp-auth-user=xxx
set  smtp-auth-password=xxxxx
set  smtp-auth=login

3.邮件发送测试、可以发送到多个邮箱,带附件

1
echo  "Test using xxx@163.com  to send email "  | mail -a  /root/dbbackup .log -s  "This email from Linux"  xxxx@139.com xxxx@qq.com

三、问题处理

1.sendmail 启动慢,需要大概3分钟

1
2
3
4
5
[root@mysql-121 mail] # service sendmail stop
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
[root@mysql-121 mail] # service sendmail start
Starting sendmail:    .....卡在这里几分钟

原始配置:

1
2
3
4
5
[root@mysql-121 ~] # more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 mysql-121  # added by Apache Friends XAMPP
192.168.80.121  mysql-121

修改后配置

1
2
3
4
5
vi  /etc/hosts
127.0.0.1   localhost localhost.localdomain mysql-121
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 mysql-121  # added by Apache Friends XAMPP
192.168.80.121  mysql-121

重启,秒级别

1
2
3
4
5
[root@mysql-121 ~] # service sendmail restart
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]

2.sendmail和postfix 冲突

1
2
3
[root@mysql-121 ~] # service sendmail status
sendmail dead but subsys locked
sm-client (pid  22112) is running...

检查postfix服务的状态

1
2
[root@mysql-121 ~] #service postfix status
master (pid  1777) is running...

停止postfix服务

1
2
[root@mysql-121 ~] #service postfix stop
Shutting down postfix: [  OK  ]

重新启动sendmail服务

1
2
3
4
5
[root@mysql-121 ~] # service sendmail restart
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:

禁用postfix在reboot后自动启动

1
2
3
4
5
6
[root@mysql-121 ~] # chkconfig --list |grep postfix
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@mysql-121 ~] # chkconfig postfix off
[root@mysql-121 ~] # chkconfig --list|grep postfix
postfix         0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@mysql-121 ~] #










本文转自 roidba 51CTO博客,原文链接:http://blog.51cto.com/roidba/1880841,如需转载请自行联系原作者
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
4月前
|
存储 SQL 关系型数据库
|
13天前
|
缓存 Linux 编译器
【C++】CentOS环境搭建-安装log4cplus日志组件包及报错解决方案
通过上述步骤,您应该能够在CentOS环境中成功安装并使用log4cplus日志组件。面对任何安装或使用过程中出现的问题,仔细检查错误信息,对照提供的解决方案进行调整,通常都能找到合适的解决之道。log4cplus的强大功能将为您的项目提供灵活、高效的日志管理方案,助力软件开发与维护。
32 0
|
2月前
|
数据库 Java 监控
Struts 2 日志管理化身神秘魔法师,洞察应用运行乾坤,演绎奇幻篇章!
【8月更文挑战第31天】在软件开发中,了解应用运行状况至关重要。日志管理作为 Struts 2 应用的关键组件,记录着每个动作和决策,如同监控摄像头,帮助我们迅速定位问题、分析性能和使用情况,为优化提供依据。Struts 2 支持多种日志框架(如 Log4j、Logback),便于配置日志级别、格式和输出位置。通过在 Action 类中添加日志记录,我们能在开发过程中获取详细信息,及时发现并解决问题。合理配置日志不仅有助于调试,还能分析用户行为,提升应用性能和稳定性。
44 0
|
2月前
|
SQL 安全 测试技术
【数据守护者必备】SQL数据备份与恢复策略全解析:从全量到日志备份,手把手教你确保企业信息万无一失的实战技巧!
【8月更文挑战第31天】数据库是企业核心业务数据的基石,为防止硬件故障、软件错误或人为失误导致的数据丢失,制定可靠的备份与恢复策略至关重要。本文通过一个在线购物平台的案例,详细介绍了使用 SQL Server 进行全量备份、差异备份及事务日志备份的方法,并演示了如何利用 SQL Server Agent 实现自动化备份任务。此外,还提供了数据恢复的具体步骤和测试建议,确保数据安全与业务连续性。
82 0
|
3月前
|
存储 SQL Oracle
关系型数据库Oracle归档日志备份
【7月更文挑战第19天】
63 5
|
4月前
|
存储 运维 关系型数据库
|
4月前
|
Shell Linux
linux shell 脚本实现:根据文件内容中的每行分隔符放入数组,根据规则打印日志并重新创建目录 备份文件
linux shell 脚本实现:根据文件内容中的每行分隔符放入数组,根据规则打印日志并重新创建目录 备份文件
44 0
|
5月前
|
SQL 关系型数据库 MySQL
mysql日志管理 、备份与恢复
mysql日志管理 、备份与恢复
|
5月前
|
弹性计算 运维 Shell
|
5月前
|
关系型数据库 MySQL 数据管理
MySQL通过 bin-log 恢复从备份点到灾难点之间数据
MySQL通过 bin-log 恢复从备份点到灾难点之间数据
280 0