이번 포스팅에서는 WAS서버의 DB부분을 구축할 예정이다.
앞 포스팅에서 WAS Server를 구축하면서 Tomcat8을 설치했다.
이번에는 WAS Server에 설치되는 MySQL5.7을 설치하려한다.
< 설치 버전 >
$ sudo yum install cmake ncurses ncurses-devel \
ncurses-libs ncurses-static openssl \
openssl-devel bison readline \
gcc gcc-c++ make cmake glibc \
automake numactl numactl-devel \
libaio libaio-devel perl perl-Data-Dumper
$ cd /usr/local/src/
$ wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
$ tar zxvf boost_1_59_0.tar.gz
# MySQL download
$ cd /usr/local/src/
$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31.tar.gz
$ tar zxvf mysql-5.7.31.tar.gz
$ cd mysql-5.7.31
MySQL5.7 configure 관련해서 자세한 설정이 궁금하다면,
https://velog.io/@nari120/MySQL5.7-Configure-option
$ cmake \
'-DCMAKE_INSTALL_PREFIX=/usr/local/mysql' \
'-DINSTALL_SBINDIR=/usr/local/mysql/bin' \
'-DINSTALL_BINDIR=/usr/local/mysql/bin' \
'-DMYSQL_DATADIR=/usr/local/mysql/data' \
'-DINSTALL_SCRIPTDIR=/usr/local/mysql/bin' \
'-DWITH_INNOBASE_STORAGE_ENGINE=1' \
'-DWITH_PARTITION_STORAGE_ENGINE=1' \
'-DSYSCONFDIR=/usr/local/mysql/etc' \
'-DDEFAULT_CHARSET=utf8' \
'-DDEFAULT_COLLATION=utf8_general_ci' \
'-DWITH_EXTRA_CHARSETS=all' \
'-DWITH_SSL=bundled' \
'-DWITH_SSL_PATH=/usr/include/openssl' \
'-DENABLED_LOCAL_INFILE=1' \
'-DMYSQL_TCP_PORT=3306' \
'-DMYSQL_UNIX_ADDR=/tmp/mysql.sock' \
'-DCURSES_LIBRARY=/usr/lib64/libncurses.so' \
'-DCURSES_INCLUDE_PATH=/usr/include' \
'-DDOWNLOAD_BOOST=1' \
'-DWITH_BOOST=/usr/local/src/boost_1_59_0' \
'-DWITH_ARCHIVE_STORAGE_ENGINE=1' \
'-DWITH_BLACKHOLE_STORAGE_ENGINE=1' \
'-DWITH_PERFSCHEMA_STORAGE_ENGINE=1' \
'-DWITH_FEDERATED_STORAGE_ENGINE=1'
-DWITH_SSL=/usr/local/openssl-1.0.1l
-DWITH_ZLIB=system -DMYSQL_DATADIR=/usr/local/mysql-5.6.22/data -DENABLE_DOWNLOADS=1
$ make && make install
## MySQL 라이브러리 등록
$ echo /usr/local/mysql/lib >> /etc/ld.so.conf
$ ldconfig
$ cd /usr/local/mysql
$ mkdir logs tmp data
$ touch /usr/local/mysql/logs/mysqld_safe.err
$ chown -R root /usr/local/mysql
$ cd /usr/local/mysql/bin
$ ./mysqld --initialize \
--user=root \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
./mysql_install_db --user=root \
--datadir=/usr/local/mysql/data
cd /usr/local/mysql/bin
./mysql_secure_installation
# 생성된 데이터 파일 확인(비어있지않으면 잘 생성된 것..!)
$ ls -al /usr/local/mysql/data/
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chown root.root /etc/init.d/mysqld
chkconfig --add mysqld
$ vi /etc/my.cnf
[client]
port = 3306
socket=/tmp/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket=/tmp/mysql.sock
datadir=/usr/local/mysql/data
basedir = /usr/local/mysql
user = root
bind-address = 0.0.0.0
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 8M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
skip-name-resolve
max_connections = 1000
max_connect_errors = 1000
wait_timeout= 60
explicit_defaults_for_timestamp
symbolic-links=0
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid
character-set-client-handshake=FALSE
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci
symbolic-links=0
default-storage-engine = myisam
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
$ cd /usr/local/mysql/bin
$ systemctl start mysqld
# /tmp/mysql.sock 생성 확인
$ cd /tmp
$ ls
# mysqld_safe로 가동
$ /usr/local/mysql/bin/mysqld_safe &
$ cd /usr/local/mysql/logs
$ cat mysqld_safe.err | grep generated
or
$ cd /usr/local/mysql/data
$ grep 'temporary password' mysqld.log
[Note] A temporary password is generated for root@localhost: *hyjVFL6pf*V
# mysql 접속방법 2가지
$ /usr/local/mysql/bin/mysql -uroot -p
or
$ cd /usr/local/mysql/bin
$ ./mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
mysql> commit;
mysql> flush privileges;
mysql>
$ cd /usr/local/mysql/bin
$ ./mysql -u root -p
password: root
$ rm -rf CMakeCache.txt
$ rm -rf CMakeFile