티스토리 뷰



Linux Server 를 운용하다보면 각종 보안패치나, Driver Update를 위한 Kernel Upgrade 등으로 인해


System Library 나 연관 패키지등이 교체 될 때가 있다.


이때 문제되는 것이 Dependuncy 즉 시스템 의존성이다.



Linux OS에서 실행되는 여러 Process들은 OS에서 제공되는 System Library 나 각종 패키지에서 제공되는 Process등 간에 상호 의존성을 갖게된다.


때문에 관련 패키지의 교체로 인해 의도치 않은 Process 오류를 만날 수 있다.


물론 Yum Repository를 통해 제공되는 모든 RPM Package는 Update나 Install 시 자동으로 연관 의존성 패키지를 검색하여 함께 처리해 주기때문에 문제가 없지만,


특정 Vendor를 통해 제공되는 제품이나 Souce Complie등으로 설치되는 Software들은 이러한 작업전에 반드시 시스템 의존성 검사를 수행하여,


작업 후에 서비스 제공에 문제가 없는 지를 점검해야한다.


이러한 과정이 필요할 경우 아래와 같이 작성된 Shell Script로 간단히 의존성 관계를 확인하고 관련 Package를 확인 할 수 있다.



1. WEB Server 용도로 사용중인 Linux OS에 Apache Process 의존성 관계 확인 및 관련 Package 조회하기


[root@TEST01 shell]#
[root@TEST01 shell]# ps -ef | grep http
root     17325     1  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17327 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17328 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17329 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17330 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17331 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17332 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17333 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
apache   17334 17325  0 11:24 ?        00:00:00 /usr/sbin/httpd
root     17918 16701  0 11:25 pts/0    00:00:00 grep http
[root@TEST01 shell]#
[root@TEST01 shell]#
[root@TEST01 shell]#
[root@TEST01 shell]#
[root@TEST01 shell]# ./check_lib.sh

Usage1 - ./check_lib.sh [Process Name]
ex1) - ./check_lib.sh httpd

[root@TEST01 shell]#
[root@TEST01 shell]#
[root@TEST01 shell]# ./check_lib.sh httpd

