[root@ip-172-31-33-333 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
AWS환경에서 amazon linux에 mariadb를 설치 및 셋팅하는 방법을 정리한 글입니다.(2021.03.03)
EC2생성후 접속시 os계정 접속시 root는 접속 불가능하다. 아래와 같이 aws os플랫폼 별로 로긴하는 방법을 참고하자
이후 yum mariadb 설치 명령어로 진행한다.
[ec2-user@ip-172-31-33-333 ~]$ sudo su -
Last login: Wed Mar 3 11:36:40 UTC 2021 from 58.127.248.108 on pts/0
[root@ip-172-31-33-333 ~]#
[root@ip-172-31-33-333 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@ip-172-31-33-333 ~]# yum -y install mariadb-server mariadb
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.amzn2 will be installed
---> Package mariadb-server.x86_64 1:5.5.68-1.amzn2 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.68-1.amzn2.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.68-1.amzn2.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.68-1.amzn2.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.68-1.amzn2.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.amzn2 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.amzn2.0.2 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.amzn2.0.2.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.amzn2.0.2.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.amzn2.0.2 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.amzn2 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.amzn2.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.amzn2.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.amzn2.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.amzn2.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.amzn2 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.amzn2.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.amzn2.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.amzn2 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.amzn2.0.2 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.amzn2.0.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mariadb x86_64 1:5.5.68-1.amzn2 amzn2-core 8.8 M
mariadb-server x86_64 1:5.5.68-1.amzn2 amzn2-core 11 M
Installing for dependencies:
perl-Compress-Raw-Bzip2 x86_64 2.061-3.amzn2.0.2 amzn2-core 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.amzn2.0.2 amzn2-core 58 k
perl-DBD-MySQL x86_64 4.023-6.amzn2 amzn2-core 141 k
perl-DBI x86_64 1.627-4.amzn2.0.2 amzn2-core 804 k
perl-Data-Dumper x86_64 2.145-3.amzn2.0.2 amzn2-core 48 k
perl-IO-Compress noarch 2.061-2.amzn2 amzn2-core 260 k
perl-Net-Daemon noarch 0.48-5.amzn2 amzn2-core 51 k
perl-PlRPC noarch 0.2020-14.amzn2 amzn2-core 36 k
Transaction Summary
================================================================================
Install 2 Packages (+8 Dependent packages)
Total download size: 22 M
Installed size: 110 M
Downloading packages:
(1/10): mariadb-server-5.5.68-1.amzn2.x86_64.rpm | 11 MB 00:00
(2/10): mariadb-5.5.68-1.amzn2.x86_64.rpm | 8.8 MB 00:00
(3/10): perl-Compress-Raw-Bzip2-2.061-3.amzn2.0.2.x86_64.r | 32 kB 00:00
(4/10): perl-Compress-Raw-Zlib-2.061-4.amzn2.0.2.x86_64.rp | 58 kB 00:00
(5/10): perl-DBD-MySQL-4.023-6.amzn2.x86_64.rpm | 141 kB 00:00
(6/10): perl-Data-Dumper-2.145-3.amzn2.0.2.x86_64.rpm | 48 kB 00:00
(7/10): perl-DBI-1.627-4.amzn2.0.2.x86_64.rpm | 804 kB 00:00
(8/10): perl-Net-Daemon-0.48-5.amzn2.noarch.rpm | 51 kB 00:00
(9/10): perl-IO-Compress-2.061-2.amzn2.noarch.rpm | 260 kB 00:00
(10/10): perl-PlRPC-0.2020-14.amzn2.noarch.rpm | 36 kB 00:00
--------------------------------------------------------------------------------
Total 48 MB/s | 22 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Data-Dumper-2.145-3.amzn2.0.2.x86_64 1/10
Installing : perl-Compress-Raw-Bzip2-2.061-3.amzn2.0.2.x86_64 2/10
Installing : 1:mariadb-5.5.68-1.amzn2.x86_64 3/10
Installing : perl-Net-Daemon-0.48-5.amzn2.noarch 4/10
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.amzn2.0.2.x86_64 5/10
Installing : perl-IO-Compress-2.061-2.amzn2.noarch 6/10
Installing : perl-PlRPC-0.2020-14.amzn2.noarch 7/10
Installing : perl-DBI-1.627-4.amzn2.0.2.x86_64 8/10
Installing : perl-DBD-MySQL-4.023-6.amzn2.x86_64 9/10
Installing : 1:mariadb-server-5.5.68-1.amzn2.x86_64 10/10
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.amzn2.0.2.x86_64 1/10
Verifying : perl-IO-Compress-2.061-2.amzn2.noarch 2/10
Verifying : perl-Net-Daemon-0.48-5.amzn2.noarch 3/10
Verifying : perl-Data-Dumper-2.145-3.amzn2.0.2.x86_64 4/10
Verifying : perl-DBD-MySQL-4.023-6.amzn2.x86_64 5/10
Verifying : 1:mariadb-server-5.5.68-1.amzn2.x86_64 6/10
Verifying : 1:mariadb-5.5.68-1.amzn2.x86_64 7/10
Verifying : perl-Compress-Raw-Bzip2-2.061-3.amzn2.0.2.x86_64 8/10
Verifying : perl-DBI-1.627-4.amzn2.0.2.x86_64 9/10
Verifying : perl-PlRPC-0.2020-14.amzn2.noarch 10/10
Installed:
mariadb.x86_64 1:5.5.68-1.amzn2 mariadb-server.x86_64 1:5.5.68-1.amzn2
Dependency Installed:
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.amzn2.0.2
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.amzn2.0.2
perl-DBD-MySQL.x86_64 0:4.023-6.amzn2
perl-DBI.x86_64 0:1.627-4.amzn2.0.2
perl-Data-Dumper.x86_64 0:2.145-3.amzn2.0.2
perl-IO-Compress.noarch 0:2.061-2.amzn2
perl-Net-Daemon.noarch 0:0.48-5.amzn2
perl-PlRPC.noarch 0:0.2020-14.amzn2
Complete!
[root@ip-172-31-33-333 ~]#
이후 서비스 기동을 해본다.
systemctl start mariadb
[root@ip-172-31-33-333 ~]# systemctl start mariadb
[root@ip-172-31-33-333 ~]# ps -ef | grep maria
mysql 3899 3733 1 11:52 ? 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 3935 3431 0 11:52 pts/0 00:00:00 grep --color=auto maria
[root@ip-172-31-33-333 ~]#
[root@ip-172-31-33-333 ~]# ps -ef | grep mysql
mysql 3733 1 0 11:52 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql 3899 3733 0 11:52 ? 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 3937 3431 0 11:52 pts/0 00:00:00 grep --color=auto mysql
이후 서비스상태 확인도 해본다.
systemctl status mariadb
[root@ip-172-31-33-333 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2021-03-03 11:52:11 UTC; 5min ago
Process: 3734 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 3651 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 3733 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─3733 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─3899 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mariadb-prepare-db-dir[3651]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mysqld_safe[3733]: ...
Mar 03 11:52:09 ip-172-31-33-333.ap-northeast-2.compute.internal mysqld_safe[3733]: ...
Mar 03 11:52:11 ip-172-31-33-333.ap-northeast-2.compute.internal systemd[1]: ...
Hint: Some lines were ellipsized, use -l to show in full
putty 터미널에서 접속을 해본다.
mysql -u root
[root@ip-172-31-33-333 ~]# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
서버 재부팅시 자동으로 mariadb가 서비스기동되도록 설정한다.
grant all privileges on *.* to tstadmin@'%' identified by 'tst30333!' ;
모든 인스턴스에 권한을 부여한 유저를 생성해본다.
mysql(mariadb) 익스포트, 임포트 방법(definer 제거까지) (0) | 2024.04.12 |
---|---|
my.cnf에 [client]등 그룹 항목이 필요한 이유 (0) | 2020.06.25 |