2024년 1월 29일
#R1 config t interface FastEthernet0/0 ip address 1.1.1.254 255.255.255.0 no shutdown exit config t interface Serial1/0 ip address 2.2.2.1 255.255.255.252 no shutdown exit ip route 3.3.3.0 255.255.255.0 2.2.2.2 exit #R2 config t interface FastEthernet0/0 ip address 3.3.3.254 255.255.255.0 no shutdown exit config t interface Serial1/0 ip address 2.2.2.2 255.255.255.252 no shutdown exit ip route 1.1.1.0 255.255.255.0 2.2.2.1 exit # R2 라우터에 DHCP 기능 추가 config t ip dhcp pool R2 network 3.3.3.0 255.255.255.0 dns-server 3.3.3.1 default-router 3.3.3.254 ip dhcp excluded-address 3.3.3.1 ip dhcp excluded-address 3.3.3.2 ip dhcp excluded-address 3.3.3.254 exit show ip dhcp binding IP변경 dpkg -l apt -y install rsync (이미 있어서 생략) 사이트 보고 메인서버, 모니터서버 설정파일 세팅 sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime rsync -avz --delete --exclude-from=/etc/rsync_exclude.lst /backup/ node01.srv.world::backup /backup == 시간 + 프로그램 cd /home/master nano myBackup.sh #!/bin/sh set $(date) fname="backup-$1$2$3.tar.xz" tar cfj /backup/$fname /home $1 : 요일 $2 : 월 1월~12월 $3 : 일 1~31 chmod 755 myBackup.sh ls /etc/crontab 35 15 * * * root /home/master/myBackup.sh 00 04 * * * root /home/master/myBackup.sh 40 15 * * * root /home/master/rsync.sh systemctl restart cron ''' timedatectl set-ntp 0 date 012914002024 systemctl restart cron 시간변경 sudo apt -y install rdate at rdate -s time.bora.net ''' rsync.sh #!/bin/sh SOURCE_DIR="/backup" DESTINATION_DIR="3.3.3.2::backup" rsync -av --delete $SOURCE_DIR/ $DESTINATION_DIR/ 0 0 * * * root /home/mater/rsync.sh 데이터베이스백업스크립트 #!/bin/bash # MySQL 연결 정보 DB_USER="사용자이름" DB_PASSWORD="패스워드" DB_NAME="데이터베이스이름" # 백업 파일 경로 및 파일명 지정 BACKUP_DIR="/경로/백업" DATE=$(date +"%Y%m%d%H%M%S") BACKUP_FILE="$BACKUP_DIR/$DB_NAME_backup_$DATE.sql" # mysqldump를 사용하여 백업 수행 mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > $BACKUP_FILE # 백업 완료 메시지 출력 echo "MySQL 백업이 완료되었습니다. 백업 파일: $BACKUP_FILE" [하드디스크 추가] fdisk /dev/sdb 로그분석기만들기 grep -v -E "^#|^$" /etc/rsyslog.conf /etc/rsyslog.d/* [3.3.3.1] -----------> [3.3.3.2] [3.3.3.2] 받을준비 sudo nano /etc/rsyslog.conf # line 21-22 : uncomment line 23 : set allowed hosts to connect module(load="imtcp") input(type="imtcp" port="514") $AllowedSender TCP, 127.0.0.1, 10.0.0.0/24, *.srv.world sudo systemctl restart syslog netstat -ant | grep 514 tail -f /var/log/auth.log [3.3.3.1] 보낼준비 sudo nano /etc/rsyslog.d/50-default.conf # add to the end action(type="omfwd" queue.filename="monitor.st.au" queue.maxdiskspace="1g" queue.saveonshutdown="on" queue.type="LinkedList" action.resumeRetryCount="-1" Target="monitor.st.au" Port="514" Protocol="tcp") # queue.filename : queue filename # queue.maxdiskspace : maxdiskspace for queue # queue.saveonshutdown=on : save queue data on disk when system shutdown # queue.type=LinkedList : asynchronous queue which can store 10,000 messages # action.resumeRetryCount=-1 : continue to retry sending when syslog server does not respond # Target=*** : specify syslog server Host