728x90
반응형

 

RPM 패키지 업데이트가 있어 yum으로 설치했다.
현재 설정과 맞지 않아 yum으로 삭제했다.

 

*문제
실행파일은 /usr/bin/에 있는데 /usr/local/bin에 있는 파일을 실행하려고 한다.

 

    ~$tmux
    -bash: /usr/local/bin/tmux: No such file or directory
    ~$which tmux
    /usr/bin/tmux
    ~$echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

 

기존에 설치되어 있던 패키지를 재설치했으나 동일한 문제가 발생한다.

 

*해결
hash -r 을 이용하여 bash의 cache(캐시)를 없애 주면 된다.

 

hash -r

 

#linux #path #경로문제 #bash #hash

728x90
SMALL
Posted by gromet
728x90
반응형

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

 

신규 사이트 vhost 설정을 추가하고 graceful을 시켰는데,
갑자기 이런 메세지가...

 

 
[root@lease10feb ~]# apachectl graceful
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

 

등에 식은 땀이 흐른다.
서비스에는 이상이 없는 것을 확인한다.
일단 퇴근 이후 까지 기다린다.

 

확인해 보니 /var/run/httpd.pid 가 없다.
생각해 보니 monit으로 서버 부하를 모니터링하여 일정 부하이상 올라가면 httpd를 재시작하도록 설정해 놓았는데,
오늘 그 작업이 있었고, 그로 인해 문제가 생긴 것 같다.
monit의 상태는 아래와 같았다.

 

 
[root@lease10feb ~]# monit summary
The Monit daemon 5.5 uptime: 244d 11h 18m

System 'lease10feb.dreamtec.co.kr'  Running
Process 'httpd'                     Execution failed

 

'restart'를 해야하나? 'killall httpd'를 해야하나? 고민한다.

 

[수정2023.05.30] apachectl 옵션을 보니 reload가 있다. 없다. 
/etc/init.d/httpd 에 reload 옵션이 있다.

 

 
[root@lease10feb ~]# apachectl
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
 
[root@lease10feb ~]# /etc/init.d/httpd
Usage: httpd {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}

reload를 해 본다.
httpd.pid가 생겼다.
graceful을 해 본다. 잘 된다.

 

#아파치 #apache #httpd #monit #apachectl

 

 

728x90
SMALL
Posted by gromet
728x90
반응형

아파치 프록시로 다른 서버의 사이트 서비스 하기

 

 

2대의 서버를 운영중이다.
A 서버에서 서비스 중인 사이트를
B 서버에서 함께 서비스를 하고 싶다.

첫번째는 일반적으로 하는 것처럼 데이터를 복사하고 똑같이 세팅하여 서비스를 하면 된다.
두번째는 프로그램 버전 차이 문제나, 데이터를 복사할 수 없을 때 등 프록시를 이용하여 세팅할 수 있다.

사용된 아파치 버전은 아래와 같다.

[root@test httpd]# httpd -v
Server version: Apache/2.2.22 (Unix)
Server built: Feb 23 20xx 12:27:57

 

VirtualHost를 아래와 같이 작성한다.
핵심은 Proxy~ 부분이다.

 

<VirtualHost *:80>
ServerName mydomain1.com
ServerAlias *.mydomain1.com mydomain1.com
ServerAdmin webmaster@mydomain1.com
ErrorLog logs/mydomain1.com-error_log
SetEnvIf Request_URI "favicon.ico" do_not_log
CustomLog logs/mydomain1.com-access_log Combined env=!do_not_log
ProxyPreserveHost On
ProxyPass / http://mydomain2.com:80/
ProxyPassReverse / http://mydomain2.com:80/
ProxyRemote * http://mydomain2.com:80/
</VirtualHost>

 

아파치를 재시작 해 주면 된다.

 

#아파치 #프록시 #apache #proxy

 

728x90
SMALL
Posted by gromet
728x90
반응형

발신자 메일 주소별로 다른 수신자에게 전달는 방법

 

<상황설명>
사용자에게 advertisement@domain.com에서 메일이 들어오고 이 메일 주소의 모든 메일을 검출하여 sysadmin@domain.com으로 전달하고 싶다.

<적용방법>
postfix의 header_checks를 이용하여 redirect 하면 된다.

 

/^From:(.*)advertisement@domain.com/ REDIRECT sysadm@domain.com

 

<참고사이트>
https://wiki.zimbra.com/wiki/How_to_redirect_mails_from_specific_email_to_one_user

 

How to redirect mails from specific email to one user - Zimbra :: Tech Center

How to redirect emails from specific e-mail address to a specific user Resolution In this article we will see how to redirect an email from a specific email address to a designated user. For example you have emails coming from advertisement@domain.com that

wiki.zimbra.com

 

#postfix #header_checks #redirect

728x90
SMALL
Posted by gromet
728x90
반응형

MySQL 데이터베이스 이전하기 euckr->utf8

오래전 구축 된 시스템을 이전 하려니 걸리는 것이 참 많다.

 

1. MySQL3 -> MySQL5로 이전하기
2. euckr 데이터를 utf8로 이전하기

 

1. MySQL3->MySQL5 로 이전
데이터는 다음과 같이 추출하였다.

#덤프
mysqldump --skip-extended-insert --skip-quote-names --default-character-set=latin1 --compatible=mysql40 -uuser -ppass -h192.168.100.1 db > db.sql

 

복원을 했더니 아래와 같이 오류가 난다.

mysql -uuser -ppass db < db.sql
ERROR 1064 (42000) at line 18: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TYPE=MyISAM' at line 14

 

