리눅스 서버는 살아 있는데,

특정 프로세스만 Down 되어 서비스가 먹통이 되는 때가 간혹 있다.

예를들어, 서버의 ICMP는 되나 nginx만 죽었다던지...그런 것이다.


방법을 찾던 중에 Monit 이라는 오픈소스를 알게 되었다.


- 설치

# On RedHat/CentOS(AMI)/Fedora/

yum install monit

# On Ubuntu/Debian/Linux Mint

apt-get install monit


# vi /etc/monit.conf   또는  vi /etc/monit/monitrc


주석 처리 된 내용 중 원하는 설정의 # 을 제거하여 활성화 한다.

set daemon  120           # check services at 2-minute intervals

 - 실행
service monit start
/etc/init.d/monit start

원하는 것을 골라서 실행 시키면 된다.

 - 사용자 설정 (모니터링)
vi /etc/monit/conf.d/httpd

check process httpd with pidfile /var/run/httpd.pid
    start program = "/etc/init.d/httpd start"
    stop program = "/etc/init.d/httpd stop"
    if failed host www.example.com port 80
      protocol HTTP request /alive.html then restart
    group httpd


vi /etc/monit/conf.d/nginx 

 check process nginx with pidfile /var/run/nginx.pid
   group nginx
   start program = "/etc/init.d/nginx start"
   stop program = "/etc/init.d/nginx stop"
   if failed 127.0.0.1 port 80 protocol http request "/check.html" then restart

 

vi /etc/monit/conf.d/mysql
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout

vi /etc/monit/conf.d/vsftpd

check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid
start program = "/etc/init.d/vsftpd start"
stop program = "/etc/init.d/vsftpd stop"
if failed host 127.0.0.1 port 21 then restart


stop start 프로그램이 없을 경우,

check process nginx with pidfile /var/run/nginx.pid
start program = "/opt/cac/sbin/nginx"
stop program = "/opt/cac/sbin/nginx -s stop"
if failed host 127.0.0.1 port 80 then restart

원하는 모니터링을 생성 후 설정 저장

- config 오류 확인
monit -t
Control file syntax OK

- monit 재실행
/etc/init.d/monit restart




 - 부팅시 monit 실행

vi /etc/rc.local

/usr/bin/monit cnrk







참고 url : https://mmonit.com/monit/documentation/monit.html

https://nolboo.kim/blog/2016/08/13/monitoring-linux-monit/



by 초보인척 2018. 10. 23. 11:27

Mikrotik Router SYN flood Protection


New Terminal

[Mikrotik]# 아래 내용 적용.


ip firewall filter add chain=input protocol=tcp connection-limit=0,32  action=add-src-to-address-list  address-list=blocked-addr address-list-timeout=1d

      

ip firewall filter add chain=input protocol=tcp src-address-list=blocked-addr connection-limit=3,32 action=tarpit  


ip firewall filter add chain=forward protocol=tcp tcp-flags=syn connection-state=new action=jump jump-target=SYN-Protect comment="SYN Flood protect" disabled=yes  


ip firewall filter add chain=SYN-Protect protocol=tcp tcp-flags=syn limit=400,5 connection-state=new action=accept comment="" disabled=no 


ip firewall filter add chain=SYN-Protect protocol=tcp tcp-flags=syn connection-state=new  action=drop comment="" disabled=no 



For v6.x (version 6.X 이상에 적용)

ip settings set tcp-syncookies=yes


For older version. (6.X 이하에 적용)

ip firewall connection tracking set tcp-syncookie=yes





참고url : https://wiki.mikrotik.com/wiki/DoS_attack_protection

by 초보인척 2018. 10. 5. 16:27

환경

우분투 16.04 LTS 


apt-get install keepalived

keepalived 설치



vi /etc/keepalived/keepalived.conf


! Configuration File for keepalived


global_defs {

   notification_email {

   }

}


