2015년 11월 12일 목요일

CentOS 7 에 php 설치

CentOS 7 에 php 설치하기 (디비와 아파치를 설치한후 마지막에 php를 설치한다.)


설치 가능한 php 버전을 확인해 본다.
확인해 보니 버전이 php 5.4.16 이다.
[root@localhost ~]# yum list | grep php
graphviz-php.x86_64                     2.30.1-18.el7                  base   
php.x86_64                              5.4.16-23.el7_0.3              updates
php-bcmath.x86_64                       5.4.16-23.el7_0.3              updates
php-cli.x86_64                          5.4.16-23.el7_0.3              updates
php-common.x86_64                       5.4.16-23.el7_0.3              updates
php-dba.x86_64                          5.4.16-23.el7_0.3              updates
php-devel.x86_64                        5.4.16-23.el7_0.3              updates
php-embedded.x86_64                     5.4.16-23.el7_0.3              updates
php-enchant.x86_64                      5.4.16-23.el7_0.3              updates
php-fpm.x86_64                          5.4.16-23.el7_0.3              updates
php-gd.x86_64                           5.4.16-23.el7_0.3              updates
php-intl.x86_64                         5.4.16-23.el7_0.3              updates
php-ldap.x86_64                         5.4.16-23.el7_0.3              updates
php-mbstring.x86_64                     5.4.16-23.el7_0.3              updates
php-mysql.x86_64                        5.4.16-23.el7_0.3              updates
php-mysqlnd.x86_64                      5.4.16-23.el7_0.3              updates
php-odbc.x86_64                         5.4.16-23.el7_0.3              updates
php-pdo.x86_64                          5.4.16-23.el7_0.3              updates
php-pear.noarch                         1:1.9.4-21.el7                 base   
php-pecl-memcache.x86_64                3.0.8-4.el7                    base   
php-pgsql.x86_64                        5.4.16-23.el7_0.3              updates
php-process.x86_64                      5.4.16-23.el7_0.3              updates
php-pspell.x86_64                       5.4.16-23.el7_0.3              updates
php-recode.x86_64                       5.4.16-23.el7_0.3              updates
php-snmp.x86_64                         5.4.16-23.el7_0.3              updates
php-soap.x86_64                         5.4.16-23.el7_0.3              updates
php-xml.x86_64                          5.4.16-23.el7_0.3              updates
php-xmlrpc.x86_64                       5.4.16-23.el7_0.3              updates
rrdtool-php.x86_64                      1.4.8-8.el7                    base   
uuid-php.x86_64                         1.6.2-26.el7                   base   


php를 설치한다.
중간에 y를 선택해 준다. 연관 패키지이다.

[root@localhost ~]# yum install php php-mysql php-gd php-pear
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr
 * updates: centos.tt.co.kr
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64
---> Package php-gd.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: libt1.so.5()(64bit) for package: php-gd-5.4.16-23.el7_0.3.x86_64
---> Package php-mysql.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: php-pdo(x86-64) = 5.4.16-23.el7_0.3 for package: php-mysql-5.4.16-23.el7_0.3.x86_64
---> Package php-pear.noarch 1:1.9.4-21.el7 will be installed
--> Processing Dependency: php-xml for package: 1:php-pear-1.9.4-21.el7.noarch
--> Processing Dependency: php-posix for package: 1:php-pear-1.9.4-21.el7.noarch
--> Running transaction check
---> Package php-cli.x86_64 0:5.4.16-23.el7_0.3 will be installed
---> Package php-common.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-23.el7_0.3.x86_64
---> Package php-pdo.x86_64 0:5.4.16-23.el7_0.3 will be installed
---> Package php-process.x86_64 0:5.4.16-23.el7_0.3 will be installed
---> Package php-xml.x86_64 0:5.4.16-23.el7_0.3 will be installed
---> Package t1lib.x86_64 0:5.1.2-14.el7 will be installed
--> Running transaction check
---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch          Version                  Repository      Size
================================================================================
Installing:
 php                x86_64        5.4.16-23.el7_0.3        updates        1.3 M
 php-gd             x86_64        5.4.16-23.el7_0.3        updates        124 k
 php-mysql          x86_64        5.4.16-23.el7_0.3        updates         97 k
 php-pear           noarch        1:1.9.4-21.el7           base           357 k