[root@s-node01 shell]#
[root@s-node01 shell]# ./check_lib.sh httpd
[ httpd ] Used - /lib64/ld-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libc-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libcom_err.so.2.1 :::::  Check Package - e2fsprogs-libs-1.39-33.el5
[ httpd ] Used - /lib64/libcrypt-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libcrypto.so.0.9.8e :::::  Check Package - openssl-0.9.8e-37.el5_11
[ httpd ] Used - /lib64/libdb-4.3.so :::::  Check Package - db4-4.3.29-10.el5_5.2
[ httpd ] Used - /lib64/libdl-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libexpat.so.0.5.0 :::::  Check Package - expat-1.95.8-8.3.el5_5.3
[ httpd ] Used - /lib64/libgcc_s-4.1.2-20080825.so.1 :::::  Check Package - libgcc-4.1.2-52.el5
[ httpd ] Used - /lib64/libkeyutils-1.2.so :::::  Check Package - keyutils-libs-1.2-1.el5
[ httpd ] Used - /lib64/libm-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libnsl-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libnss_files-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libpcre.so.0.0.1 :::::  Check Package - pcre-6.6-6.el5_6.1
[ httpd ] Used - /lib64/libpthread-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libresolv-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libselinux.so.1 :::::  Check Package - libselinux-1.33.4-5.7.el5
[ httpd ] Used - /lib64/libsepol.so.1 :::::  Check Package - libsepol-1.15.2-3.el5
[ httpd ] Used - /lib64/libssl.so.0.9.8e :::::  Check Package - openssl-0.9.8e-37.el5_11
[ httpd ] Used - /lib64/libutil-2.5.so :::::  Check Package - glibc-2.5-123.el5_11.1
[ httpd ] Used - /lib64/libuuid.so.1.2 :::::  Check Package - e2fsprogs-libs-1.39-33.el5
[ httpd ] Used - /lib64/libz.so.1.2.3 :::::  Check Package - zlib-1.2.3-4.el5
[ httpd ] Used - /usr/lib64/httpd/modules/libphp5.so :::::  Check Package - php-5.1.6-32.el5
[ httpd ] Used - /usr/lib64/httpd/modules/mod_actions.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_alias.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_auth_basic.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_auth_digest.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authn_alias.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authn_anon.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authn_dbm.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authn_default.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authn_file.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authnz_ldap.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_dbm.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_default.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_groupfile.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_host.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_owner.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_authz_user.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_autoindex.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_cache.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_cgi.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_dav.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_dav_fs.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_deflate.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_dir.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_disk_cache.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_env.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_expires.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_ext_filter.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_file_cache.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_headers.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_include.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_info.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_ldap.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_log_config.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_logio.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_mem_cache.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_mime.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_mime_magic.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_negotiation.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_perl.so :::::  Check Package - mod_perl-2.0.4-6.el5
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy_ajp.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy_balancer.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy_connect.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy_ftp.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_proxy_http.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_python.so :::::  Check Package - mod_python-3.2.8-3.1
[ httpd ] Used - /usr/lib64/httpd/modules/mod_rewrite.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_setenvif.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_speling.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_ssl.so :::::  Check Package - mod_ssl-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_status.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_suexec.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_userdir.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_usertrack.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_version.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/httpd/modules/mod_vhost_alias.so :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /usr/lib64/libapr-1.so.0.2.7 :::::  Check Package - apr-1.2.7-11.el5_6.5
[ httpd ] Used - /usr/lib64/libaprutil-1.so.0.2.7 :::::  Check Package - apr-util-1.2.7-11.el5_5.2
[ httpd ] Used - /usr/lib64/libaspell.so.15.1.3 :::::  Check Package - aspell-0.60.3-12
[ httpd ] Used - /usr/lib64/libbz2.so.1.0.3 :::::  Check Package - bzip2-libs-1.0.3-6.el5_5
[ httpd ] Used - /usr/lib64/libcurl.so.3.0.0 :::::  Check Package - curl-7.15.5-15.el5
[ httpd ] Used - /usr/lib64/libdistcache.so.1.0.1 :::::  Check Package - distcache-1.4.5-14.1
[ httpd ] Used - /usr/lib64/libgmp.so.3.3.3 :::::  Check Package - gmp-4.1.4-10.el5
[ httpd ] Used - /usr/lib64/libgssapi_krb5.so.2.2 :::::  Check Package - krb5-libs-1.6.1-70.el5
[ httpd ] Used - /usr/lib64/libidn.so.11.5.19 :::::  Check Package - libidn-0.6.5-1.1
[ httpd ] Used - /usr/lib64/libk5crypto.so.3.1 :::::  Check Package - krb5-libs-1.6.1-70.el5
[ httpd ] Used - /usr/lib64/libkrb5.so.3.3 :::::  Check Package - krb5-libs-1.6.1-70.el5
[ httpd ] Used - /usr/lib64/libkrb5support.so.0.1 :::::  Check Package - krb5-libs-1.6.1-70.el5
[ httpd ] Used - /usr/lib64/liblber-2.3.so.0.2.31 :::::  Check Package - openldap-2.3.43-25.el5
[ httpd ] Used - /usr/lib64/libldap-2.3.so.0.2.31 :::::  Check Package - openldap-2.3.43-25.el5
[ httpd ] Used - /usr/lib64/libnal.so.1.0.1 :::::  Check Package - distcache-1.4.5-14.1
[ httpd ] Used - /usr/lib64/libpspell.so.15.1.3 :::::  Check Package - aspell-0.60.3-12
[ httpd ] Used - /usr/lib64/libpython2.4.so.1.0 :::::  Check Package - python-libs-2.4.3-46.el5
[ httpd ] Used - /usr/lib64/libsasl2.so.2.0.22 :::::  Check Package - cyrus-sasl-lib-2.1.22-5.el5_4.3
[ httpd ] Used - /usr/lib64/libstdc++.so.6.0.8 :::::  Check Package - libstdc++-4.1.2-52.el5
[ httpd ] Used - /usr/lib64/libxml2.so.2.6.26 :::::  Check Package - libxml2-2.6.26-2.1.12.el5_7.2
[ httpd ] Used - /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so :::::  Check Package - perl-5.8.8-42.el5
[ httpd ] Used - /usr/lib64/php/modules/dbase.so :::::  Check Package - php-common-5.1.6-32.el5
[ httpd ] Used - /usr/lib64/php/modules/ldap.so :::::  Check Package - php-ldap-5.1.6-32.el5
[ httpd ] Used - /usr/sbin/httpd :::::  Check Package - httpd-2.2.3-63.el5.centos
[ httpd ] Used - /var/log/httpd/access_log :::::  Check Package - file /var/log/httpd/access_log is not owned by any package
[ httpd ] Used - /var/log/httpd/error_log :::::  Check Package - file /var/log/httpd/error_log is not owned by any package
[ httpd ] Used - /var/log/httpd/ssl_access_log :::::  Check Package - file /var/log/httpd/ssl_access_log is not owned by any package
[ httpd ] Used - /var/log/httpd/ssl_error_log :::::  Check Package - file /var/log/httpd/ssl_error_log is not owned by any package
[ httpd ] Used - /var/log/httpd/ssl_request_log :::::  Check Package - file /var/log/httpd/ssl_request_log is not owned by any package



