System Engineering

Install SRSd with Postfix on OpenSUSE

Posted on

Postfix Sender Rewriting Scheme(SRS) daemon zypper install postsrsd vi /etc/default/postsrsd SRS_DOMAIN=xxx.com vi /etc/postfix/main.cf inet_interfaces = all inet_protocols = ipv4 myhostname = smtp.xxx.com mynetworks_style = subnet mynetworks = 10.3.0.0/16, 192.168.1.0/24 relay_domains = $mydestination, hash:/etc/postfix/relay virtual_alias_domains = hash:/etc/postfix/virtual virtual_alias_maps = hash:/etc/postfix/virtual # Aiden: PostSRSd settings. sender_canonical_maps = tcp:localhost:10001 sender_canonical_classes = envelope_sender recipient_canonical_maps = tcp:localhost:10002 recipient_canonical_classes= envelope_recipient,header_recipient # […]

System Engineering

자체적으로 rotate되는 로그파일에 logrotate 적용하기

Posted on
log rotate

tomcat 기본설정 처럼 로그파일 이름이 자체적으로 rotate되어 버리는 경우, logrotate 로의  통합이 어렵다. 네이밍은 자체룰을 이용하고 압축을 하는 등 후작업을 logrotate에 넣는 방식으로 통합하는 방법이다. vi /etc/logrotate.d/tomcat /var/log/tomcat-access-log-dummy { su root root rotate 0 create 664 tomcat root daily ifempty lastaction /usr/bin/find /home/www/*/logs/*.txt -mtime +30 -delete /usr/bin/find /home/www/*/logs/*.txt -mtime +1 -exec gzip -q {} \; endscript […]

Developments

MySQL Stored Procedure for CRUD Dynamic Queries

Posted on

The new MySQL 5.7 version has some great features. One of them is the ‘JSON data’ type. We can use it for column of table like ‘Virtual Colunm’ with Indexing. But, ‘JSON data’ is also useful for stored procedure. Because we can compact parameters and the procedure could be more flexible.I made the procedures for […]

System Engineering

Mysql Backup Script

Posted on
MySQL

Features Full Backup (Mysqldump) Incremental Backup (Bin-log) Local Backup & Remote(AWS S3) Upload Sample Environments MySQL bin log prefix : mysql-bin BINLOG_PATH=/home/mysql/data BACKUP_ROOT=/home/backup/mysql S3_PATH=s3://system-backup/{SyatemName}/mysql #!/bin/bash #—————————————- # MySQL Backup Script # Revision 20160531 # Copyright (c) Aiden Kim # http://www.daemon.pe.kr #—————————————- ARCHIVE_PERIOD=60 BINLOG_PATH=/home/mysql/data BASE_PATH=/home/backup/mysql SYSNAME=$(echo $HOSTNAME | tr “[:lower:]” “[:upper:]”) S3_PATH=s3://system-backup/${SYSNAME}/mysql STATUS_PATH=${BASE_PATH}/mysql-backup-status ## prepare path if ! […]

System Engineering

Subversion Repogitories Backup Script

Posted on
Subversion

Features Full Backup (Dump) Incremental Backup (Dump) Local Backup & Remote(AWS S3) Upload Sample Environments REPOS_ROOT=/home/svn/repos BACKUP_ROOT=/home/backup/svn S3_PATH=s3://svn-backup/svn #!/bin/bash #—————————————- # Subversion Repogitories Backup Script # Revision 20160531 # Copyright (c) Aiden Kim # http://www.daemon.pe.kr #—————————————- DSTR=$(date +”%Y%m%d”) ARCHIVE_PERIOD=30 REPOS_ROOT=/home/svn/repos BACKUP_ROOT=/home/backup/svn S3_PATH=s3://svn-backup/svn # Each repogitories REPOS_DIRS=`ls -t ${REPOS_ROOT} 2>/dev/null` for DIR in ${REPOS_DIRS}; do # Create directory BACKUP_PATH=${BACKUP_ROOT}/repo-${DIR} […]

System Engineering

When Nagios send alert mails with attachement…

Posted on

When Nagios send alert mails with attachement… Perhaps this problem is that if a device name or warning message include non-Latin characters.   1. Add new command to nagios configuration Original commands # ‘notify-host-by-email’ command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Host […]

System Engineering

AWS CodeDeploy 설정 (S3)

Posted on
AWS CodeDeploy

The flow of a typical AWS CodeDeploy deployment 설정 목록 EC2 On-Premises(EC2가 아닌 물리서버) CodeDeploy 서비스용 IAM 권한 생성 서버용  IAM 권한 생성 CodeDeploy Application 생성 EC2 설정 CodeDeploy Agent 설치/설정 On-Premise 서버 설정 배포 파일 준비, appspec.yml 설정 [반복] 배포 [반복] CodeDeploy 서비스용 IAM 권한 생성 [AWS-Console] IAM > Roles : Create New Role Role Type :  AWS […]

System Engineering

rsyslog + MySQL + LogAnalyzer on OpenSUSE

Posted on
rsyslog Features Map

1. Install requirements zypper install rsyslog rsyslog-module-relp rsyslog-module-mysql rsyslog-module-snmp rsyslog-module-mmnormalize 2. Create RuleBase for PHP log vi /etc/rsyslog.d/phplog.rulebase # PHP Logs rule=: %server:char-to:\x3a%\x3a PHP %priority:char-to:\x3a%\x3a%message:rest% rule=: PHP %priority:char-to:\x3a%\x3a%message:rest% 3. Prepare MySQL CREATE DATABASE `syslog`; USE `syslog`; CREATE USER ‘syslog’@’localhost’ IDENTIFIED BY ‘my_password’; GRANT EXECUTE, INSERT, LOCK TABLES, SELECT, SHOW VIEW, UPDATE ON syslog.* TO ‘syslog’@’localhost’; […]

System Engineering

Upload PKCS#12 Server Certificates to AWS

Posted on
AWS IAM Certificate Manager

1. Extract RSA Private key openssl pkcs12 -in CERTIFICATE.PFX -nocerts -nodes -out private.key openssl rsa -in private.key -out private-rsa.key 2. Extract Certificate openssl pkcs12 -in CERTIFICATE.PFX -clcerts -nokeys -out certificate.crt 3. Extract Certificate Chains openssl pkcs12 -in CERTIFICATE.PFX -cacerts -nokeys -out certificate-chain.crt 4. Trimming  Certificates for AWS sed -ne ‘/—–BEGIN CERTIFICATE—–/,/—–END CERTIFICATE—–/ p’ certificate.crt > certificate-trim.crt […]