MySQL과 함께 MariaDB 설치
=======================================
mariadb-5.5.24-linux-x86_64.tar.gz 설치
=======================================
MariaDB와 Mysql DB 함께 설치 할 수 있음.
1. 시스템 정보 확인.
1.1 운영체제 정보
cat /etc/issue
Ubuntu 12.04.5 LTS \n \l
1.2 DB 정보
mysql --version
mysql Ver 14.14 Distrib 5.5.54, for debian-linux-gnu (x86_64) using readline 6.2
2. MariDB 설치
MariaDB 다운로드 : http://downloads.mariadb.org/mariadb/5.5.24/#bits=64&file_type=tar_gz
2.1 심볼릭 링크
cd /opt/
mkdir mariadb-data
ln -s mariadb-5.5.24-linux-x86_64 mariadb
ls -al
lrwxrwxrwx 1 root root 27 Dec 4 13:42 mariadb -> mariadb-5.5.24-linux-x86_64
drwxr-xr-x 13 root root 4096 Dec 4 13:42 mariadb-5.5.24-linux-x86_64
-rw-r--r-- 1 root root 213836788 Dec 4 13:41 mariadb-5.5.24-linux-x86_64.tar.gz
drwxr-xr-x 2 root root 4096 Dec 4 13:42 mariadb-data
drwxr-xr-x 9 root root 4096 Nov 28 12:01 samba4
2.2 사용자 생성 및 소유권 설정
groupadd --system mariadb
useradd -c "MariaDB Server" -d /opt/mariadb -g mariadb --system mariadb
chown -R mariadb:mariadb mariadb-5.5.24-linux-x86_64/
chown -R mariadb:mariadb mariadb-data/
3 my.cnf 설정
3.1 편집
pwd
/opt
cp mariadb/support-files/my-medium.cnf mariadb-data/my.cnf
chown mariadb:mariadb mariadb-data/my.cnf
vi ./mariadb-data/my.cnf
[client]
port = 3307
socket = /opt/mariadb-data/mariadb.sock
[mysqld]
datadir = /opt/mariadb-data
basedir = /opt/mariadb
port = 3307
socket = /opt/mariadb-data/mariadb.sock
user = mariadb
4. 데몬 구동
cp mariadb/support-files/mysql.server /etc/init.d/mariadb
chmod +x /etc/init.d/mariadb
4.1 데몬 시작 파일 편집
vi /etc/init.d/mariadb
- # Provides: mysql
+ # Provides: mariadb
- basedir=
+ basedir=/opt/mariadb
- datadir=
+ datadir=/opt/mariadb-data
- lock_file_path="$lockdir/mysql"
+ lock_file_path="$lockdir/mariadb"
4.1 하나의 구성 파일만 사용하도록 설정
/etc/init.d/mariadb 파일 수정.
# my.cnf 파일을 사용하여 mysqld에 다가 추가 인수를 제공해야한다.
# 만약 업그레이드가 일어나면 스크립트를 덮어 쓸 수 있다.
$bindir/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
# mariadb start mysqladmin 명령어 사용.
wait_for_ready () {
[...]
if $bindir/mysqladmin --defaults-file=/opt/mariadb-data/my.cnf ping >/dev/null 2>&1; then
수정파일
=== modified file 'support-files/mysql.server.sh'
--- support-files/mysql.server.sh 2017-07-16 17:09:54 +0000
+++ support-files/mysql.server.sh 2018-02-17 10:10:30 +0000
@@ -147,68 +147,12 @@
datadir_set=1
;;
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ --socket=*) socket=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
esac
done
}
-wait_for_pid () {
- verb="$1" # created | removed
- pid="$2" # process ID of the program operating on the pid-file
- pid_file_path="$3" # path to the PID file.
-
- i=0
- avoid_race_condition="by checking again"
-
- while test $i -ne $service_startup_timeout ; do
-
- case "$verb" in
- 'created')
- # wait for a PID-file to pop into existence.
- test -s "$pid_file_path" && i='' && break
- ;;
- 'removed')
- # wait for this PID-file to disappear
- test ! -s "$pid_file_path" && i='' && break
- ;;
- *)
- echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
- exit 1
- ;;
- esac
-
- # if server isn't running, then pid-file will never be updated
- if test -n "$pid"; then
- if kill -0 "$pid" 2>/dev/null; then
- : # the server still runs
- else
- # The server may have exited between the last pid-file check and now.
- if test -n "$avoid_race_condition"; then
- avoid_race_condition=""
- continue # Check again.
- fi
-
- # there's nothing that will affect the file.
- log_failure_msg "The server quit without updating PID file ($pid_file_path)."
- return 1 # not waiting any more.
- fi
- fi
-
- echo $echo_n ".$echo_c"
- i=`expr $i + 1`
- sleep 1
-
- done
-
- if test -z "$i" ; then
- log_success_msg
- return 0
- else
- log_failure_msg
- return 1
- fi
-}
-
# Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
if test -x ./bin/my_print_defaults
@@ -266,6 +210,69 @@
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
+# wait for the pid file to disappear
+wait_for_gone () {
+ pid="$1" # process ID of the program operating on the pid-file
+ pid_file_path="$2" # path to the PID file.
+
+ i=0
+ crash_protection="by checking again"
+
+ while test $i -ne $service_startup_timeout ; do
+
+ if kill -0 "$pid" 2>/dev/null; then
+ : # the server still runs
+ else
+ if test ! -s "$pid_file_path"; then
+ # no server process and no pid-file? great, we're done!
+ log_success_msg
+ return 0
+ fi
+
+ # pid-file exists, the server process doesn't.
+ # it must've crashed, and mysqld_safe will restart it
+ if test -n "$crash_protection"; then
+ crash_protection=""
+ sleep 5
+ continue # Check again.
+ fi
+
+ # Cannot help it
+ log_failure_msg "The server quit without updating PID file ($pid_file_path)."
+ return 1 # not waiting any more.
+ fi
+
+ echo $echo_n ".$echo_c"
+ i=`expr $i + 1`
+ sleep 1
+
+ done
+
+ log_failure_msg
+ return 1
+}
+
+wait_for_ready () {
+
+ test -n "$socket" && sockopt="--socket=$socket"
+
+ i=0
+ while test $i -ne $service_startup_timeout ; do
+
+ if $bindir/mysqladmin $sockopt ping >/dev/null 2>&1; then
+ log_success_msg
+ return 0
+ fi
+
+ echo $echo_n ".$echo_c"
+ i=`expr $i + 1`
+ sleep 1
+
+ done
+
+ log_failure_msg
+ return 1
+}
#
# Set pid file if not given
#
@@ -292,7 +299,7 @@
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
- wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
+ wait_for_ready; return_value=$?
# Make lock for RedHat / SuSE
if test -w "$lockdir"
@@ -319,7 +326,7 @@
echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid file when it exits, so wait for it.
- wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
+ wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
else
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
rm "$mysqld_pid_file_path"
5. 테스트
설정 파일 지정.
cd /opt/mariadb
scripts/mysql_install_db --defaults-file=/opt/mariadb-data/my.cnf
데몬 시작.
/etc/init.d/mariadb start
cd /etc/init.d
시작 데몬 등록
chmod +x mariadb
update-rc.d mariadb defaults
6. 확인.
mysql -e "SELECT VERSION();"
+--------------------+
| VERSION() |
+--------------------+
| 5.5.24-MariaDB-log |
+--------------------+
mysql -e "SELECT VERSION();" --socket=/opt/mariadb-data/mariadb.sock
Enter password:
+-----------+
| VERSION() |
+-----------+
| 5.5.41 |
+-----------+
# mysql --socket=/opt/mariadb-data/mariadb.sock
mariadb 패스워드 설정
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("new-password") where User='root';
mysql> flush privileges;
mysql> exit
익명 사용자 삭제
DELETE FROM mysql.user WHERE user='' AND host='myhost';
FLUSH PRIVILEGES;
테스트베이스를 삭제하고 접근
DELETE FROM mysql.db WHERE db LIKE 'tes%' AND user='';
FLUSH PRIVILEGES;
데이터베이스에 대한 원격 연결 비활성화
vi my.cnf
bind-address=127.0.0.1
/opt/mariadb-data 디렉토리에 MariaDB 데이터베이스를 업데이트 할 경우(mariadb.socket, my.cnf)
/opt 새 버전의 데이터베이스 압축푼다.
심볼릭 링크 mariadb를 지정된 디렉토리로 변경하십시오.
MariaDB 시작
소켓을 사용하여 업데이트 스크립트를 실행 -> --socket=/opt/mariadb-data/mariadb.sock
mysql 데이터 베이스 동기화 업그레이드.(myaql에 DB가 마리아DB로 업데이트 된다).
/usr/local/mariadb/bin/mysql_upgrade -uroot -p
===============================
Mariadb10.2.8 데이터베이스 설치
===============================
다운로드 : https://downloads.mariadb.org/interstitial/mariadb-10.2.8/bintar-linux-x86_64/mariadb-10.2.8-linux-x86_64.tar.gz?serv
cd /usr/local/mariadb
sudo groupadd --system mariadb
sudo useradd -g mariadb mariadb
sudo chown -R mariadb:mariadb /usr/local/mariadb
sudo chown -R mariadb:mariadb /usr/local/mariadb/data/
sudo cp /usr/local/mariadb/support-files/my-large.cnf /usr/local/mariadb/data/my.cnf
vi /usr/local/mariadb/data/my.cnf
[client]
#password = your_password
port = 3307
socket = /opt/mariadb-data/mariadb.sock
# Here follows entries for some specific programs
# The MariaDB server
[mysqld]
datadir = /opt/mariadb-data
basedir = /opt/mariadb
port = 3307
socket = /opt/mariadb-data/mariadb.sock
user = mariadb
sudo cp /usr/local/mariadb/support-files/mysql.server /etc/init.d/mariadb
sudo chmod +x /etc/init.d/mariadb
vi /etc/init.d/mariadb
- # Provides: mysql
+ # Provides: mariadb
- basedir=
+ basedir=/usr/local/mariadb
- datadir=
+ datadir=/usr/local/mariadb/data
- lock_file_path="$lockdir/mysql"
+ lock_file_path="$lockdir/mariadb"
$bindir/mysqld_safe --defaults-file=/usr/local/mariadb/data/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
wait_for_ready; return_value=$?
1. mysql, mariadb 바이너리 버전으로 설치 후 부팅시 시작 오류 발생.
메세지 내용.
/usr/local/mysql/share/errmsg.sys를 찾을 수 없음.
바이너리 설치 디렉토리 /usr/local/mysql이 아닌 경우 오류 발생.
추가
설치 파일 경로는 /usr/local/mysql 일 경우.
/etc/my.cnf 파일에 다음줄 추가.
language = /usr/local/mysql/share/english
/etc/mysql/my.cnf 권한 변경
chmod 644 /etc/mysql/my.cnf
/etc/mysql/debian-start 실행에서 문제가 발생.
다음 명령을 통해 debian-start 검색
locate debian-start
updatedb
locate debian-start
파일복사.
mariadb-10.2.8/debian/additions/debian-star /etc/mysql/
2. mariadb 버전 업그레이드
/usr/local/mariadb/bin/mysql_upgrade -uroot -p
========================================
Mariadb 우분투 저장소 단일 DB 사용 설치
========================================
sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
ubuntu 12.04
# sudo add-apt-repository 'deb http://mirror.klaus-uwe.me/mariadb/repo/5.5/ubuntu precise main'
Ubuntu 12.10
# sudo add-apt-repository 'deb http://mirror.klaus-uwe.me/mariadb/repo/5.5/ubuntu quantal main'
Ubuntu 13.10
# sudo add-apt-repository 'deb http://mirror.klaus-uwe.me/mariadb/repo/5.5/ubuntu saucy main'
sudo apt-get update
sudo apt-get install mariadb-server
sudo service mysql start
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 35
Server version: 5.5.36-MariaDB-1~saucy-log mariadb.org binary distribution
.
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
.
MariaDB [(none)]>
설치시 이미 업그레이드 됨.
mysql_upgrade -uroot -p
댓글 없음:
댓글 쓰기