728x90
반응형
큰 마음을 먹고 앞으로 진행하는 작업 중 재사용이 가능한 task에 대해서는 블로그에 작성해보기로 결심했습니다.
미래의 나에게 보여주는 형식으로 작성했으니 반말은 이해해주세용 :)
항상 그랬듯 AWS EC2를 프리티어로 만들었다.
AWS 계정 생성 및 EC2 인스턴스 만드는 방법은 이미 잘 설명해 놓은 블로드들이 많으니 패스
인스턴스를 생성하면서 만들어놓은 pem 파일을 이용하여 iTerms로 연결해두었다.
iTerms를 이용하여 처음 접속하게 되면 아래와 같은 화면이 표시된다.
Last login: Fri Dec 17 15:10:03 on ttys005
ssh -i "metacode.pem" ubuntu@ec2-3-11-11-61.ap-northeast-2.compute.amazonaws.com
(base) hercules@kjm MetaCode % ssh -i "metacode.pem" ubuntu@ec2-3-36-62-61.ap-no
rtheast-2.compute.amazonaws.com
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-1022-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Fri Dec 17 06:11:13 UTC 2021
System load: 0.0 Processes: 99
Usage of /: 4.9% of 29.02GB Users logged in: 0
Memory usage: 20% IPv4 address for eth0: 172.31.39.237
Swap usage: 0%
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@ip-111-31-39-237:~$
자세한 이름을 찍어보기 위해서는 uname -a
ubuntu@ip-111-31-39-237:~$ uname -a
Linux ip-111-31-39-237 5.11.0-1022-aws #23~20.04.1-Ubuntu SMP Mon Nov 15 14:03:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
이제부터 본격적으로 MariaDB를 설치해본다.
바로 mariadb-server를 설치하려고 하니 에러가 발생한다.
$ sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mariadb-server
아래와 같이 sudo apt update 를 통해 apt 명령어를 사용할수 있게 해놓고
~$ sudo apt update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
. . .
다시 한번 sudo apt install mariadb-server 명령어를 수행한다.
(중간에 계속할건지 물어보는 경우 Y 입력)
$ sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
galera-3 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl
libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
libio-html-perl liblwp-mediatypes-perl libmysqlclient21 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl
mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 mysql-common socat
Suggested packages:
libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx
mariadb-test tinyca
The following NEW packages will be installed:
galera-3 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl
libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
libio-html-perl liblwp-mediatypes-perl libmysqlclient21 libsnappy1v5 libterm-readkey-perl libtimedate-perl liburi-perl
mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3
mysql-common socat
0 upgraded, 28 newly installed, 0 to remove and 16 not upgraded.
Need to get 21.3 MB of archives.
After this operation, 174 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
. . .
드디어 MariaDB 설치 완료!
다음은 클라이언트 설치
$ sudo apt install mariadb-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mariadb-client
0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded.
Need to get 12.5 kB of archives.
After this operation, 68.6 kB of additional disk space will be used.
Get:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-client all 1:10.3.32-0ubuntu0.20.04.1 [12.5 kB]
Fetched 12.5 kB in 0s (680 kB/s)
Selecting previously unselected package mariadb-client.
(Reading database ... 64710 files and directories currently installed.)
Preparing to unpack .../mariadb-client_1%3a10.3.32-0ubuntu0.20.04.1_all.deb ...
Unpacking mariadb-client (1:10.3.32-0ubuntu0.20.04.1) ...
Setting up mariadb-client (1:10.3.32-0ubuntu0.20.04.1) ...
다음은 sudo mysql_secure_installation 명령어를 통해 기본 설정 세팅
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
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.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Sorry, passwords do not match.
New password:
Re-enter new 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] n
... skipping.
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]
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
드디어 세팅 완료!!
$ sudo mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 56
Server version: 10.3.32-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
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 [(none)]>
(추가) DB Client 접속을 위한 설정
1. mysqld option 확인
$ mysqld --print-defaults
mysqld would have been started with the following arguments:
--user=mysql --pid-file=/run/mysqld/mysqld.pid --socket=/run/mysqld/mysqld.sock --basedir=/usr --datadir=/var/lib/mysql --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --bind-address=127.0.0.1 --query_cache_size=16M --log_error=/var/log/mysql/error.log --expire_logs_days=10 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
2. 설정 파일에 설정값 추가
$ sudo vi /etc/mysql/my.cnf
. . .
skip-networking=0
skip-bind-address
3. mysql 재실행
$ sudo systemctl restart mysql
$ mysqld --print-defaults
4. EC2 보안그룹 편집하기 (인바운드 규칙에 TCP 3306 추가)
728x90
반응형
'Development > DB' 카테고리의 다른 글
MariaDB 개발하기 (0) | 2021.12.17 |
---|