::::: Process [ httpd ] Dependency OS RPM Package List - 34 :::::


apr-1.2.7-11.el5_6.5
apr-util-1.2.7-11.el5_5.2
aspell-0.60.3-12
bzip2-libs-1.0.3-6.el5_5
curl-7.15.5-15.el5
cyrus-sasl-lib-2.1.22-5.el5_4.3
db4-4.3.29-10.el5_5.2
distcache-1.4.5-14.1
e2fsprogs-libs-1.39-33.el5
expat-1.95.8-8.3.el5_5.3
glibc-2.5-123.el5_11.1
gmp-4.1.4-10.el5
httpd-2.2.3-63.el5.centos
keyutils-libs-1.2-1.el5
krb5-libs-1.6.1-70.el5
libgcc-4.1.2-52.el5
libidn-0.6.5-1.1
libselinux-1.33.4-5.7.el5
libsepol-1.15.2-3.el5
libstdc++-4.1.2-52.el5
libxml2-2.6.26-2.1.12.el5_7.2
mod_perl-2.0.4-6.el5
mod_python-3.2.8-3.1
mod_ssl-2.2.3-63.el5.centos
openldap-2.3.43-25.el5
openssl-0.9.8e-37.el5_11
pcre-6.6-6.el5_6.1
perl-5.8.8-42.el5
php-5.1.6-32.el5
php-common-5.1.6-32.el5
php-ldap-5.1.6-32.el5
python-libs-2.4.3-46.el5
zlib-1.2.3-4.el5 




2. Shell Script 작성하기


[root@TEST01 shell]# vi ./check_lib.sh


#!/bin/bash

export LANG=C
export LC_ALL=C
TMP_FILE=/tmp/imsi.list
declare -a ARRAY_PACKAGE
rm -f ${TMP_FILE}


if [ $# -ne 1 ]
then
        echo
        echo "Usage1 - $0 [Process Name]"
        echo "ex1) - $0 httpd"
        echo
        exit 0
fi


CHECK_PROC=$1

PROC_LIB_LIST=`lsof | awk '$1 ~ /'"^${CHECK_PROC}$"'/ {print $9}' | sort -u | uniq | egrep -v 'grep|^\*|^\/$|^\/dev' | grep "^\/"`

for LIST in ${PROC_LIB_LIST}
do
 CHECK_PACKAGE=`rpm -qf ${LIST}`
 ARRAY_PACKAGE=("${ARRAY_PACKAGE[@]}" "${CHECK_PACKAGE}")
 echo -e "[ $1 ] Used - ${LIST} :::::\t Check Package - ${CHECK_PACKAGE}"
done

echo


LOOP_COUNT=0
LOOP_LIMIT=${#ARRAY_PACKAGE[@]}
while [ "${LOOP_COUNT}" -le "${LOOP_LIMIT}" ]
do
 echo "${ARRAY_PACKAGE[${LOOP_COUNT}]}" >> ${TMP_FILE}
 LOOP_COUNT=`echo "${LOOP_COUNT} + 1" | bc`
done0

DEPENDENCY_COUNT=`grep -v "not owned by any package" ${TMP_FILE} | sort -u | uniq | wc -l`


echo
echo "::::: Process [ $1 ] Dependency OS RPM Package List - ${DEPENDENCY_COUNT} :::::"
grep -v "not owned by any package" ${TMP_FILE} | sort -u | uniq











반응형
반응형
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday