Solaris Bind 자동 스크립

Posted 2010. 10. 11. 12:09

요즘은 편리하게 할려고 자동 스크립을 자주 찾게 되네요 -_-;  이러다가 명령어 다 까먹겠네요

OS : Solaris
Bind 실행 파일 : /usr/local/sbin/named
pid 위치 : /var/run/named.pid


# cd /var/named                <- 자동 스크립 파일 저장 위치

# cat >> Bind_named.sh          <- 자동 스크립 파일 생성

---------------------------------------------------------------------------------------
#!/bin/sh
#

# Control the Internet name servic

PATH=/sbin:/usr/sbin:/usr/bin:/bin
export PATH

[ -f /etc/named.conf ] || exit 0
case "$1" in
     'start')
           if [ -x /usr/local/sbin/named ];
           then
                /usr/local/sbin/named;
                echo "Internet name service started"
           fi
           ;;
    'stop')
           if [ -r /var/run/named.pid ];
           then
               Pid=`cat /var/run/named.pid`
               kill -9 $Pid
               sleep 2
               echo "Internet name service stopped"
           fi
           ;;
   'restart')
          if [ -r /var/run/named.pid ];
          then
              Pid=`cat /var/run/named.pid`
              kill -1 $Pid
              sleep 5
              echo "Internet name service restarted"
          fi
          ;;
  *)
          echo "usage: $0 {start|stop|restart}"
          exit 1
esac

exit 0


Ctrl + C                      
---------------------------------------------------------------------------------------




# chmod 744 Bind_named.sh              <- 자동 스크립 권한

# cd /etc/rc2.d                                 <- 자동 스크립 파일을 링크로 걸 위치

# ln -s /var/namd/Bind_named.sh S10named              <- 자동 스크립 파일을 링크 거는 명령어


이렇게 하면 Server 재부팅시 자동으로 실행이 진행됨












 

Solaris8 (SPARC) APM 과 보안서버(SSL)설치

 


현재 제가 직접 설치한것을 토대로 글을 작성합니다. (2009.09.30)


환경 : Solaris 8 SPARC


1.
필요한  APM 및 라이브러리  다운

 

http://sunfreeware.com  에서 접속하여 오른쪽에 있는 해당 하드웨어 사항들을 체크한 다음  클릭하여  아래에 적힌 목록들을 다운

apache-2.2.9-sol8-sparc-local.gz
mysql-5.0.67-sol8-sparc-local.gz
ncurses-5.6-sol8-sparc-local.gz
php-5.2.6-sol8-sparc-local.gz
expat-2.0.1-sol8-sparc-local.gz
openldap-2.4.11-sol8-sparc-local.gz
sasl-2.1.21-sol8-sparc-local.gz
gcc-3.4.6-sol26-sparc-local.gz
libgcc-3.4.6-sol26-sparc-local.gz
libiconv-1.11-sol26-sparc-local.gz
libintl-3.4.0-sol26-sparc-local.gz
libxml2-2.6.31-sol26-sparc-local.gz
openssl-0.9.8i-sol26-sparc-local.gz
zlib-1.2.3-sol26-sparc-local.gz
libidn-1.10-sol8-sparc-local.gz
libpng-1.2.33-sol8-sparc-local.gz
curl-7.19.1-sol8-sparc-local.gz
fontconfig-2.4.2-sol8-sparc-local.gz
freetype-2.3.1-sol8-sparc-local.gz
gd-2.0.35-sol8-sparc-local.gz
jpeg-6b-sol8-sparc-local.gz
xpm-3.4k-sol8-sparc-local.gz


새로 Server를 설치하였다면 위의 목록들을 모두 받아놓는게 정신건강상 좋습니다.


~ 필요한거에요.


~ 혹시 위에 버젼보다 높은 버젼이 나왔다면 그걸 받아서 설치하셔도 됩니다.


위의 파일들은 모두 패키지 형식이기 때문에 gzip으로 압축만 풀고 간단한 명령어가 치면 자동으로

설치 됩니다.


) #  gzip -d gcc-3.4.6-sol26-sparc-local.gz


이렇게 모두 압축을 풀어주세요

압축을 풀게 되면 gcc-3.4.6-sol26-sparc-local 이렇게만 남습니다.


그다음 패키지를 풀면됩니다.


) # pkgadd -d gcc-3.4.6-sol26-sparc-local

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:  all

이렇게 모두 파일이름만 바꾸고 설치 하시면 됩니다.

 


2. PATH
설정


밑의 내용을 /etc/profile 에서 넣어주시면 됩니다.


# vi /etc/profile
# for Apache located at /usr/local/apache2
if [ -d /usr/local/apache2 ]
then
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apache2/lib; export LD_LIBRARY_PATH
  PATH=$PATH:/usr/local/apache2/bin; export PATH;
fi
# for MySQL located at /usr/local/mysql
if [ -d /usr/local/mysql/lib/mysql ]
then
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql; export LD_LIBRARY_PATH
  PATH=$PATH:/usr/local/mysql/bin; export PATH;
fi



밑의 내용을 PATH  에 대해 적용 방법등을 적어놓았습니다.


현재 자신의 PATH 값을 보려면 아래와 같이 하면 됩니다.

# echo $PATH

 
그리고 PATH에 새로운 값을 추가하려면 아래와 같이 하면 됩니다.

 
# PATH=$PATH:/usr/local/bin:/usr/ccs/bin
# export PATH


위에서 /usr/local/bin /usr/ccs/bin 디렉토리를 추가했습니다. 이제 /usr/local/bin에 있는 명령어를 아무곳에서나 경로명 없이 실행할 수 있습니다.


하지만 위의 방법은 로그아웃하기 전까지만 유효합니다. 다시 로그인하면 또 위와 같이 PATH를 설정해줘야합니다.

그래서 이걸 자동적으로 적용되는 방법이 있는데 그건 사용자의 profile에 위의 내용들을 추가하는 겁니다.


# vi $HOME/.profile
PATH=$PATH:/usr/local/bin:/usr/ccs/bin
export PATH

만약 csh을 사용한다면 아래와 같이 하세요.

# vi $HOME/.login
setenv PATH $PATH:/usr/local/bin:/usr/ccs/bin



3. APM  설정


1) Apache


밑의 내용처럼  httpd.conf 파일을 수정해 주세요~!


# vi /usr/local/apache2/conf/httpd.conf
User nobody
Group nobody
daemon
으로 되어 있는걸 nobody로 수정


DefaultType text/plain
<IfModule mime_module> 
이부분에

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
위 두 내용을 추가.


LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module        modules/libphp5.so   
이부분 추가.

ServerName  192.168.1.69:80
IP
대신 도메인을 사용할 수 있음. test를 위해서는 일단 ip로 해도 괜찮아요.


Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-multilang-errordoc.conf
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-languages.conf
Include conf/extra/httpd-userdir.conf
Include conf/extra/httpd-info.conf
Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-manual.conf
Include conf/extra/httpd-dav.conf
Include conf/extra/httpd-default.conf
Include conf/extra/httpd-ssl.conf
위의 사항들을 사용하고 싶다면 # 주석을 없애면 됩니다.


# /usr/local/apache2/bin/apachectl start


혹시 에러가 생기다면 필요한 라이브러리를 설치하지 않아 생겼을 테니 꼭 라이브러리를 설치하시길 바랍니다.

 

부팅시 자동으로 Apache를 구동할 수 있도록 스크립을 작성하겠습니다.
위의 사항들을 제대로 구성하셨으면 /etc/init.d/apache  라는 파일이 만들어져 있을껍니다.
이건 그냥 무시하시고 저는 간단하게 하기 위해 짧게 할 예정이라 한줄 밖에 안됩니다.
          
#vi /etc/init.d/apache2

#!/sbin/sh
#
# apache starting script
#

/usr/local/apache2/bin/apachectl start

더 이상 없습니다.


# chown root:sys /etc/init.d/apache2
소유자와 그룹을 root : sys로 변경

# chmod 744 /etc/init.d/apache2
파일 권한은 744

# ln /etc/init.d/apache2 /etc/rc2.d/S99apache  
# ln /etc/init.d/apache2 /etc/rc1.d/K16apache
# ln /etc/init.d/apache2 /etc/rcS.d/K16apache
여기에 링크를 걸어주시면 부팅시 자동으로 Apache 데몬이 작동이 됩니다.

 


2) PHP

cp /usr/local/php/doc/php/php.ini-recommended /usr/local/php/lib/php.ini
/usr/local/php/doc/php/php.ini-recommended
/usr/local/php/lib/php.ini 복사합니다.


테스트를 위해 아래 내용을 새로 작성

# vi /usr/local/apache2/htdocs/index.php
<?
  phpinfo()
?>

확인방법은 http://192.168.1.69/index.php  (이건 저의 셋팅에 따라 만든거에요)
제대로 되었다면 밑의 그림이 나올껍니다. ~ 그리고 이 테스트는 APM 모두 설치 셋팅한다음 테스트를 하시길 바랍니다.





3) MySQL


# useradd -d /export/home/mysql -g staff -m -u 102 -s /bin/false mysql
MySQL
을 사용할 계정을 추가


# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf
/usr/local/mysql/share/mysql
my-huge.cnf, my-large.cnf, my-medium.cnf, my-small.cnf 의 예제 설정 파일이 있다. 이를 /etc/my.cnf 으로 이름을 바꿔 복사하면 된다.


skip-networking
#log-bin
리플리케이션을 사용하지 않는다면 [log-bin]을 찾아 주석처리하고 외부에서 접속이 없다면 [skip-networking]의 주석을 푼다.


# /usr/local/mysql/bin/mysql_install_db
기본 MySQL DB를 생성


# chown -R mysql:staff /usr/local/mysql/var
기본 MySQL DB가 생성되는  /usr/local/mysql/var 의 디렉토리 및 파일들의 소유자를 mysql  그룹은 staff로 변경


# /usr/local/mysql/share/mysql/mysql.server start
MySQL
서버를 시작
종료는 /usr/local/mysql/share/mysql/mysql.server stop


# /usr/local/mysql/bin/mysqladmin -u root password 'PASSWORD'
MySQL
root 패스워드를 변경
기본값은 없기 때문에 보안을 위해서 반드시 수정


# /usr/local/mysql/bin/mysqladmin -u root -h test -p password 'NEW-PASSWORD'
Enter password: PASSWORD
위처럼 하시면 새로운 패스워드로 변경이 됩니다. 위에서  test host 이름입니다.

 

 

부팅시 자동으로 Mysql를 구동할 수 있도록 스크립을 작성하겠습니다.

# vi /etc/init.d/mysql

#!/sbin/sh
#
# mysql starting script
#
 
/usr/local/mysql/bin/mysqld_safe &


# chown root:sys /etc/init.d/mysql
소유자와 그룹을 root : sys로 변경

# chmod 744 /etc/init.d/mysql
파일 권한은 744

# ln /etc/init.d/mysql /etc/rc2.d/S99mysql  

이렇게 하면 mysql도 부팅시 자동으로 데몬이 올라오게 됩니다.

 

 

 


 

4. 보안서버(SSL) 설치 및 설정

 


1) openssl 을 이용하여 key 파일 생성 및 csr 코드 생성

 

일단 ssle 인증서 키와 파일들을 저장할 디렉토리를 만들어놓습니다.

# mkdir /usr/local/apache2/conf/ssl

# cd /usr/local/apache2/conf/ssl

 

Ps. 꼭 개인키와 csr 코드 등은 복사등을 해서 백업을 해주시길 바랍니다.

 

- 개인Key 파일 생성

# openssl genrsa -des3 1024 > m-sys_co_kr.key

 

Generating RSA private key, 1024 bit long modulus

.................................++++++

...............++++++

e is 65537 (0x10001)

Enter pass phrase:  <- 암호 필히 기억 (apache 실행시 사용함)

Verifying - Enter pass phrase:

 

만약 apache 실행시 암호를 사용하지 않고 사용하실려면 아래의 명령어를 통해 개인키를 생성하시길 바랍니다.

 

# openssl genrsa 1024 > m-sys_co_kr.key

 

 

 

- csr 코드 생성

# openssl req -new -key m-sys_co_kr.key -out m-sys_co_kr.csr

 

Enter pass phrase for m-sys_co_kr.key:

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [AU]:KR

State or Province Name (full name) [Some-State]:Busan

Locality Name (eg, city) []:BusanJin

Organization Name (eg, company) [Internet Widgits Pty Ltd]:Minerva Systems   <-회사명

Organizational Unit Name (eg, section) []:Technical Support Team   <-소속 부서

Common Name (eg, YOUR name) []:www.m-sys.co.kr    <-홈페이지 도메인

Email Address []:***@m-sys.co.kr

 

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:    <- 암호 필히 기억

An optional company name []:


 

 

- csr 코드 확인(보안상 *** 처리하였습니다)

# cat m-sys_co_kr.csr

 

-----BEGIN CERTIFICATE REQUEST-----

MIIB/jCCAWcCAQAwgagxCzAJBgNVBAYTAktSMQ4wDAYDVQQIEwVCdXNhbjERMA8G

A1UEBxMIQnVzYW5KaW4xGDAWBgNVBAoTD01pbmVydmEgU3lzdGVtczEfMB0GA1UE

***********************

934AJEaN5VPO3RJR6w4O2GwW/AM3iNuNr2IaBJmfKip9gA==

-----END CERTIFICATE REQUEST-----

 

공공기관이나 교육기관 등등에서 사용하기 위해서는 위에 생성된 csr 코드를 SSL 인증키 업체에게 메일이나 웹으로 이 파일을 보내서 인증키 발급을 신청해야합니다.

 

메일이나 웹으로 csr 내용을 SSL 인증키 업체에게 보내서 인증서 발급을 받으면 key csr 파일이 있는 경로(저의 경우는  /usr/local/apache2/conf/ssl) ftp를 이용하시던 다른 어떤수를 사용해서라도 넣어놓으세요.  ㅎㅎ

 

자체 인증서를 만들어서 테스트하는 방법은 뒤에서 설명하도록 하겠습니다.

 

 

2) SSL을 사용하기 위한 httpd.conf & httpd-ssl.conf 수정

 

어떤 파일 형식으로 인증서를 받으실지 모르겠지만 대충 m-sys_co_kr.pem 으로 받았다고 가정하고 시작하도록 하겠습니다.

 

저는 그냥 m-sys_co_kr.pem 파일을 복사해서 이름을 바꾸어서 사용하였습니다.

 

# cp m-sys_co_kr.pem  m-sys_co_kr.crt

 

 

먼저 위에서 Apache의 옵션 httpd.conf 파일안에 있는

Include conf/extra/httpd-vhosts.conf

Include conf/extra/httpd-ssl.conf  이 두 부분에서 주석처리를 없애버렸기 때문에 바로 httpd-ssl.conf 를 수정하겠습니다.

 

 

# vi /usr/local/apache2/conf/extra/httpd-ssl.conf

 

 

##

## SSL Virtual Host Context

##

 

<VirtualHost 210.*.223.*:443> <-이부분 수정 해당 IP (보안상 * 표시하였습니다만.. -_-;)

 

#   General setup for the virtual host

DocumentRoot "/home1/homepage/www"   <- 수정

ServerName www.m-sys.co.kr:443  <- 수정

ServerAdmin kwonbk@m-sys.co.kr  <- 수정

ErrorLog "/usr/local/apache2/logs/m-sys.co.kr_ssl_error_log"  <- 알아서 수정하세요 ^^

TransferLog "/usr/local/apache2/logs/m-sys.co.kr_ssl_access_log" <- 이것도 ..

 

#   SSL Engine Switch:

#   Enable/Disable SSL for this virtual host.

SSLEngine on

 

#   SSL Cipher Suite:

#   List the ciphers that the client is permitted to negotiate.

#   See the mod_ssl documentation for a complete list.

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

 

#   Server Certificate:

#   Point SSLCertificateFile at a PEM encoded certificate.  If

#   the certificate is encrypted, then you will be prompted for a

#   pass phrase.  Note that a kill -HUP will prompt again.  Keep

#   in mind that if you have both an RSA and a DSA certificate you

#   can configure both in parallel (to also allow the use of DSA

#   ciphers, etc.)

SSLCertificateFile "/usr/local/apache2/conf/ssl/m-sys_co_kr.crt"  <- 발급받은 인증서 경로

#SSLCertificateFile "/usr/local/apache2/conf/server-dsa.crt"

 

#   Server Private Key:

#   If the key is not combined with the certificate, use this

#   directive to point at the key file.  Keep in mind that if

#   you've both a RSA and a DSA private key you can configure

#   both in parallel (to also allow the use of DSA ciphers, etc.)

SSLCertificateKeyFile "/usr/local/apache2/conf/ssl/m-sys_co_kr.key"  <- 개인키 경로

#SSLCertificateKeyFile "/usr/local/apache2/conf/server-dsa.key"

 

#   Server Certificate Chain:

#   Point SSLCertificateChainFile at a file containing the

#   concatenation of PEM encoded CA certificates which form the

#   certificate chain for the server certificate. Alternatively

 

#SSLCACertificateFile "/usr/local/apache2/conf/ssl.crt/ca-bundle.crt"  <- CA 있으면 추가~!

 

<FilesMatch "\.(cgi|shtml|phtml|php)$">

    SSLOptions +StdEnvVars

</FilesMatch>

<Directory "/usr/local/apache2/cgi-bin">

    SSLOptions +StdEnvVars

</Directory>

 

BrowserMatch ".*MSIE.*" \

         nokeepalive ssl-unclean-shutdown \

         downgrade-1.0 force-response-1.0

 

CustomLog "/usr/local/apache2/logs/ssl_request_log" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

 

</VirtualHost>

 


 

3) SSL 적용한 Apache 실행하기

 

이제 httpd-ssl.conf 파일을 저장하고 apache를 실행하시면 됩니다.

일단 테스트를 해서 옵션등에 에러가 없는지 확인하겠습니다.

 

# /usr/local/apache2/bin/apachectl –t

Syntax OK

 

이렇게 정상적인 OK 가 나오면 실행하시면 됩니다. 간혹 인증서 때문에 테스트에서는 정상 작동이 된다고 하지만 실행해보면 실패가 되는 경우가 있는데 운영중인 서버라면 httpd.conf 에서 Include conf/extra/httpd-ssl.conf 부분을 주석처리하고 일단 상황을 보시고 실행하시길 바랍니다.

 

그리고 Solaris에서는 모르겠지만 Linux 에서는 apache 2.x.x 버전은 openssl, 이 자체 내장되어서 나옵니다. sunfreeware 사이트에서 설치시 받아야할 항목을 모두 받아서 설치한거니 헷갈리지 마세요 ^^;  아참 apache 1.3.x 버전의 경우 apache 실행시 apachectl startssl 을 해야 하지만 apache 2.x.x 의 경우 밑의 명령어 처럼 start 명령어만 해주면 됩니다.

 

 

# ./apachectl start

Apache/2.2.12 mod_ssl/2.2.12 (Pass Phrase Dialog)

Some of your private key files are encrypted for security reasons.

In order to read them you have to provide the pass phrases.

 

Server www.m-sys.co.kr:443 (RSA)

Enter pass phrase:

 

OK: Pass Phrase Dialog successful.

 

 

이렇게 하고 443 Port가 사용하고 있는지 확인하세요.

 

# netstat –an | grep 443

 

*.443                *.*                0      0 24576      0 LISTEN

      *.443                             *.*                             0      0 24576      0 LISTEN

 

 

443 Port 가 열려있다면 이제 익스플로러나 파폭등을 이용해서 https://m-sys.co.kr 주소로 들어가시면 SSL 보안이 실행되고 있는지 확인하실 수가 있습니다.

 


 

 

4) 자체 인증서 만들기

 

# openssl genrsa 1024 > m-sys_co_kr.key

 

# openssl req -new -key m-sys_co_kr.key -out m-sys_co_kr.csr

 

# openssl x509 -in m-sys.co.kr.csr -out m-sys.co.kr.crt -req -signkey m-sys.co.kr.key -days 3650

Signature ok

subject=/C=KR/ST=Busan/L=Busan/O=Minerva Systems/OU=Technical Support Team/CN=www.m-sys.co.kr/emailAddress=****@m-sys.co.kr

Getting Private key

 

이건 자체 테스트용으로 한것이기 때문에 기간은 10년으로ㅎㅎ

 

이렇게 하신다음 apache를 재시작 하시면 됩니다.

 

 

 

5) 각 운영체제 별 현재 설치된 apache, openssl 등을 확인 방법

 

- Linux

 

# rpm –qa | grep apache

# rpm –qa | grep ssl

 

# find / -name apache

# find / -name ssl

 

 

- Solaris

 

# pkginfo | grep apache

# pkginfo | grep ssl

 

# find / -name apache

# find / -name ssl

 

 


출처 : http://cafe.naver.com/solatech/174



** 하우투 솔라리스에서 퍼온 글 입니다. 
 
 
 
솔라리스의 1 sector 는 1 block 이고 512 bytes 입니다.  
 
가끔 fsck 를 시도시 다음과 같이 cannot read 라는 메세지와 함께 fsck 상태가  
멈추어 버리는 경우가 있습니다.  
이경우는 전혀 mount를 할수 없습니다.  
여러번 fsck를 시도해 보아도 같은 현상이 나오곤 합니다.  
 
다음은 fsck 시도시 위와 같은 현상이 나오는 예제 입니다.  
 
# fsck /dev/rdsk/c0t1d0s0  
** /dev/rdsk/c0t1d0s0  
** Last Mounted on /  
** Phase 1 - Check Blocks and Size  
 
CANNOT READ: BLK 2036256  
CONTINUE? y  
 
** Phase 2 - Check Pathnames  
** Phase 3 - Check Connectivity  
** Phase 4 - Check Reference Counts  
** Phase 5 - Check Cyl groups  
 
FREE BLK COUNT(S) WRONG IN SUPERBLK  
SALVAGE? y  
 
THE FOLLOWING SECTORS COULD NOT BE READ: 2036256 2036257 2036258 2036259  
 
fsck is incapable of fixing sector errors.  
 
fsck is incapable of of fixing sector erros 라는 메시지를 뿌리고 작업이 중단 되거나  
/var/adm/messages 파일에 다음과 같이 뿌려주는 경우도 있습니다.  
 
 
Error for command 'read(10)' Error Level: Retryable  
Requested Block 2422272, Error Block: 2422283  
Sense Key: Media Error  
Vendor 'SEAGATE':  
ASC = 0x11 (unrecovered read error), ASCQ = 0x0, FRU = 0x0  
 
 
위와 같은 현상이 나타나는 이유는 sector의 formating 정보의 손실이나 전기적  
현상에 의한 sector의 문제인 경우가 많습니다.  
 
 
대부분의 경우 이런 현상이 나오게 되면 newfs 하거나 format하여 사용하면 정상적으로 사용 할수 잇습니다.  
그러나 중요한 정보나 데이타가 있다면 newfs 나 format의 경우 모두 없어지게 됩니다.  
그래서 평소에 백업을 충실히 해두라는 말입니다...  
나중에 후회 하지 말구여...  
 
희망이 없는것은 아닙니다... 한번 해보자구여...  
 
 
에러현상은 다음과 같이 크게 SOFT ERROR과 HARD ERROR로 들수 있습니다.  
 
SOFT ERROR  
----------  
soft에러 발생시 데이타는 영향을 받는 블럭(Affacted block)은 영향을 받지않는(alternate block)으로  
이동하게 됩니다. 그리고 이 불안정한 블럭은 repaired되거나 flawed sector(손상된섹터)  
라는 꼬리표를 달게 됩니다.  
 
 
HARD ERROR  
----------  
하드웨어적인 에러는 디스크의 I/O나 SCSI의 문제일수도 있다..  
물리적 전기적 충격을 가하지 않았다면 디스크는 왠만해선 고장 나지 않는다.  
위의 soft error일 경우가 많은데 Hard error로 간주한다면  
여러분의 귀중한 데이타는 없어질지도 모릅니다.  
정말루 확실한 Hard error라고 판명이 되면 수리센타에 의뢰하는 것이 좋습니다.  
format명령어를 실행했을 경우 Hard error은 디스크타잎을 모르거나 인식이 되지 않는  
경우 입니다.  
 
그런데 디스크타잎과 정보는 정상적인데 fsck시 나타나는 현상이 생기면  
일단은 다음과 같이 해 봅시다...정말 몇천만원 짜리 데이타라면 중요하므로  
전문 복구센타에 의뢰하셔야지 제가 하는데로 하시다간 저만 나쁜놈 됩니다.  
그래도 밑져야 본전 중요한 데이타가 아니라면 일단 한번 해보시죠...  
혹시 압니까.. 제덕에 돈벌런지....ㅋㅋ  
 
 
자그럼 지금 부터 하는 내용을 잘 따라 하시면됩니다.  
 
 
format 명령어를 칩니다.  
 
증상이 나타나는 디스크의 번호를 선택 합니다.  
 
블럭에러가 하나인 것은 다음과 같은 예로 하시면 됩니다.  
 
일단은 error bolck number를 아셔야 합니다.  
 
예)  
 
# format  
AVAILABLE DISK SELECTIONS:  
0. c0t0d0 <IBM-DDYS-T18350M-SA2A cyl 14970 alt 2 hd 6 sec 399>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@0,0  
1. c0t1d0 <SUN4.2G cyl 3880 alt 2 hd 16 sec 135>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@1,0  
2. c0t2d0 <IBM-DCAS-34330-S65A cyl 8203 alt 2 hd 6 sec 171>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@2,0  
3. c0t4d0 <IBM-DORS-32160-WA6A cyl 6701 alt 2 hd 5 sec 125>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@4,0  
Specify disk (enter its number)[3]: 3 ----> block error가 난 디스크선택  
selecting c0t4d0  
[disk formatted]  
format> repair  
Enter absolute block number of defect: 4080544 ---> 에러 block number  
Ready to repair defect, continue? y  
(at this point, format will indicate how and if the block was repaired)  
format> q  
 
이런식으로 하시면 됩니다. 에러 블럭이 하나라면 위와 같은 식으로 하시면 되겠죠..  
그다음 raw device를 fsck 시켜 줍니다. 그럼 아무문제 없이 fsck될 것입니다.  
그담엔 mount 하시면 됩니다.... 성공하면 방명록에 고맙다는 리플 다시는거  
잊지마셈...  
 
 
자 그럼 두개 이상의 block error 을 reoair하려면 어떻게 하는지  
 
다음 예를 들어 봅니다.  
 
예)  
AVAILABLE DISK SELECTIONS:  
0. c0t0d0 <IBM-DDYS-T18350M-SA2A cyl 14970 alt 2 hd 6 sec 399>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@0,0  
1. c0t1d0 <SUN4.2G cyl 3880 alt 2 hd 16 sec 135>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@1,0  
2. c0t2d0 <IBM-DCAS-34330-S65A cyl 8203 alt 2 hd 6 sec 171>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@2,0  
3. c0t4d0 <IBM-DORS-32160-WA6A cyl 6701 alt 2 hd 5 sec 125>  
/sbus@1f,0/SUNW,fas@e,8800000/sd@4,0  
Specify disk (enter its number)[3]: 3  
selecting c0t4d0  
[disk formatted]  
 
format> analyze  
 
analyze> setup  
analyze> setup  
Analyze entire disk[yes]? no  
Enter starting block number[0, 0/0/0]: 2036240  
Enter ending block number[2052287, 2035/13/7]: 2036270  
Loop continuously[no]? no  
Enter number of passes[2]: 1  
Repair defective blocks[yes]? yes  
Stop after first error[no]? no  
Use random bit patterns[no]? no  
Enter number of blocks per transfer[126, 0/2/0]: 1  
Verify media after formatting[yes]? yes  
Enable extended messages[no]? no  
Restore defect list[yes]? yes  
Restore disk label[yes]? yes  
 
analyze> read  
Ready to analyze (won't harm SunOS). This takes a long time,  
but is interruptible with CTRL-C. Continue? y  
 
pass 0  
 
Error during read: block 2036256 (0x5da1c0) (2003/5/3)  
Repairing soft error on 2036256 (2003/5/3)...ok.  
 
Error during read: block 2036257 (0x5da1c1) (2003/5/4)  
Repairing soft error on 2036257 (2003/5/3)...ok.  
 
Error during read: block 2036258 (0x5da1c2) (2003/5/5)  
Repairing soft error on 2036258 (2003/5/3)...ok.  
Error during read: block 2036259 (0x5da1c3) (2003/5/6)  
Repairing soft error on 2036259 (2003/5/3)...ok.  
 
2035/13/7  
 
Total of 4 defective blocks repaired.  
(0x5da1c0) (2003/5/3)  
(0x5da1c1) (2003/5/4)  
(0x5da1c2) (2003/5/5)  
(0x5da1c3) (2003/5/6)  
 
analyze> quit  
format> quit  





출처 : http://blog.naver.com/navy_han?Redirect=Log&logNo=70024449636



### 시스템 점검 및 장애복구 방법 ###

 

Hardware 점검

hoony[root:/#]format
nSearching for disks...done nAVAILABLE DISK SELECTIONS:       
0. c0t0d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>          
/sbus@1f,0/SUNW,fas@e,8800000/sd@0,0 n      
1. c0t1d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>         
/sbus@1f,0/SUNW,fas@e,8800000/sd@1,0

hoony[root:/#]iostat -En
c0t0d0          Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: SEAGATE  Product: ST39236LC        Revision: 0005 Serial No:
Size: 9.19GB <9185582592 bytes> n
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0 n
c0t6d0          Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: TOSHIBA  Product: XM6201TASUN32XCD Revision: 1103 Serial No:
Size: 0.00GB <0 bytes> nMedia Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
n* -En option은 5.6 이상에서만 지원됨

 

LAN Port 점검

점검목적 nsystem 에 장착되어 있는 LAN card 의 Port 및 cable 의 연결상태를 점검하여
network의 장애 요소를 제거

hoony[root:/#]netstat -i
Name Mtu Net/Dest Address Ipkts Ierrs   Opkts      Oerrs Collis Queue
lo0 8232 loopback localhost 231473 0        231473   0       0       0
hme1 1500 ns ns 1450055 0        1296494  0       0       0
Ierrs : Input error ( 0.025% 까지는 정상 ), Oerrs : Output error( 0.025% 까지는 정상 )
Queue : 10% 까지는 정상.
* 시스템을 부팅한지 오래된 경우에는 맞지 않을 수 있음

Software 점검

hoony[root:/#]df -k
파일시스템                 K바이트         사용      가용    용량    설치지점
/dev/dsk/c0t0d0s0    6196234   5893082  241190    97%    /
/proc                                  0             0           0     0%    /proc
fd                                       0             0           0     0%    /dev/fd
mnttab                                0             0           0     0%    /etc/mnttab
swap                        2222704           24 2222680     1%    /var/run
/dev/dsk/c0t0d0s5     9136141  7682616 1362164    85%    /users1
/dev/dsk/c0t1d0s6   17413250 13630019 3609099    80%    /mnt
swap                        2223784        1104 2222680     1%    /tmp 
Core file 및 lost+found file 정리(find 명령어 사용)
90%이상 넘는 부분이 있을 시 일단 data 영역에서 필요 없는 파일들을 제거
core file 등과 같은 size 가 크고 불필요한 파일을 제거하여 90% 이하 수준으로 유지

 

Network 점검

점검목적 nNetwork를 구성하는 configuration file 과 table들을 점검하여 외부와의 서비스에
장애요소가 있는지 점검

점검방법 nNetwork 관련 해당 파일 확인
system booting시에 network configuration이 정상적으로 설정됨을 점검
(/etc/hosts, /etc/hostname*,  /etc/inet/*)

현재 Network 환경 설정 확인
ifconfig –a 와 netstat –nr 명령어를 이용하여 network device 의 설정 및 routing table 이
정상인지 점검 nNetwork 외부 연동 확인

외부 system 과의 ping , telnet 여부 확인
snoop ,arp 로 protocol 이 정상인지 확인

 

Administration File 점검
hoony[root:/#]who -b 

       system boot   8월  9 15:55
hoony[root:/#]who -r 

       run-level 3   8월  9 15:55     3      0  S
/var/adm/message file중 WARNING , Error 가 포함되어 있는지  점검하여 과거와 현재
장애 component 의 교체 여부를 결정
hoony[root:/#]grep WAR /var/adm/messages*
hoony[root:/#]grep Err /var/adm/messages*
hoony[root:/#]grep panic /var/adm/messages*

 

계정관리 File 확인

/etc/passwd , /etc/shadow, /etc/group file들을 점검, 운영에 불필요한 계정이 있는지 확인
hoony[root:/#]more /etc/passwd
root:x:0:1:Super-User:/:/bin/ksh
daemon:x:1:1::/: nbin:x:2:2::/usr/bin:
sys:x:3:3::/:
… … …
listen:x:37:4:Network Admin:/usr/net/
ls: nnobody:x:60001:60001:Nobody:/:
noaccess:x:60002:60002:No Access User:/:
nobody4:x:65534:65534:SunOS 4.x Nobody:/:
* passwd 파일은 7개의 필드로 구성 
 (login ID : x : UID : GID : comment : home directory : login shell)

hoony[root:/etc/inet#]more /etc/shadow
root:1OTpM5zTYsnJ6:12660:7:49::::
daemon:NP:6445::::::
bin:NP:6445:::::: nsys:NP:6445::::::
… … … nlisten:MZu2Kz2foRU.g:::::::
nobody:NP:6445:::::: nnoaccess:NP:6445::::::
nobody4:NP:6445::::::
* shadow파일은 9개의 필드로 구성(password가 암호화되어 있는 file)
(login ID : passwd : lastchg : min : max : warn : inactive : expire : )

 

패스워드 정책 설정 값 확인
/etc/default/passwd file에 MAXWEEKS=4 , PASSLEGTH=6 으로
설정하여 4주마다 한번씩은 password를 변경하고, 6자리 이상으
로 하여 Password의 유출을 최대한 방지

주기적인 job 정상운용 여부 확인 ncron이 정상적으로 설정되어 있는지 crontab -l 로 확인
실행 후 log file 인 /var/cron/log or olog 를 점검하여 cron 수행시 nerror 발생 여부 확인

DISK I/O 사용율 niostat 혹은 vmstat 명령어를 사용하여 system disk 및 data disk 의 I/O
performance를 측정. solaris 8 일 경우 iostat –xnt option 을 사용하여
I/O 에 error 가 발생하는지를 점검
hoony[root:/etc#]iostat -xnt 2 100
extended device statistics       ---- errors ---
r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b s/w h/w trn tot device
17.1   13.1   76.3   97.4  0.2  1.2    7.5   41.3   0  18   0   0   0   0 c0t0d0
0.0    0.0    1.2    0.0  0.0  0.0    0.0    5.7   0   0   0   0   0   0 c0t1d0
0.7    0.0    1.5    0.0  0.0  0.0   19.5   10.2   0   0   0   0   0   0 c0t6d0
0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.6   0   0   0   0   0   0 hoony:vold(pid305)

 

Memory 및 swapping 사용율
sar 나 swap 명령어를 사용, 현재 free memory 값 점검 및 확인
vmstat 값에서 page 의 sr 이 값이 200 이 넘는 경우가 있는지를 점검
hoony[root:/etc#]swap –s
총: 39824k 바이트 할당 + 21152k 예약 = 60976k 사용, 2223800k 사용 가능
hoony[root:/etc#]vmstat 2 100
procs     memory            page            disk          faults      cpu
r b w   swap  free  re  mf pi po fr de sr s0 s1 s6 --   in   sy   cs us sy id
2 0 0 2208584 146352 2  18 71  0  0  0  0 30  0  1  0  411  282  138  1 25 74
0 0 0 2223728 157592 0   2  0  0  0  0  0  0  0  0  0  307   99   91  0  0 100
0 0 0 2223728 157592 0   0  0  0  0  0  0  0  0  0  0  304   81   86  0  0 100
0 0 0 2223728 157592 0   0  0  0  0  0  0  0  0  0  0  308   77   75  0  0 100
0 0 0 2223728 157592 0   0  0  0  0  0  0  0  0  0  0  305   86   86  0  0 100

 

Disk 장애
장애 유형 및 복구 절차
장애 현상
WARNING:/pci@1f,4000/scsi@3/sd@1,0(sd1):
Error for command: write     Error Level: Retryable
Requested Block: 90722224    Serial Number: 3HZ62CT3
Sense Key: Hardware Error nWARNING: /pci@1f,4000/scsi@3/sd@1,0(sd1):
SCSI transport failed: reason ‘reset’ : retrying command
WARNING: /pci@1f,4000/scsi@3/sd@1,0(sd1):
SCSI transport failed: reason ‘incomplete’ : retrying command
WARNING: /pci@1f,4000/scsi@3/sd@1,0(sd1):
Disk not responding to selection
장애 복구 절차
Hard disk 의 불량으로 hardware 교체. 같은 용도로 사용중인 양호한 장비의 disk로부터 데이터 copy or reinstall

장애 현상
정전이나 부적절한 방법으로 시스템 종료로 file system 이 깨졌을 경우
부팅 시 multi user 모드로 부팅되지 않을 수 있다.
장애 복구 절차
부팅 시 multi user 모드로 부팅 하지 못하고 single user 모드에서
멈췄을 때(maintenance) root 암호를 입력하여 single user 모드로 들어간다.
# fsck 를 실행
(주의) fsck –y 명령을 실행하면 진행되는 동안 inode를 삭제할 수 있기 때문에 복구가 안될 수도 있다.
fsck 명령 실행 시에는 –y 옵션을 빼고 실행할 것.

 

CPU 장애
장애 유형 및 복구 절차
장애 현상
panic[cpu0]/thread=0x3001fec0: BAD TRAP: cpu=0 type=0x31 rp=0x3001bb00 addr=0x0
mmu_fsr=0x0 nBAD TRAP occurred in module "sd" due to an illegal access to a user address.
sched: trap type = 0x31
pid=0, pc=0x601aa4b0, sp=0x0, tstate=0x3001bb9000000000, context=0x1e03
g1-g7: 0, 30002, 112c000000000000, 7fff, abb5d55900000000, 0, 3001bec0
장애 복구 절차
cpu panic 현상이 발생하면 /var/crash/hostname 디렉토리에 이미지 파일이 생기게 된다.
adb 유틸리티나 기타 방법으로 이미지 파일을 분석한 후 hardware교체 여부를 판단

Memory 장애
장애 유형 및 복구 절차
장애 현상
May 22 11:09:50 eprjdb2 SUNW,UltraSPARC-II: [ID 362078 kern.info] [AFT0] Corrected Memory Error
detected by CPU11, errID 0x001dd49c.d54e5a7b nMay 22 11:09:50 eprjdb2 SUNW,UltraSPARC-II: [ID 589262 kern.info]
[AFT0] errID 0x001dd49c.d54e5a7b Corrected Memory Error on Board 5 J3101 is Persistent
장애 복구 절차 n먼저 /var/adm/messages 파일에 발생된 메시지에서
CE (Correctable memory Error)인지 UE (Uncorrectable memory Error)
인지 판단하여 다음의 용어를 참조 하여 교체 여부를 판단한다.

Intermittent : data에 오류가 있어 다시 해당 word를 read할 시 error가
없는 경우로 memory module 교체는 필요 없다.
* Persistent  : data에 오류가 있어 다시 해당 word를 read할 시 또 오류가
있는 경우로 memory scrub operation으로 해당 bit를 fix를
수정한 경우로 한 module에서 계속적인 error가
(24시간 내 4번 이상) 없을 경우 memory 교체는 필요 없다.
* Sticky : persistent error로 bit를 수정한 이후에도 error가 fix되지 않는
경우로 이 error가 발생하면 즉시 memory를 교체해 주어야 한다

 

File System Full
Root, VAR 등의 File System이 Full
/ 화일시스템에 사용자가 임의로 만들어 준 디렉토리, 파일 여부 확인
/dev 디렉토리 밑에 일반 파일이 있는지 조사
# find /dev  -type f -exec ls -l {} \;
일반 파일이 있을 경우, 모두 삭제. 특히 테이프에 백업을 받을 경우에 사용자가 디바이스명을 잘못 지정하여,
테이프에 백업되지 않고 파일에 저장하는 경우가 있다.
시스템에 있는 core 화일을 제거

core 화일을 찾아 보려면 다음과 같은 명령어를 사용한다.
# find / -name core –print

core 화일을 찾아서 자동으로 지우려면 다음과 같은 명령어를 실행
# find / -name core -exec rm {} \; -print


/var 디렉토리 밑을 조사한다.
# du -sk /var/* | sort –nr
/var 밑에 있는 디렉토리 별로 그 서브 디렉토리까지 포함하여 KB단위로
크기를 출력. 정상적인 시스템에 문제가 될 디렉토리는 다음과 같다.
/var/adm, /var/mail, /var/log, /var/preserve, /var/spool
/var/adm/messages*, wtmp, wtmpx, pacct
시스템이 운용 중에 발생하는 메세지나 기타 정보들이 누적 보관되는 곳.
messages : 시스템에서 발생되는 메세지를 보관하는 파일
wtmp, wtmpx : 시스템에 접속한 사용자에 대한 정보
pacct : accounting 정보를 가지고 있는 파일
# cp /dev/null messages # cp /dev/null wtmp
# cp /dev/null wtmpx # cp /dev/null pacct

/var/mail
메일 데이터가 보관되는 곳(해당 사용자에게 그 메일을 정리하도록 권고)
※ 파일을 지울 때, 그 파일이 어떤 파일인지 숙지한 후에
지울 것인가 아닌가를 결정
/ 파일 시스템에 있는 1 MB 이상 되는 파일을 조사하여, 파일 크기순으로 sort하여 그 내용을 조사한다.
# find / -mount -size +1024k -ls > /tmp/find.list
# sort -nr +6 /tmp/find.list > /tmp/find.list.s
find.list.s 파일에서 비정상적인 큰 파일이 있는지 조사한다

 

Solaris7 에서 SSH(openssh) 설치

Posted 2009. 2. 17. 11:47


밑에 보시면 Solaris 8 에서 설치하는 글이 있는데 또 적는 이유는  Solaris 8에서 조금 더 수정 및 추가가 되어야 하는 부분이 있어서 이렇게 다시 적습니다. (2009.01.23)

환경 : Solaris7 SPARC


1. SSH 설치에 필요한 Package 다운로드

http://sunfreeware.com  에서 접속하여 오른쪽에 있는 Solaris7 x86, Solaris8 SPARC 중 해당 시스템 사항에 맞추어서 클릭하여  아래에 적힌 목록들을 다운

egd-0.8-sol7-sparc-local
gcc-3.4.6-sol7-sparc-local.gz
libgcc-3.4.6-sol7-sparc-local.gz
openssh-5.1p1-sol7-sparc-local.gz
openssl-0.9.8i-sol7-sparc-local.gz
perl-5.8.8-sol7-sparc-local
prngd-0.9.25-sol7-sparc-local.gz
tcp_wrappers-7.6-sol7-sparc-local.gz
zlib-1.2.3-sol7-sparc-local.gz

위에 리스트중에 이미 설치되어있는것은 생략하셔도 됩니다.
혹시 이 버젼보다 상위 버젼이 나왔다면 그것을 받아서 설치하셔도 됩니다.



2. Package 압축 해제 및 설치

위의 파일들은 모두 패키지 형식이기 때문에 gzip으로 압축만 풀고 간단한 명령어가 치면 자동으로

설치 됩니다.

예) #  gzip -d openssh-5.1p1-sol7-sparc-local.gz   

이렇게 모두 압축을 풀어주세요

압축을 풀게 되면 openssh-5.1p1-sol7-sparc-local 이렇게만 남습니다.


그다음 패키지를 풀면됩니다.


예) # pkgadd -d openssh-5.1p1-sol7-sparc-local

The following packages are available:
  1  SMCosh511     openssh
                   (sparc) 5.1p1

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: all

Processing package instance <SMCosh511> from </home/kuma/openssh-5.1p1-sol7-sparc-local>

openssh
(sparc) 5.1p1
The OpenSSH Group
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
   6 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing openssh as <SMCosh511>

## Installing part 1 of 1.
/usr/local/bin/scp
/usr/local/bin/sftp
/usr/local/bin/slogin <symbolic link>
/usr/local/bin/ssh
/usr/local/bin/ssh-add
/usr/local/bin/ssh-agent
/usr/local/bin/ssh-keygen
/usr/local/bin/ssh-keyscan
/usr/local/doc/openssh/CREDITS
/usr/local/doc/openssh/ChangeLog
/usr/local/doc/openssh/INSTALL
/usr/local/doc/openssh/LICENCE
/usr/local/doc/openssh/OVERVIEW
/usr/local/doc/openssh/README
/usr/local/doc/openssh/README.dns
/usr/local/doc/openssh/README.platform
/usr/local/doc/openssh/README.privsep
/usr/local/doc/openssh/README.smartcard
/usr/local/doc/openssh/README.tun
/usr/local/doc/openssh/TODO
/usr/local/doc/openssh/WARNING.RNG
/usr/local/doc/openssh/contrib/Makefile
/usr/local/doc/openssh/contrib/README
/usr/local/doc/openssh/contrib/aix/README
/usr/local/doc/openssh/contrib/aix/buildbff.sh
/usr/local/doc/openssh/contrib/aix/inventory.sh
/usr/local/doc/openssh/contrib/aix/pam.conf
/usr/local/doc/openssh/contrib/caldera/openssh.spec
/usr/local/doc/openssh/contrib/caldera/ssh-host-keygen
/usr/local/doc/openssh/contrib/caldera/sshd.init
/usr/local/doc/openssh/contrib/caldera/sshd.pam
/usr/local/doc/openssh/contrib/cygwin/Makefile
/usr/local/doc/openssh/contrib/cygwin/README
/usr/local/doc/openssh/contrib/cygwin/ssh-host-config
/usr/local/doc/openssh/contrib/cygwin/ssh-user-config
/usr/local/doc/openssh/contrib/cygwin/sshd-inetd
/usr/local/doc/openssh/contrib/findssl.sh
/usr/local/doc/openssh/contrib/gnome-ssh-askpass1.c
/usr/local/doc/openssh/contrib/gnome-ssh-askpass2.c
/usr/local/doc/openssh/contrib/hpux/README
/usr/local/doc/openssh/contrib/hpux/egd
/usr/local/doc/openssh/contrib/hpux/egd.rc
/usr/local/doc/openssh/contrib/hpux/sshd
/usr/local/doc/openssh/contrib/hpux/sshd.rc
/usr/local/doc/openssh/contrib/redhat/gnome-ssh-askpass.csh
/usr/local/doc/openssh/contrib/redhat/gnome-ssh-askpass.sh
/usr/local/doc/openssh/contrib/redhat/openssh.spec
/usr/local/doc/openssh/contrib/redhat/sshd.init
/usr/local/doc/openssh/contrib/redhat/sshd.init.old
/usr/local/doc/openssh/contrib/redhat/sshd.pam
/usr/local/doc/openssh/contrib/redhat/sshd.pam.old
/usr/local/doc/openssh/contrib/solaris/README
/usr/local/doc/openssh/contrib/ssh-copy-id
/usr/local/doc/openssh/contrib/ssh-copy-id.1
/usr/local/doc/openssh/contrib/sshd.pam.freebsd
/usr/local/doc/openssh/contrib/sshd.pam.generic
/usr/local/doc/openssh/contrib/suse/openssh.spec
/usr/local/doc/openssh/contrib/suse/rc.config.sshd
/usr/local/doc/openssh/contrib/suse/rc.sshd
/usr/local/doc/openssh/contrib/suse/sysconfig.ssh
/usr/local/etc/moduli
/usr/local/etc/ssh_config
/usr/local/etc/sshd_config
/usr/local/libexec/sftp-server
/usr/local/libexec/ssh-keysign
/usr/local/libexec/ssh-rand-helper
/usr/local/sbin/sshd
/usr/local/share/Ssh.bin
/usr/local/share/man/man1/scp.1
/usr/local/share/man/man1/sftp.1
/usr/local/share/man/man1/slogin.1 <symbolic link>
/usr/local/share/man/man1/ssh-add.1
/usr/local/share/man/man1/ssh-agent.1
/usr/local/share/man/man1/ssh-keygen.1
/usr/local/share/man/man1/ssh-keyscan.1
/usr/local/share/man/man1/ssh.1
/usr/local/share/man/man5/ssh_config.5
/usr/local/share/man/man5/sshd_config.5
/usr/local/share/man/man8/sftp-server.8
/usr/local/share/man/man8/ssh-keysign.8
/usr/local/share/man/man8/ssh-rand-helper.8
/usr/local/share/man/man8/sshd.8
[ verifying class <none> ]

Installation of <SMCosh511> was successful.
#

이렇게 위의 리스트에 적혀있는 파일들을 예)를 보시고 설치 하시면 됩니다.



3. SSH 접속 환경 구성

# mkdir /var/empty 

# chown root:sys /var/empty
소유자와 그룹을 root:sys로 변경

# chmod 755 /var/empty
empty 사용 권한은 755(rwxr-xr-x)

# groupadd sshd
그룹 sshd 만들기

# useradd -g sshd -c 'sshd privsep' -d /var/empty -s /bin/false sshd



4. Getting Entropy (Solaris 8버젼 이상에서는 필요가 없는 부분입니다.)

만약 이부분을 하지않고 진행할 경우 ssh-keygen  명령어 사용시 에러가 발생하게 됩니다.

# ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
PRNG is not seeded

여기 진행부분은 필히 순서를 지켜서 사용하셔야 합니다.

먼저 /var/log or /var/adm 로 이동하세요

# cd /var/log
# cat syslog > /usr/local/etc/prngd/prngd-seed

or

# cd /var/adm
# cat messages > /usr/local/etc/prngd/prngd-seed

# mkdir /var/spool/prngd

# /usr/local/sbin/prngd /var/spool/prngd/pool
이부분이 prngd 실행하는 부분입니다.

# ln -s /var/spool/prngd/pool /dev/egde-pool

그다음 /etc/init.d 디렉토리에서 prngd 파일을 하나 생성해야합니다.

# vi prngd  or   # cat >> prngd

#!/bin/sh

pid=`/usr/bin/ps -e | /usr/bin/grep prngd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
case $1 in
'start')
 /usr/local/sbin/prngd /var/spool/prngd/pool
 ;;
'stop')
 if [ "${pid}" != "" ]
 then
  /usr/bin/kill ${pid}
 fi
 ;;
*)
 echo "usage: /etc/init.d/prngd {start|stop}"
 ;;
esac

이 파일은 제가 첨부파일로 올려놓겠습니다.




# chown root:sys /etc/init.d/prngd
prngd 파일의 소유자 및 그룹을  root:sys 로 변경

# chmod 755 /etc/init.d/prngd
prngd 파일의 권한을 755 (r-xr-xr-x)

# ln -s /etc/init.d/prngd /etc/rc2.d/S99prngd

이렇게 하시면 Server Reboot 데몬이 자동 실행되어 가동이 됩니다.




5. Tcp_Wrapper 설정

# vi /etc/hosts.allow
sshd : All    (추가)

# vi /etc/hosts.deny
Server로 접근 못하게 할 IP 등을 넣어시면 됩니다.

위 두부분은 파일만 만들어 놓고 나중에 추가 사항들을 추가 하시는게 좋을것 같습니다. 만약 원격으로 하실 경우 직접 서버가 있는 곳까지 가야할 상황이 생길 수 있으니까요.



6. SSH 사용을 위한 암호키 생성

먼저 PATH에 /usr/local/bin 과 /usr/local/sbin 이 등록되어 있어야 명령어를 실행하실 수 있습니다.

# ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""
# ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N ""
# ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N ""

이렇게 하시면

예) # ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N ""

Generating public/private rsa1 key pair.
Your identification has been saved in /usr/local/etc/ssh_host_key.
Your public key has been saved in /usr/local/etc/ssh_host_key.pub.
The key fingerprint is:
4f:00:d4:cc:c8:b2:7e:41:6e:3d:5d:c5:d0:52:17:cc root@unknown
The key's randomart image is:
+--[RSA1 2048]----+
|       oo=        .*=.o|
|        . +.+     o oE |
|               = ... . .  |
|            . + o.. .    |
|      .  .  .S..  ..     |
|    .    .  o          . |
|     .    .               |
|                          |
|                          |
+-----------------+
bash-2.03#

이런 형식의 내용을 화면에 뿌려줍니다.  만들어진 파일은 /usr/local/etc/ 안에 있습니다.



7. sshd Daemon Script 작성

# vi /etc/init.d/sshd

#!/bin/sh

pid=`/usr/bin/ps -e | /usr/bin/grep sshd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
case $1 in
'start')
/usr/local/sbin/sshd
;;
'stop')
if [ "${pid}" != "" ]
then
/usr/bin/kill ${pid}
fi
;;
*)
echo "usage: /etc/init.d/sshd {start|stop}"
;;
esac


혹은

case "$1" in

'start')
     # Start the ssh daemon
     if [ -f /usr/local/sbin/sshd ]; then
          echo "starting SSHD daemon"
          /usr/local/sbin/sshd &
     fi
     ;;

'stop')
     # Stop the ssh deamon
     PID=`/usr/bin/ps -e -u 0 | /usr/bin/fgrep sshd | /usr/bin/awk '{print $1}'`
     if [ ! -z "$PID" ] ; then
          /usr/bin/kill ${PID} >/dev/null 2>&1
     fi
     ;;

*)
     echo "usage: /etc/init.d/sshd {start|stop}"
     ;;

esac
exit 0

둘중에 하나를 작성하시면 됩니다.
제가 사용하는 파일을 첨부파일로 올리겠습니다.



# chown root:sys /etc/init.d/sshd
sshd 파일의 소유자 및 그룹을  root:sys 로 변경

# chmod 755 /etc/init.d/sshd
sshd 파일의 권한을 755 (r-xr-xr-x)

# cat >> /etc/rc2.d/S99sshd
/etc/init.d/sshd start
Ctrl + C <- 이거 아시죠? 빠져나오기.. ^^

# chome 744 /etc/rc2.d/S99sshd
sshd 파일의 권한을 744 (rwxr--r--)

이렇게 하시면 Server Reboot 데몬이 자동 실행되어 가동이 됩니다.



8. SSH, PRNGD 실행 및 가동여부 확인

# /etc/init.d/prngd start

# /etc/init.d/prngd stop

# ps -ef | grep prngd
    root 20381     1  0 16:18:33 ?        0:00 /usr/local/sbin/prngd /var/spool/prngd/pool

데몬이 제대로 올라오는지 확인.


# /etc/rc2.d/S99sshd
starting SSHD daemon

# ps -ef | grep sshd
    root   478     1  0 16:16:27 ?        0:02 /usr/local/sbin/sshd

이렇게 띄워져 있다면 실행되고 있습니다.

해 보시고 문제가 있다면 댓글을 남겨주세요~!



Solaris 서버정보 확인 명령어

1. 솔라리스 버전 및 업데이트 번호
[SOLARIS:/]cat /etc/release
                     Solaris 8 HW 7/03 s28s_hw3wos_05a SPARC
           Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
                             Assembled 11 June 2003


2. 서버의 모델 출력
[SOLARIS:/]prtconf -vp | grep banner-name
    banner-name:  'Sun Fire V240'


3. 서버 정보
[SOLARIS:/]uname -a
SunOS SOLARIS 5.8 Generic_108528-22 sun4u sparc SUNW,Sun-Fire-V240
   ⓐ          ⓑ      ⓒ             ⓓ               ⓔ       ⓕ      ⓖ            ⓗ
ⓐ System(OS)
ⓑ Hostname
ⓒ Release
ⓓ Kernel Version(ID)
ⓔ Kernel architecture(그외 i86pc, sun4m, sun4c 등)
ⓕ Application architecture(그외 sparc, i386, i686등
ⓖ Maker?
ⓗ Banner

-a 옵션이 아닌 -X 옵션으로 좀더 쉽게 볼 수 있으며 비슷한 명령어로는 showrev명령어가 있습니다.

[SOLARIS:/]showrev
Hostname: SOLARIS
Hostid: 838e1e19
Release: 5.8
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Sun_Microsystems
Domain:
Kernel version: SunOS 5.8 Generic 108528-22 May 2003

일반적으로 uname -v 명령어를 통해 설치된 Kernel에 적용된 최신 패치를 보여 주며
uname -srv 명령어를 통해 OS와 Kernel을 같이 본다. 하지만 좀더 자세한 정보를 원한다면
showrev -p 명영어를 통해 좀더 자세한 정보를 확인할 수 있습니다.

[SOLARIS:/]showrev -p | more
Patch: 109879-02 Obsoletes: 109654-02 Requires: 109877-01 Incompatibles:  Packages: SUNWcarx, SUNWcsr

패치가 많이 이루어 졌다면 상당량의 라인이 지나갈 것입니다. 때문에 more명령을 같이 넣어주면 확인하는대 불편함이 없을 것입니다.
Patch: 109879-02는 이 패치로 인해 109654-02 패치가 쓸모없어 제거 됬으며, 이 패치를 설치하기 위한 선행 패치로 109877-01이 설치되어야 하며, 관련 패키지는 SUNWcarx와 SUNWcsr이 있다는 것을 의미 한다.


4. 장착(monut)된 Disk(갯수) 확인
[SOLARIS:/]iostat -nE
c1t0d0          Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: FUJITSU  Product: MAP3367N SUN36G  Revision: 0401 Serial No: 00N0BPPN    
Size: 36.42GB <36418595328 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0
>>
c1t1d0          Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: SEAGATE  Product: ST336607LSUN36G  Revision: 0307 Serial No: 3JA65ZTV00007349
Size: 36.42GB <36418595328 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0

보기 쉽게 중간에 공백을 넣어 놓았습니다. 실제로 명령어를 입력했을때
는 공백이 존재하지 않습니다.

c1t0d0(FUJITSU)와 c1t1d0(SEAGATE) Disk, 이렇게 두게의 Disk가 보입니다.
df -k 명령어로 용량을 확인해 봐도 Filesystem부분에

[SOLARIS:/]df -k
Filesystem                  kbytes      used      avail capacity  Mounted on
/dev/dsk/c1t0d0s0      1016122    222789    732366    24%    /
/dev/dsk/c1t0d0s4      1016122    719173   235982    76%     /usr
/dev/dsk/c1t0d0s1       492872    173737    269848    40%    /var
/dev/dsk/c1t0d0s6    30879855     91478 30479579      1%    /backup
/dev/dsk/c1t0d0s5       492872    175590    267995    40%    /tmp
/dev/dsk/c1t1d0s6    35009161 30749312  3909758     89%    /home1

총 6개의 파티션으로 나뉜 두게의 Disk가 보입니다.
/dev/dsk/c1t0d0s[04165], /dev/dsk/c1t1d0s6

※ 참고
솔라리스는 장착된 디스크에 대한 물리적인 정보를 ‘devices.....’라는 디렉토리에 보관한 후 솔라리스가 실제 사용하는 이름으로 링크하는데 앞의 예제가 바로 그것이다. 이때 솔라리스는 물리적인 디스크에 대한 사용 방식을 두가지로 정의한다. 디스크를 있는 그대로 사용하기 위한(raw device) 방법으로 ‘/dev/rdsk/...’에 링크를 저장하는 방법과, 디스크를 솔라리스의 파일 시스템용으로 사용하기 위해 별도의 링크를 ‘/dev/dsk/...’ 디렉토리에 저장하는 방법이 있다.
일반적으로 오라클과 같은 데이터베이스나 특정 애플리케이션은 파일 시스템과 관련없이 로 디바이스(raw device)를 사용하기 때문에 ‘/dev/rdsk/....’ 밑의 파일을 사용한다. 한편 솔라리스가 직접 제어하는 파일 시스템은 블럭 디바이스(block device)를 사용하며 ‘/dev/dsk/....’ 밑의 디스크 링크를 사용한다.
따라서 어느 쪽이나 사용자가 앞의 예제와 같이 ls 명령을 실행하면 솔라리스가 인지한 디스크의 정보를 얻을 수 있다. 앞의 예제에서 표시된 내용을 해석해보면 세개의 디스크 컨트롤러(c0,c1,c2)가 장착돼 있으며, 0번 컨트롤러에는 t1 디스크 하나, 1번 컨트롤러에는 t6 디스크 하나, 2번 컨트롤러에는 t10과 t11이라는 두개의 디스크가 연결돼, 총 4개의 디스크가 시스템에 장착돼 있다는 것을 알 수 있다.

참고 사이트 : http://blog.naver.com/wooya510?Redirect=Log&logNo=60008927738


5. CPU 구성 확인
[SOLARIS:/]psrinfo -v 또는
[SOLARIS:/]/usr/sbin/psrinfo -v
Status of processor 0 as of: 11/07/08 14:46:54
  Processor has been on-line since 10/15/08 21:30:42.
  The sparcv9 processor operates at 1002 MHz,
        and has a sparcv9 floating point processor.

한개의 SPARCV9 1002MHz짜리 CPU가 있음을 보여주고 있습니다.
만약 여러게 였다면 위와 같은 정보가 여러번 나오게 됩니다.
때문에 한번에 갯수만 출력하는 명령어를 친다면 다음과 같이 입력하면 됩니다.

[SOLARIS:/]psrinfo -v | grep "Status of processor" | wc -l      
       1


6. Memory Size보기
[SOLARIS:/]prtconf | grep "Memory"
Memory size: 512 Megabytes


7. CPU점유율 확인
[SOLARIS:/]prstat
   PID USERNAME    SIZE   RSS STATE  PRI NICE   TIME CPU  PROCESS/NLWP
   296            root    443M  258M   sleep   59  -20   3:00.02   5.4%        SOLARIS/17
   311            root   3464K 1600K    sleep  58    0    0:22.13   0.1%        SOLARIS/1
    70            root    3920K 2440K   sleep   31    0   0:00.00   0.1%         picld/6
  3227    SOLARIS   1584K 1216K    cpu0   58    0   0:00.00   0.0%          prstat/1
 19074   SOLARIS   6688K 2016K       run   58    0   0:00.00   0.0%         sshd/1
 27216   SOLARIS   2560K 1784K   sleep    48    0   0:00.00   0.0%         bash/1
 27211          root    6696K 2712K   sleep   38    0   0:00.00   0.0%          sshd/1
 27245          root    2560K 1784K   sleep   58    0   0:00.00   0.0%          bash/1
 19072          root    6696K 2760K   sleep   22    0   0:00.00   0.0%          sshd/1
   272           root    5272K 1328K   sleep   20    0   0:00.00   0.0%          dtlogin/4
   310           root    1840K  632K   sleep   58    0   0:00.00   0.0%          ttymon/1
   210           root    3680K 1112K   sleep   58    0   0:00.00   0.0%         vold/5
   186           root    1048K  512K   sleep   58    0   0:00.03   0.0%          utmpd/1
   163           root    2064K  968K   sleep   48    0   0:01.35   0.0%          cron/1
   159           root    4088K 1592K   sleep  59    0   0:00.00   0.0%           syslogd/11
   152           root    1824K  440K   sleep   50    0   0:00.00   0.0%          inetd/1
 19076   SOLARIS   2560K 1792K      run   48    0   0:00.00   0.0%          bash/1
   130           root    2240K  272K   sleep    5    0   0:00.00   0.0%          rpcbind/1
   178           root    4056K 1280K   sleep    0    0   0:00.06   0.0%          sshd/1
    59            root   1752K  712K   sleep   30    0   0:00.00   0.0%          syseventd/12
 27214   SOLARIS   6688K 2008K   sleep   58    0   0:00.00   0.0%         sshd/1
    68            root   2760K  920K   sleep   53    0   0:00.00   0.0%         devfsadm/7
  2790           root   9776K 8240K   sleep    0    0   0:00.06   0.0%          nvfs/1
   308           root    1864K  520K   sleep   38    0   0:00.00   0.0%         ttymon/1
   307           root    1832K  528K   sleep   59    0   0:00.00   0.0%         sac/1
     1            root     840K  264K   sleep   58    0   0:00.43   0.0%         init/1
 

Total: 26 processes, 108 lwps, load averages: 0.06, 0.10, 0.12

하지만 이렇게 입력하면 한번 출력하고 끝이기 때문에 다음과 같이 입력 합니다.

[SOLARIS:/]prstat 5 5

이렇게 입력하면 prstat 명령여를 5초에 한번씩 5번 친 효과가 나타 납니다.
즉, 5초 간격으로 총 5번 자동적으로 prstat값이 reflash됩니다.


8. 시스템 장치의 정보 확인
[SOLARIS:/]uname -i
SUNW,Sun-Fire-V240
   ⓐ             ⓑ
Maker       Banner
이를 이용해 시스템 장치의 정보를 확인 할 수 있다.

[SOLARIS:/]/usr/platform/`uname -i`/sbin/prtdiag | more
System Configuration: Sun Microsystems  sun4u Sun Fire V240
System clock frequency: 167 MHZ
Memory size: 512MB     
==================================== CPUs ====================================
                      E$          CPU     CPU       Temperature         Fan
       CPU  Freq      Size        Impl.   Mask     Die    Ambient   Speed   Unit
       ---  --------  ----------  ------  ----  --------  --------  -----   ----
     MB/P0  1002 MHz  1MB         US-IIIi  2.4       -        -   
================================= IO Devices =================================
     Bus   Freq
Brd  Type  MHz   Slot        Name                          Model
---  ----  ----  ----------  ----------------------------  --------------------
 0   pci    66           MB  pci108e,1648 (network)                          
 0   pci    66           MB  pci108e,1648 (network)                          
 0   pci    33           MB  isa/su (serial)                                 
 0   pci    33           MB  isa/su (serial)                                 
 0   pci    33           MB  pci10b9,5229 (ide)                              
 0   pci    66           MB  scsi-pci1000,21 (scsi-2)                        
 0   pci    66           MB  scsi-pci1000,21 (scsi-2)                        
 0   pci    66           MB  pci108e,1648 (network)                          
 0   pci    66           MB  pci108e,1648 (network)                          
 0   pci    33            7  isa/rmc-comm-rmc_comm (seria+                   
============================ Memory Configuration ============================
Segment Table:
-----------------------------------------------------------------------
Base Address       Size       Interleave Factor  Contains
-----------------------------------------------------------------------
0x0                512MB             1           BankIDs 0
Bank Table:
-----------------------------------------------------------
           Physical Location
ID       ControllerID  GroupID   Size       Interleave Way
-----------------------------------------------------------
0        0             0         512MB           0
Memory Module Groups:
--------------------------------------------------
ControllerID   GroupID  Labels
--------------------------------------------------
0              0        MB/P0/B0/D0,MB/P0/B0/D1
=============================== usb Devices ===============================
Name          Port#
------------  -----
keyboard        2
======== FRU Status =========
-------------------------
Fru Operational Status:
-------------------------
Location        Status  
-------------------------
MB/SC           okay
PS0             okay
HDD0            present
HDD1            present