vrrp_instance xdnpass {

    state MASTER              # keepalived 시작시 MASTER로서 시작할지 BACKUP으로 시작할지를 지정

#    state BACKUP

    interface eth1             # VRRP패킷을 송신하거나 수실할 인터페이스를 지정

    virtual_router_id 100    # 가상 라우터 ID.VRRP 인스턴스 마다 고유한 값을 지정. 지정할 수 있는 범위는 0~255

    priority 101                # VRRP의 우선순위값. 마스터를 선출할 때 이 값이 큰 것이 우선

#    priority 100

    advert_int 2               # VRRP패킷 송신 간격. 초단위로 지정

    garp_master_delay 2    # 마스터 상태로 변경된 후에 gratuitous ARP를 재송신하기까지 대기시간을 초단위로 지정

    authentication {

        auth_type PASS

        auth_pass xdnroute

    }

    virtual_ipaddress {

        121.126.223.193    # virtual_ipaddress  VIP(가상주소). 형식은 다음과 같고 여러 개 지정할 수 있음.

   # <IPADDR>/<MASK>dev<STRIng>

    }

}


vrrp_instance private6pass {

    state MASTER

    interface eth0

    virtual_router_id 101

    priority 101

    advert_int 2

    garp_master_delay 2

    authentication {

        auth_type PASS

        auth_pass xdnroute

    }

    virtual_ipaddress {

        10.1.6.241

    }

}

by 초보인척 2018. 6. 21. 13:17

## rsyslog 를 이용한 client log를 원격지 LOG 수집서버로 쌓기


1) LOG SERVER conf 수정

vi /etc/rsyslog.conf


# provides UDP syslog reception

$ModLoad imudp                            -  주석제거

$UDPServerRun 514                         -  주석제거

$template FILENAME,"/var/log/%hostname%/%$YEAR%_%$MONTH%_%$DAY%.log"        - 추가

*.* ?FILENAME                                                                                                   - 추가


/etc/init.d/rsyslog restart



2) client conf

vi /etc/rsyslog.conf


syslog

#*.*;auth,authpriv.none         -/var/log/syslog            - 주석, 복사

*.*;auth,authpriv.none          @172.16.1.1:514            - @LOG Server IP:514




messages

*.=info;*.=notice;*.=warn;\

        auth,authpriv.none;\

        cron,daemon.none;\

        mail,news.none          @172.16.1.1:514



/etc/init.d/rsyslog restart




LOG 수집 서버에 /var/log/호스트네임/날짜 로 로그 수집이 되는지 확인. 끝.



참고 url : http://idchowto.com/?p=16367

http://egloos.zum.com/outspace/v/3091255

by 초보인척 2018. 6. 1. 11:35

** 환경

CentOS 7 x86_64

Cacti 1.1.38 


****   centos 7.0 부터 iptables 설정이 아주 이상해졌다.

아래 과정을 꼭 해주길 권장한다.

systemctl stop firewalld

systemctl disable firewalld

/etc/selinux  - disabled


/etc/iptables.sh  생성관리



###  apache 2.4 설치

# Install Apache 2.4

sudo yum install httpd -y

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

sudo systemctl start httpd.service

sudo systemctl enable httpd.service



###  MariaDB 10.2 설치

# Install MariaDB 10.2

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

sudo yum install MariaDB-server MariaDB-client -y

sudo systemctl start mariadb.service

sudo systemctl enable mariadb.service


###  MariDB root password 설정

# Secure MariaDB 10.2

sudo /usr/bin/mysql_secure_installation

# When prompted, answer questions as below:

# - Enter current password for root (enter for none): Just press the Enter button

# - Set root password? [Y/n]: Y

# - New password: your-MariaDB-root-password

# - Re-enter new password: your-MariaDB-root-password

# - Remove anonymous users? [Y/n]: Y

# - Disallow root login remotely? [Y/n]: Y

# - Remove test database and access to it? [Y/n]: Y

# - Reload privilege tables now? [Y/n]: Y


###  cacti database 생성

# Create a MariaDB database for Cacti

mysql -u root -p

# For security purposes, be sure to replace "cacti", "cactiuser", and "yourpassword" with your own ones. 

CREATE DATABASE cacti;

CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword';

GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

EXIT;



###   PHP7.1 설치

# Install required PHP 7.1 components for Cacti

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

sudo yum install -y mod_php71w php71w-process php71w-common php71w-pdo php71w-xml php71w-ldap php71w-mbstring php71w-gd php71w-snmp php71w-mysqlnd php71w-cli php71w-mcrypt php71w-opcache php71w-imap php71w-intl