Installing for dependencies:
 libzip             x86_64        0.10.1-8.el7             base            48 k
 php-cli            x86_64        5.4.16-23.el7_0.3        updates        2.7 M
 php-common         x86_64        5.4.16-23.el7_0.3        updates        561 k
 php-pdo            x86_64        5.4.16-23.el7_0.3        updates         95 k
 php-process        x86_64        5.4.16-23.el7_0.3        updates         52 k
 php-xml            x86_64        5.4.16-23.el7_0.3        updates        122 k
 t1lib              x86_64        5.1.2-14.el7             base           166 k

Transaction Summary
================================================================================
Install  4 Packages (+7 Dependent packages)

Total download size: 5.7 M
Installed size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
(1/11): libzip-0.10.1-8.el7.x86_64.rpm                     |  48 kB   00:00   
(2/11): php-5.4.16-23.el7_0.3.x86_64.rpm                   | 1.3 MB   00:01   
(3/11): php-gd-5.4.16-23.el7_0.3.x86_64.rpm                | 124 kB   00:01   
(4/11): php-pdo-5.4.16-23.el7_0.3.x86_64.rpm               |  95 kB   00:00   
(5/11): php-common-5.4.16-23.el7_0.3.x86_64.rpm            | 561 kB   00:01   
(6/11): php-process-5.4.16-23.el7_0.3.x86_64.rpm           |  52 kB   00:00   
(7/11): php-xml-5.4.16-23.el7_0.3.x86_64.rpm               | 122 kB   00:00   
(8/11): php-mysql-5.4.16-23.el7_0.3.x86_64.rpm             |  97 kB   00:00   
(9/11): php-pear-1.9.4-21.el7.noarch.rpm                   | 357 kB   00:00   
(10/11): php-cli-5.4.16-23.el7_0.3.x86_64.rpm              | 2.7 MB   00:01   
(11/11): t1lib-5.1.2-14.el7.x86_64.rpm                     | 166 kB   00:00   
--------------------------------------------------------------------------------
Total                                              2.7 MB/s | 5.7 MB  00:02   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libzip-0.10.1-8.el7.x86_64                                  1/11
  Installing : php-common-5.4.16-23.el7_0.3.x86_64                         2/11
  Installing : php-cli-5.4.16-23.el7_0.3.x86_64                            3/11
  Installing : php-pdo-5.4.16-23.el7_0.3.x86_64                            4/11
  Installing : php-process-5.4.16-23.el7_0.3.x86_64                        5/11
  Installing : php-xml-5.4.16-23.el7_0.3.x86_64                            6/11
  Installing : t1lib-5.1.2-14.el7.x86_64                                   7/11
  Installing : php-gd-5.4.16-23.el7_0.3.x86_64                             8/11
  Installing : 1:php-pear-1.9.4-21.el7.noarch                              9/11
  Installing : php-mysql-5.4.16-23.el7_0.3.x86_64                         10/11
  Installing : php-5.4.16-23.el7_0.3.x86_64                               11/11
  Verifying  : php-common-5.4.16-23.el7_0.3.x86_64                         1/11
  Verifying  : php-pdo-5.4.16-23.el7_0.3.x86_64                            2/11
  Verifying  : t1lib-5.1.2-14.el7.x86_64                                   3/11
  Verifying  : php-process-5.4.16-23.el7_0.3.x86_64                        4/11
  Verifying  : php-5.4.16-23.el7_0.3.x86_64                                5/11
  Verifying  : php-gd-5.4.16-23.el7_0.3.x86_64                             6/11
  Verifying  : php-xml-5.4.16-23.el7_0.3.x86_64                            7/11
  Verifying  : php-mysql-5.4.16-23.el7_0.3.x86_64                          8/11
  Verifying  : php-cli-5.4.16-23.el7_0.3.x86_64                            9/11
  Verifying  : libzip-0.10.1-8.el7.x86_64                                 10/11
  Verifying  : 1:php-pear-1.9.4-21.el7.noarch                             11/11

Installed:
  php.x86_64 0:5.4.16-23.el7_0.3           php-gd.x86_64 0:5.4.16-23.el7_0.3  
  php-mysql.x86_64 0:5.4.16-23.el7_0.3     php-pear.noarch 1:1.9.4-21.el7     

Dependency Installed:
  libzip.x86_64 0:0.10.1-8.el7             php-cli.x86_64 0:5.4.16-23.el7_0.3
  php-common.x86_64 0:5.4.16-23.el7_0.3    php-pdo.x86_64 0:5.4.16-23.el7_0.3
  php-process.x86_64 0:5.4.16-23.el7_0.3   php-xml.x86_64 0:5.4.16-23.el7_0.3
  t1lib.x86_64 0:5.1.2-14.el7           

Complete!
설치가 완료 되었다.


아파치를 재시작해 준다.
[root@localhost ~]# systemctl restart httpd.service


홈페이지에서 php 정보를 확인하기 위해 info.php 파일을 만든다.
[root@localhost ~]# vi /var/www/html/info.php
내용은 아래와 같이 입력한다.
<?php
   phpinfo();
?>
참고로 저장하고 빠져 나올때는 ESC 키를 누른 후에 손을 땐후
:wq
입력하면 저장후 빠져 나온다.

아파치를 재시작해 준다.
[root@localhost ~]# systemctl restart httpd.service


CentOS에 깔려 있는 브라우저 파이어 폭스를 실행해서 php 정보를 확인해 본다.
주소창에 입력
localhost/info.php

참고사항
PHP 설치 경로 : /usr/lib64/php
PHP 설정파일 경로 :  /etc/php.ini

[출처]http://www.websaram.com/bbs/board.php?bo_table=web_server&wr_id=52

CentOS 7 아파치 웹서버 설치

아파치가 설치되어 있나 확인해 본다.
결과는 없다.
[root@localhost ~]# which httpd
/usr/bin/which: no httpd in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)

아파치는 최신 버전을 설치한다.
먼저 아파치 버전을 확인해 본다.
[root@localhost ~]# yum list | grep httpd
httpd.x86_64                            2.4.6-19.el7.centos            updates
httpd-devel.x86_64                      2.4.6-19.el7.centos            updates
httpd-manual.noarch                     2.4.6-19.el7.centos            updates
httpd-tools.x86_64                      2.4.6-19.el7.centos            updates
libmicrohttpd.i686                      0.9.33-2.el7                   base   
libmicrohttpd.x86_64                    0.9.33-2.el7                   base   
libmicrohttpd-devel.i686                0.9.33-2.el7                   base   
libmicrohttpd-devel.x86_64              0.9.33-2.el7                   base   
libmicrohttpd-doc.noarch                0.9.33-2.el7                   base   


아파치를 설치한다.
설치중 관련 패키지를 설치할 것이냐고 묻는데 y라고 입력하고 엔터를 치자.
[root@localhost ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00   
extras                                                   | 3.4 kB     00:00   
mariadb                                                  | 1.9 kB     00:00   
updates                                                  | 3.4 kB     00:00   
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr
 * updates: centos.tt.co.kr
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-19.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-19.el7.centos for package: httpd-2.4.6-19.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-19.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-19.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-19.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-19.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch         Version                     Repository     Size
================================================================================
Installing:
 httpd             x86_64       2.4.6-19.el7.centos         updates       2.7 M
Installing for dependencies:
 apr               x86_64       1.4.8-3.el7                 base          103 k
 apr-util          x86_64       1.5.2-6.el7                 base           92 k
 httpd-tools       x86_64       2.4.6-19.el7.centos         updates        78 k
 mailcap           noarch       2.1.41-2.el7                base           31 k

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): mailcap-2.1.41-2.el7.noarch.rpm                     |  31 kB   00:00   
(2/5): httpd-tools-2.4.6-19.el7.centos.x86_64.rpm          |  78 kB   00:00   
(3/5): apr-1.4.8-3.el7.x86_64.rpm                          | 103 kB   00:00   
(4/5): apr-util-1.5.2-6.el7.x86_64.rpm                     |  92 kB   00:00   
(5/5): httpd-2.4.6-19.el7.centos.x86_64.rpm                | 2.7 MB   00:01   
--------------------------------------------------------------------------------
Total                                              1.5 MB/s | 3.0 MB  00:01   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                       1/5
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/5
  Installing : httpd-tools-2.4.6-19.el7.centos.x86_64                       3/5
  Installing : mailcap-2.1.41-2.el7.noarch                                  4/5
  Installing : httpd-2.4.6-19.el7.centos.x86_64                             5/5
  Verifying  : httpd-2.4.6-19.el7.centos.x86_64                             1/5
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  2/5
  Verifying  : httpd-tools-2.4.6-19.el7.centos.x86_64                       3/5
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  4/5
  Verifying  : apr-1.4.8-3.el7.x86_64                                       5/5

Installed:
  httpd.x86_64 0:2.4.6-19.el7.centos                                          

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                     apr-util.x86_64 0:1.5.2-6.el7  
  httpd-tools.x86_64 0:2.4.6-19.el7.centos     mailcap.noarch 0:2.1.41-2.el7  

Complete!


설치가 완료 되었다.
아파치 버전을 확인해 보자.
[root@localhost ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Jan 12 2015 13:22:31


아파치를 시작해 보자.
명령어가 조금 바뀌었다고 한다. 예전 명령어를 자동으로 현재의 명령어를 바꾸어서 실행해 준다.
[root@localhost ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service


아파치 상태를 확인해 보자.
[root@localhost ~]# service httpd status
Redirecting to /bin/systemctl status  httpd.service
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
   Active: active (running) since 금 2015-02-13 20:50:28 KST; 2min 16s ago
 Main PID: 16657 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─16657 /usr/sbin/httpd -DFOREGROUND
           ├─16658 /usr/sbin/httpd -DFOREGROUND
           ├─16659 /usr/sbin/httpd -DFOREGROUND
           ├─16662 /usr/sbin/httpd -DFOREGROUND
           ├─16663 /usr/sbin/httpd -DFOREGROUND
           └─16665 /usr/sbin/httpd -DFOREGROUND

 2월 13 20:50:27 localhost.localdomain systemd[1]: Starting The Apache HTTP ...
 2월 13 20:50:27 localhost.localdomain httpd[16657]: AH00558: httpd: Could n...
 2월 13 20:50:28 localhost.localdomain systemd[1]: Started The Apache HTTP S...
Hint: Some lines were ellipsized, use -l to show in full.


부팅할 때 아파치를 자동으로 시작하도록 설정한다.
[root@localhost ~]# systemctl enable httpd.service
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'


바로 위에서 설정한 값이 제대로 입력 되었는지 확인해 본다.
enabled면 제대로 된 것이다.
[root@localhost ~]# systemctl list-unit-files --type=service |grep httpd
httpd.service                               enabled
[root@localhost ~]#

제대로 설치 되었는지 확인해 본다.
centos에 기본으로 설치된 브라우저  파이어폭스에서 아래와 같이 입력해 본다.
http://localhost/

실제 홈페이지 경로는 /var/www/html
아파치 프로그램이 설치된 경로는 /etc/httpd
아파치 설정파일 경로는 /etc/httpd/conf/httpd.conf

아파치(httpd) 시작/멈춤/재시작 명령어
 시작 systemctl start httpd.service
 멈춤 systemctl stop httpd.service
 재시작 systemctl restart httpd.service

아파치 설정파일 에러검사
[root@localhost ~]# apachectl configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
아직 설정 파일을 전혀 수정하지 않은 상태.
아직 도메인등을 설정하지 않아서 위와 같이 출력이 된다.
마지막에 systax ok이면 정상.

[출처]http://www.websaram.com/bbs/board.php?bo_table=web_server&wr_id=51
[참조]http://tecadmin.net/install-tomcat-8-on-centos-rhel-and-ubuntu/#
[참조]http://blog.lael.be/post/1721

CentOS7에 MariaDB 설치 후 PORT변경

# vi /etc/my.cnf.d/server.cnf

 [mysqld]
port =설정포트번호


[참조]http://sharadchhetri.com/2013/11/25/change-mysql-default-port-number-in-linux/

관련해서 구글에서 조회하면 참조페이지와 같이  /etc/my.cnf에서 port설정하는것으로 설명되어 있는데
나의 경우는 적용되지 않아 많은 삽질이 있었다....

CentOS7에 MariaDB yum설치

1. yum 설치를 위한 repository 생성 
vi /etc/yum.repos.d/MariaDB.repo

MariaDB.repo 내용([출처2]참고:2015.11.10현재 최신버전)

# MariaDB 10.1 CentOS repository list - created 2015-11-10 10:11 UTC  # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

2. MariaDB 삭제전
기존에 설치되어있는 MariaDB 서버와 라이브러리는 삭제해두자
#yum remove mariadb-server mariadb-libs -y

3. yum설치 
#yum install MariaDB-server MariaDB-client MariaDB-common -y

4. MariaDB 실행
#service mysql start
혹은
#systemctl start mysql.service

5. MariaDB 자동실행 등록
#chkconfig mysql on
혹은
#systemctl enable mysql.service

6. MariaDB Security 설정
#mysql_secure_installation

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 그냥엔터
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: ENTER YOUR PASSWORD
Re-enter new password: REPEAT YOUR PASSWORD
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

7. MariaDB 재시작
#service mysql restart
혹은
#systemctl restart mysql.service

8. 방화벽 열기
#firewall-cmd --permanent --zone=public --add-service=mysql

다음번에도 자동으로 방화벽을 열기위해 --permanent 옵션추가

9. 외부접근계정권한 생성
클 라이언트 툴에서 root로 접근해보면  host "xxx.xxx.xxx.xxx' is not allowed to connect to this mariadb server 라는 오류메시지가 나온다. 접근을 위한 계정등록을 해야지만 내부 혹은 외부에서 DB에 접근이 가능해진다.

먼저 터미널에서 DB콘솔 로그인
#mysql -u root -p

로컬에서만 접근가능한 계정생성 및 권한부여
MariaDB [(none)]> create user '신규계정아이디입력'@'localhost' identified by '패스워드입력';
MariaDB [(none)]> grant all privileges on *.* to '신규계정아이디입력'@'localhost';

외부에서 접근가능한 계정생성 및 권한부여(특정 IP로만 접근을 제한하고싶다면 %대신 IP입력)
MariaDB [(none)]> create user '신규계정아이디입력'@'%' identified by '패스워드입력';

MariaDB [(none)]> grant all privileges on *.* to '신규계정아이디입력'@'%';



[출처2]https://downloads.mariadb.org/mariadb/repositories/#mirror=kaist&distro=CentOS&distro_release=centos7-amd64--centos7&version=10.1

2015년 11월 11일 수요일

linux - cron으로 mysql 자동백업

linux - cron으로 mysql 자동백업
 
Shell 작성

# mkdir /backup
# chmod 755 backup
# vi /root/backup.sh

backup.sh
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
#!/bin/sh
DATE=`date +"%Y%m%d"`
PREV_DATE=`date --date '5 days ago' +"%Y%m%d"`

/usr/bin/mysqldump -u사용자id -p비번 DB명 > /backup/mysql_db_bak_${DATE}.sql
chown root.root  /backup/mysql_db_bak_${DATE}.sql
chmod 755  /backup/mysql_db_bak_${DATE}.sql
rm -Rf  /backup/mysql_db_bak_${PREV_DATE}.sql
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

전체DB를 백업하려면
mysqldump -u사용자id -p비번 DB명 > /backup/mysql_db_bak_${DATE}.sql
이 명령어대신
mysqldump  -u사용자id -p비번 -e --all-databases > /backup/mysql_db_bak_${DATE}.sql

 
원격DB백업
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
mysqldump -u 유저 -p"패스워드" -h 아이피주소 -P 포트번호 DBName > 백업명.sql
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
 
# chmod 100 /root/backup.sh


shell이 실행하는지 확인
#./root/backup.sh
실행후 /backup(백업데이터가 저장된폴더)로 가서 파일 확인

Cron 만들기

# crontab -e (매일 6시 백업)

00 06 * * * /root/backup.sh

크론 데몬 재실행
# /etc/rc.d/init.d crond restart

크론 확인
# crontab -l
 원격DB백업 부분은 첨부되었음.

나는 centos 7에서 자동백업 쉘을 만들었는데....
centos 7에는 marisdb 10.1을 설치하였고,
원격은 windows 2012에 mysql 5.6이 설치된상태임.

Cron

Cron
주기적으로 반복되는 작업을 설정해둔 시간에 작동하게 해주는 것.
crontab에 작업 내역을 설정해주면 crond(데몬)가 crontab파일을 읽어서 작업을 해준다

Cron데몬: Crond
작업 목록 설정 파일: crontab
crontab 수정 명령어: crontab

 
1. root계정에서 크론 설정
 
1.1 cron 설정 방법 
crontab -e로 크론 설정 작업을 vi에서 스크립트로 작성 한다.
 
 10       3       *        *         0,4    /etc/cron.d/logchecker
(분) (시간) (day) (month) (weak)         (command)
 
리눅스 Cron
5분에 1번씩 a.sh를 실행 (*/5 <- 5분에 1번씩)
솔라리스는 5,10,15,20 ~ 다 적어야 한다
 
ex) 52 * * * * ls -al /export/home/userA > abc.txt
: 매달 매일 매시간 52분에, /export/home/userA에 속한 파일을 abc.txt 파일에 저장 한다.
 
※ Crontab -e 이 vi모드로 안넘어가면
EDITOR=vi
export EDITOR 치면ok!
 
/var/spool/cron/crontabs/(username)에 작업 내용이 저장. 
vi /var/spool/cron/crontabs/root <- 52 * * * * ls -al /export/home/userA > abc.txt 작업 설정 내용 확인
 
 
1.2 cron 설정 확인
crontab -l: cron 예약 작업 확인.
 
# crontab -l
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
#10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___
55 * * * * ls -al /export/home/userA > abc.txt      <- 아까 설정한 cron
Cron 재시작
/etc/rc.d/init.d/crond stop

/etc/rc.d/init.d/crond start




2. 사용자계정에서 cron 설정
 
2.1 cron 설정
crontab -e로 사용자 크론 설정 명령어를 vi에서 작성 한다.(사용자 계정 로그인 상태에서)
 
2.2 root계정에서 사용자계정의 cron 설정 확인
crontab -l (사용자계정)
# crontab -l userA
19 * * * * ls -al /export/home/userA > abcd.txt
2.3 root계정에서 사용자계정 cron 수정
crontab -e (사용자계정)으로 vi에 들어가 수정한다
 
3. cron 삭제
crontab -r (사용자계정), crontab -e에서 직접 삭제해도 된다(옵션 기억 안나면 다 지워버려!!)
 
4. 사용자계정 접근 제어
/etc/cron.d/cron/deny  or   ~/cron.allow 두 개 파일 중 1개만 있으면 된다.
 
/etc/cron.d/cron.deny <- 설정된 사용자계정 접근 금지(접근금지를 원하는 사용자계정을 추가)
daemon
bin
smtp
nuucp
listen
nobody
noaccess   <-vi로 접근했을 시 기본 설정.
/etc/cron.d/cron.allow: 생성 해줘야 함. 이 파일에 속한 사용자 계정만 접근 허가

[출처] 2011.7.13_ Cron|작성자 홧팅

2015년 11월 10일 화요일

CentOS 7 vsftp설정

1. centos를 설치 후 yum으로 전체 시스템을 update한다.
# yum update -y

2. vsftpd가 설치되어 있는지 확인한다.
# yum list installed vsftpd

3. vsftpd가 설치되어 있지 않으면 vsftpd를 설치한다.
# yum install vsftpd -y

4. yum으로 vsftpd 업데이트
# yum update vsftpd

5. /etc/vsftpd/vsftpd.conf 파일 수정정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 로컬계정 사용자의 접속허용여부
local_enable=YES
# 쓰기(upload) 허용여부
write_enable=YES
local_umask=022
dirmessage_enable=YES
# 파일전송 결과 로깅 여부
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

 6. systemctl 명령어로 vsftpd를 시작/중지/상태확인한다.
# systemctl status vsftpd.service <– vsftpd 상태확인
# systemctl start vsftpd.service <– vsftpd 시작
# systemctl stop vsftpd.service <– vsftpd 중지
# systemctl restart vsftpd.service <– vsftpd 재시작

7. yum으로 ftp client설치
# yum install ftp -y

8. vsftpd 자동실행
# systemctl enable vsftpd.service

** 에러처리
A. # systemctl restart vsftpd.service 명령어로 vsftpd서버를 시작할때 Job for vsftpd.service failed. See ‘systemctl status vsftpd.service’ and ‘journalctl -xn’ for details. 라는 메세지가 나온다면 vsftpd.conf설정파일에 문제가 있어서 발생하는 경우가 있다, 예를 들어 잘못된 키워드가 있다던가 특수 문자가 편집중에 입력이 되었을 경우.
B. vsftpd 서버에 접속하여 파일을 업로드하거나 다운로드할 때 550 Failed to open file. 라는 메세지가 나올 경우가 있다. 이는 SELinux의 보안 정책에 의해 업로드/다운로드 할 수 없을 경우이다. SELinux를 비활성화 하고 서버를 재부팅하면 파일 업로드/다운로드를 할 수 있다.
– SELinux 비활성화 방법
/etc/selinux/config 파일을 열어서 SELINUX=enforcing 를 SELINUX=disabled로 변경후 재부팅 하고 다시 활성화 하려면 SELINUX=enforcing으로 변경하고 리눅스 시스템을 재부팅 한다.
– SELinux 상태보기
sestatus
getsebool -a | grep ftp
C. 로컬에서 vsftpd서버에 접속해서 업로드/다운로드가 잘 되는데 원격에서는 접속조차 되지 않는 경우가 있다. 이는 firewalld 방화벽 때문일수도 있다. firewalld가 실행중인지 확인하고 실행중이라면 firewalld를 중지하고 원격에서 vsftpd서버에 접속해 본다.
— firewalld 실행 상태 확인
# systemctl status firewalld.service
— firewalld 중지
# systemctl stop firewalld.service
— firewalld 자동중지(시스템시작시 자동시작 안함)
# systemctl disable firewalld.service

출처-- http://blog.iotinfra.net/?p=734 에서 옮김.

위의 내용중 550 error인경우는
나는 무시했는 데  발생하더라....
위와 같이 하지 않으면
selinux 설정 변경(꼭 -P 옵션을 붙임)
# setsebool -P ftp_home_dir=1
# setsebool -P ftp_home_dir on
# setsebool -P allow_ftpd_full_acess on처

출처-- http://shuiky.tistory.com/83 참조


#방화벽 21번 포트개방
#systemctl status firewalld.service
#firewall-cmd --permanent --add-port=21/tcp
#firewall-cmd --reload
출처--http://blog.naver.com/knut1031/220948465825


위에서 설명한  /etc/vsftpd/vsftpd.conf 파일은 나의 경우는 다음과 같다
anonymous_enable=NO
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
listen_port=포트번호1
port_enable=YES
pasv_enable=YES
pasv_min_port=포트번호2
pasv_max_port=포트번호3
local_enable=YES
write_enable=YES

다른 글과 달리 비교적 자세히 빼껴놓은 편인데
별로 어렵지 않은 내용임에도 계속 실패를 했었는데
원인이 포트적용이 제대로 되지 않은 탓인경우도 있었고
vsftpd.conf설정이 잘못된 경우였기 때문에
처음 하시는 분들은 참고 바랍니다.




2015년 11월 5일 목요일

centos 7 VNC-server 설치

centos 7 VNC-server 설치

1. yum install tigervnc-server

2. cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

3.vi /etc/systemd/system/vncserver@:1.service
[Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStart=/sbin/runuser -l 유저아이이디 -c "/usr/bin/vncserver %i"
PIDFile=/home/유저아이이디/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
 
4.firewall-cmd --permanent --zone=public --add-service vnc-server
   firewall-cmd --reload
 
5.su - 유저아이이디
vncserver
-- You will require a password to access your desktops
 
Now make the service enabled on after every reboot with root credentials
 
6. su -
systemctl daemon-reload
 
7. systemctl enable vncserver@:1.service
 
8. reboot
systemctl start vncserver@:1.service
 
 
 
 
 
 
 
 
 
 
 

 

2015년 10월 22일 목요일

Centos7에 mySQL workbench 설치

어제 centos7을 설치하고  DB는 mysql을 설치하였는데.....

아주 오래전에 유닉스에서 ls 몇번 해보고 이번에 리눅스를 처음 사용하는지라

가능하면 윈도에서 접속해서 쓸려고 하는데...

윈도10에서 workbench가 연결을 몬한다.
(알고보니 IP를 잘못입력하였다는....)

포트를 설정하고, db권한도 주고 다했는데....


그래서 직접 centos에 workbench를 설치했습니다.

이것도  구글로 찾아보니 http://www.dalescott.net/ 에 잘 설명 되어있네요....


Install EPEL (Extra Packages for Enterprise Linux) repositories:
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
sudo yum install ./epel-release-7-5.noarch.rpm

Install MySQL repositories:
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
wget http://repo.mysql.com/mysql-community-release-el7.rpm
sudo yum install ./mysql-community-release-el7.5.noarch.rpm
sudo yum install ./mysql-community-release-el7.rpm 

(installing mysql-community-release-el7.rpm produced error: “does not update installed package”)
Install MySQL Workbench.
sudo yum install mysql-workbench

Install additional dependencies (that you would be informed of in error messages, if you invoked mysql-workbench
sudo yum install libzip.x86_64
sudo yum install tinyxml.x86_64

You can now start MySQL Workbench using menu: Applications / Programming / MySQL Workbench

References

  • http://www.cyberciti.biz/faq/installing-rhel-epel-repo-on-centos-redhat-7-x/
  • http://www.linuxpcfix.com/how-to-install-and-configure-mysql-workbench-on-linux-system/

2015년 10월 14일 수요일

자바 JDK(Java Development Kit) 설치

Oracle : 오라클 메인 페이지
(http://www.oracle.com/index.html)

Java SE Downloads : 메인페이지에서 다운로드/Java SE 선택
(http://www.oracle.com/technetwork/java/javase/downloads/index.html)

Java SE Development Kit 8 Downloads : Java SE에서 Java Platform (JDK) 8u60 이미지 선택
(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)

마지막에 Accept License Agreement 의 라디오버튼을 선택하고

적합한 OS의 JDK를 다운로드 합니다.


 인스톨은 끝 까지 넥스트....마지막으로 Close 나오면 끝

Android Studio

다운로드 이미지 클릭
(http://developer.android.com/sdk/index.html#top)















Android SDK 도 설치가 필요하면(미리 설치되지 않았다면) DownLoad해서

설치하면 됩니다.(최신버전으로)



















vsftpd FTP 서버 접속은 성공하였으나, "디렉토리 목록 조회 실패" 현상 발생시

FTP Passive 모드를 활성화 필요. 1. vsftpd 설정 변경 /etc/vsftpd/vsftpd.conf 상에 아래 내용 추가 기입 #passive modpasv_enable=YES pasv_min_port=5001 pasv...