MySQL3에서 덤프를 한 것이라 지금은 없어진 TYPE이라는 키워드 때문이다.
편집기나 vi를 이용해서 ENGINE으로 변경해 주면 된다.

#vi 사용시
:%s/TYPE/ENGINE/
62 substitutions on 62 lines 74559,1 99%

 

 

2. ecukr을 utf8로 이전하기

위와 같이 이전을 했는데 한글이 모두 제대로 표현되지 않는다.
몇 번의 시도를 했는데 그 때마다 '?????' 이거나 깨진 문자로 표시된다.
성공한 방법만 기술해 보면.

1) 위에서와 같이 덤프한다

#덤프
mysqldump --skip-extended-insert --skip-quote-names --default-character-set=latin1 --compatible=mysql40 -uuser -ppass -h192.168.100.1 db > db.sql

 

2) utf8로 변환한다

2)-1 편집기(editplus)를 이용해서 UTF8(BOM없음)로 저장한다
또는 iconv로 변환한다.
2)-2 iconv -f euckr -t utf8 db.sql -c > db-2.sql
putty 터미널을 UTF8로 맞추고 아래와 같이 하여 한글이 제대로 보이는지 확인한다.
cat db-2.sql | more

 

3) 데이터베이스를 만들고 복원한다

데이터베이스를 만들 때 utf8로 지정한다.
#복원
mysql -uuser -ppass db < db-2.sql

 

4) 이렇게 하면 끝~ 일줄 알았는데...
heidisql 을 통해서 보면 한글 데이터들이 잘 보이는데, php를 통해서 사이트에서는 여전히 깨져 보인다.
아래와 같이 euckr로 변경해 주어야 한다.
참 이해가 안되는 부분이다.

데이터베이스 접속 관련 소스에 맨 마지막 줄을 아래와 같이 추가한다.
물론 실패한 부분은 빼고.

<?php
$dbip="192.168.100.2";
$dbid="user";
$dbpasswd="pass";
$dbname="db";

$connect = mysql_connect($dbip, $dbid, $dbpasswd) or die("please dbconnection confirm~!");
mysql_select_db($dbname,$connect);


//mysql_query("SET NAMES 'UTF8'",$connect); ==> 실패
//mysql_set_charset('utf8', $connect); ==> 실패
mysql_set_charset('euckr', $connect); ==> 성공
?> 

 

 

끝~

 

#mysql3 #mysql5 #euckr #utf8

728x90
SMALL
Posted by gromet
728x90
반응형

Postfix + header_checks in MySQL

 
In this tip I will describe how to implement Postfix header_checks along with MySQL . No blablabla....let's get straight to the point. For everything to work it is necessary to have MySQL installed. On Debian like distributions, type the following command to install the MySQL server: # apt-get install mysql-server-5.5 After that, follow the installation steps that will be described on the screen. Log in as ROOT in your MySQL and create the database "postfix", or any other name that is easy to identify: # mysql -u root -p CREATE DATABASE postfix; Enter the postfix database to be able to create the table inside it: use postfix;

Now create the header_checks table with the following command:

CREATE TABLE `header_checks` (
  `hc_id` int(11) NOT NULL AUTO_INCREMENT,
  `rule` varchar(255) NOT NULL,
  `action` varchar(255) NOT NULL,
  PRIMARY KEY ( `hc_id`),
  KEY `rule` (`rule`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

Postfix preparation

I believe that you must already have Postfix installed on your server, there are already several articles dealing with its installation.

We will now create the configuration file for communicating with MySQL:

# vi /etc/postfix/header_checks.cf

Put this content inside the file we are editing:
user = YOUR_BANK_USER_postfix
password = YOUR_BANK_PASSWORD_postfix
hosts = IP_or_YOUR_Server_NAME
dbname = DATABASE_NAME_postfix
query = SELECT action FROM header_checks WHERE '%s' REGEXP rule LIMIT 0.1
Next step is to edit the configuration in the /etc/postfix/main.cf file , if you don't already have the line below, add it:
header_checks = mysql:/etc/postfix/header_checks.cf
With these steps completed, we just have to restart postfix and populate the header_checks table in MySQL, which I will show the correct syntax below.

# /etc/init.d/postfix restart

Creating check rules in MySQL

Here we don't have many secrets, what gave me more work was finding the correct syntax to write the rule, but I'll save you this hard work and pass the correct syntax the way I'm using it on my servers.

Access MYSQL:

# mysql -u root -p

use postfix;

INSERT INTO header_checks (`hc_id`, `rule`, `action`) VALUES (NULL, '^From:(.*)domain.com.br', 'DISCARD #SPAM Domain Detected');


Note that the syntax for REGEXP used by header_checks follows the following pattern:

^From:(.*)dominio.com.br

I particularly use this rule to block domains that usually send SPAMs, but we can use it, for example, to block messages with certain subjects, in this case the rule would look like this:

^Subject:(.*)PROPAGANDA

Well folks, that's it...

I hope the subject has been addressed in a clear and objective way.

Hugs.

Measure
Measure
 
 
728x90
SMALL
Posted by gromet

블로그 이미지
나는 운이 좋은 사람이다 나는 나날이 점점 더 좋아진다 내가 하는 선택과 행동은 반드시 성공으로 이어진다 내게는 인내력과 지속력이 있다 네게는 좋은것들만 모여든다
gromet

공지사항

Yesterday
Today
Total
반응형

달력

 « |  » 2024.7
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

160x600