sudo cp /etc/php.ini /etc/php.ini.bak

sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php.ini



###  snmp 설치
 yum install -y net-snmp net-snmp-utils rrdtool
 systemctl start snmpd.service
 systemctl enable snmpd.service


###  CACTI 1.1.38 다운로드

wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz

cacti-1.1.38.tar.gz


tar zxvf cacti-1.1.38.tar.gz 

  mv /root/cacti-1.1.38 /opt/cacti


ln -s /opt/cacti-1.1.38 /var/www/html/cacti

touch /opt/cacti/log/cacti.log

 chown -R apache:apache /opt/cacti




###   CACTI SQL SB 추가

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

mysql -u root -p cacti < /var/www/html/cacti/cacti.sql

mysql -u root -p

# In the MySQL shell:

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'yourpassword';

FLUSH PRIVILEGES;

EXIT;




###    cacti config.php 수정

vi /var/www/html/cacti/include/config.php


$database_type     = 'mysql';

$database_default  = 'cacti';

$database_hostname = 'localhost';

$database_username = 'cactiuser';

$database_password = 'yourpassword';

$database_port     = '3306';

$database_ssl      = false;

$url_path = '/cacti/';




###  crontab 추가

 crontab -u apache -e



*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1





####  apache cacti.conf 추가

cat <<EOF | sudo tee -a /etc/httpd/conf.d/cacti.conf

<VirtualHost *:80>

ServerAdmin admin@example.com

DocumentRoot /var/www/html/

ServerName cacti.example.com

ServerAlias www.cacti.example.com

<Directory /var/www/html/cacti/>

Options FollowSymLinks

AllowOverride All

Order allow,deny

allow from all

</Directory>

ErrorLog /var/log/httpd/cacti.example.com-error_log

CustomLog /var/log/httpd/cacti.example.com-access_log common

</VirtualHost>

EOF



systemctl restart httpd.service



###  my.cnf 수정

vi /etc/my.cnf


[client]

default-character-set=utf8mb4

[mysql]

default-character-set=utf8mb4

[mysqld]

collation-server=utf8mb4_unicode_ci

init-connect='SET NAMES utf8mb4'

character-set-server = utf8mb4

max_heap_table_size=256M

tmp_table_size=80M

join_buffer_size=80M

innodb_buffer_pool_size=963M

innodb_doublewrite=OFF

innodb_flush_log_at_timeout=3

innodb_read_io_threads=32

innodb_write_io_threads=16



systemctl restart mariadb.service



**  mariadb 재시작 시 error 가 발생하는 경우가 생긴다.

이 때 /var/lib/mysql/  

ib_logfile0

ib_logfile1

ibdata1


3개의 파일을 삭제 한 뒤 다시 시작하면 된다.



참고url

https://www.vultr.com/docs/how-to-install-cacti-1-1-on-centos-7

http://idchowto.com/?p=11107


by 초보인척 2018. 5. 10. 12:34

* 환경

  - Ubuntu 16.04 LTS

  - Cacti 1.1.38.tar.gz



apt-get update

apt-get upgrade


## Mysql Server 설치

apt-get install mysql-server-5.7   (최신)


## php, apache2 설치

apt-get install php-xml php-ldap php-mbstring php-gd php-snmp php-gmp rrdtool snmp librrds-perl apache2


## Cacti 1.1.38 다운 (최신)

wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz

cacti-1.1.38.tar.gz


## cacti 압축 해제

tar zxvf cacti-1.1.38.tar.gz


mv cacti-1.1.38 /opt/cacti


## Log 경로 설정

mkdir /opt/logs

  touch /opt/logs/cacti.log

  touch /opt/logs/httpd_access.log

  touch /opt/logs/httpd_error.log

  chown -R www-data /opt/logs/*



## Mysql cacti DB 생성

mysqladmin --user=root --password create cacti

mysql --user root -p cacti < /opt/cacti/cacti.sql

 mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

 mysql --user root --password mysql


###Enter your mysql root password.
###This will enter you into the mysql console for mysql database.
###NOTE: ‘somepassword’ referenced here is the cacti user password and must be the same as used in cacti configuration in the next section

mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'somepassword';
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'somepassword';

Exit



## cacti config 수정

vi /opt/cacti/include/config.php 


### Find these variables and make the following changes

$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = somepassword;
$database_port = '3306';
$database_ssl = false;
$url_path = '';




##  file permissions 설정

chown -R www-data:www-data /opt/cacti/resource/snmp_queries

  chown -R www-data:www-data /opt/cacti/resource/script_server

  chown -R www-data:www-data /opt/cacti/resource/script_queries

  chown -R www-data:www-data /opt/cacti/scripts

  chown -R www-data:www-data /opt/cacti/rra/ /opt/cacti/log/

  chown -R www-data:www-data /opt/cacti/cache/mibcache

  chown -R www-data:www-data /opt/cacti/cache/realtime

  chown -R www-data:www-data /opt/cacti/cache/spikekill




##   Apache config

touch /etc/apache2/sites-available/cacti.conf

  vi /etc/apache2/sites-available/cacti.conf 

<VirtualHost *:80>

    <Location />
       require all granted
   </Location>

   ServerAdmin webmaster@localhost
   DocumentRoot /opt/cacti
   ErrorLog /opt/logs/httpd_error.log
   CustomLog /opt/logs/httpd_access.log combined

</VirtualHost>


  rm /etc/apache2/sites-enabled/*

  a2ensite cacti.conf



##   crontab 등록

vi /etc/crontab

###Add line at bottom

*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1


##  MySQL my.cnf 튜닝

vi /etc/mysql/mysql.conf.d/mysqld.cnf ###Add following lines to the bottom of the configuration file: Max_heap_table_size = 256M Tmp_table_size = 64M Join_buffer_size = 64M Innodb_doublewrite = OFF Innodb_buffer_pool_size = 963M Innodb_flush_log_at_timeout = 3 Innodb_read_io_threads = 32 Innodb_write_io_threads = 16



/etc/init.d/apache2 restart

/etc/init.d/mysql restart



*****  여기까지 했지만 cacti server IP 접근을 해도 500 error 만 나오고 정상적으로 열리지 않았다.

온갖 구글링을 해서 php7.0 버전이 너무 높아 호환성 에러가 나는 것을 찾았다.

apt-get install libapache2-mod-php

apt-get install php-curl

apt-get install php-mysql


추가 설치 후 정상 접속 가능



##    cacti 접속 후 기본 setup

http://[cacti server IP address]

default account 

admin  //  admin





참고 url

https://www.blackhillsinfosec.com/how-to-install-cacti-on-ubuntu/

https://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_function&wr_id=391359

https://github.com/spotweb/spotweb/issues/134

https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/setup-cacti-network-monitoring-tool-on-ubuntu-14-04-linux-mint-17.html





by 초보인척 2018. 5. 9. 15:17

LG그램에서 터치패드 Fn+F5 가 죽어도 안된다.ㅠㅠㅠㅠ


이유를 여러가지 찾아봤는데, 보통의 터치패드는 시냅틱 터치패드라는 제품이 들어가 있어 웬만하면 지원 하지만,


이노무 LG그램은 Elantech Touchpad 뭐 암튼 이런거다...그래서 안되는거 같다.


안되면 되게 해야지....



방법을 찾다가


스크립트 만들어서 돌려버렸다.



vi /usr/local/sbin/toggleTouchpad


#!/bin/bash


tgid=`xinput list | grep Elantech | awk '{ print $6 }' | sed 's/id=//g'`


status=`xinput list-props ${tgid} | grep Device\ Enabled | sed -e 's/.*\:[ \t]\+//g'`


if [ 1 == $status ] ; then

xinput disable $tgid

else

xinput enable $tgid

fi



저장하고, 

chmod 755 /usr/local/sbin/toggleTouchpad


키보드 사용자 키 등록에


윈도우+F5 로 등록했다. 키보드 단축키 등록에 Fn키 등록이 되지 않아 쓸모 없는 윈도우키로 조합했다.



아주 잘되네...아휴 속 시원해




by 초보인척 2016. 10. 18. 13:45

xenserver 이용중 메모리는 여유가 있는데, 디스크 full 로 더이상 VM생성이 안되는 상황이었다.


아래는 xenserver HDD 추가 장착을 위한 방법이다.


필수!

디스크를 장착하기전 다른 OS에서 ext3로 포맷 후 xenserver에 장착하기 바란다.

이거 때문에 몇시간 애먹었다.

그냥 새 하드를 장착하니 xenserver 부팅시 boot error 나면서 먹통되더라 ㅠㅠ



위 내용이 완료 됐다는 가정하에...


1. Disk id 찾기

# cat /proc/partitons

[root@xenserver-AH ~]# cat /proc/partitions 

major minor  #blocks  name


   7        0      52378 loop0

   8        0  976762584 sda

   8        1    4193297 sda1

   8        2    4193297 sda2

   8        3  968372935 sda3

   8       16  976762584 sdb

   8       17  976760832 sdb1

   8       32  488386584 sdc

   8       33  488384001 sdc1

 252        0       4096 dm-0

 252        1  105070592 dm-1

 253        0  104857600 tda

 252        2  105070592 dm-2

 253        1  104857600 tdb

 252        3   52539392 dm-3

 253        2   52428800 tdc

 252        4  105070592 dm-4

 252        5  105070592 dm-5

 252        6    9310208 dm-6

 253        3  104857600 tdd

 253        4  104857600 tde

 253        5     116404 tdf

 252        7       4096 dm-7

 252        8  105070592 dm-8

 253        6  104857600 tdg

 253        7    4251346 tdh



# ll /dev/disk/by-id
[root@xenserver-AH ~]# ll /dev/disk/by-id


2. host uuid 가져오기
# xe host-list
[root@xenserver-AH ~]# xe host-list
uuid ( RO)                : ba9e358e-12ce-4f5c-b973-adac4ce0f261
          name-label ( RW): xenserver-AH
    name-description ( RW): Default install of XenServer

host uuid 는 PDB를 가지고 있는 physical machine 의 uuid 이다.


3. SR 만들기

이렇게 알아낸 정보를 가지고 Storage Repository(SR) 을 만들 수 있다.


# xe sr-create content-type=user device-config:device=/dev/disk/by-id/<scsi-xxxxxxxxxxxxxxxxxxxxxxxxx> host-uuid=<host-uuid> name-label=”Local Storage 2” shared=false type=lvm



도움주신 url

http://www.odaeng.net/?document_srl=2485&mid=xen&order_type=desc&listStyle=viewer

http://www.notaphone.com/?p=386

by 초보인척 2015. 8. 19. 17:01

리눅스에서 윈도우로 원격 접속(RDP) 이용 시 잘 사용했던 프로그램이다.


근데 어느날 갑자기 접속이 되지 않는다는 메시지가 나와서 당황했다.


구글링을 통해 문제 해결을 할 수 있었다.


knownhosts 의 정보와 대상 장비의 정보가 달라 생기는 현상입니다. 리미너의 knownhosts 정보는 ~/.freerdp/known_hosts 에 저장됩니다. 해당 장비 정보를 삭제(혹은 수정) 해 다시 접속을 시도해 보세요.


멀쩡히 잘 사용하고 있던게 정보가 왜 깨지는지는 알 수 없지만,,,,그렇단다..ㅎㅎ


저기서 수정한 다음에 다시 해보니 잘 된다.


도움주신 url

http://snucse-dev.shapado.com/questions/remina-remote-desktop-client


by 초보인척 2015. 6. 12. 11:31

인민에어에 우분투 14.04 LTS를 설치하여 잘 사용하고 있었다.


근데 이놈의 노트북이 한/영키가 먹질 않는다 ㅠㅠ


한/영 변환을 하려면 Ctrl + SpaceBar 조합으로 바꿀 수 있다. 여간 불편한게 아니다.


그래서 

방법을 찾던 중 발견했다.


1. 터미널 창에서

ibus-setup 입력. "속성 패널 보이기" - "표시하지 않기"


2. 시스템설정 - 키보드 - 바로가기 - 자판입력 - 구성키 [오른쪽 Alt]

시스템설정 - 키보드 - 바로가기 - 런처 - 허드 [왼쪽 Alt]


3. 텍스트 입력창 설정 - 이전 소스로 전환 - 한/영키 입력(Multi_key)로 들어가면 정상 등록



도움주신 url

http://blog.daum.net/bagjunggyu/154


by 초보인척 2015. 4. 9. 09:52
| 1 2 3 4 ··· 6 |