-
Notifications
You must be signed in to change notification settings - Fork 0
1. MariaDB download Script.md
couplewith edited this page Mar 29, 2017
·
4 revisions
-
리눅스 환경에서 패키지를 설치하려면할수 없이 패키지를 다운 받아서 설치를 해야 하기도 합니다.
-
요즘과 같이 내부와 외부간의 네트웍 망분리가 된 상태라면 설치 파일을 받아서 내부로 보내야 하기도 하고 때로는 방화벽 문제로 외부 YUM으로 접근이 안되는 상황도 있습니다.
-
또 설치를 하고 세월이 흘러 업그레이드를 해야 할때 (현재 설치된 패키지의 상태를 확인 하는 경우) "와우~ 참 받은지도 오래 됬고 설치된 지도 오래 됬구나 ~~!! " 를 느끼면 다시 설치하지 않을까요 ?
-
이런 저런 이유에서 아래와 같이 설치 스크립트를 가지고 여러대의 서버에 설치 환경을 만들어 둡니다.
- sh get_mariadb.sh : 다운로드만 합니다.
- sh get_mariadb.sh install : 다운로드 하고 설치를 합니다.
VER="10.0.2"
VER="10.1.22" # 2017.3.14
REV=`echo $VER | cut -d"." -f1,2` # 10.1
VER55="5.5.54" # 2017.3.7
REV55=`echo $VER55 | cut -d"." -f1,2` # 5.5
PLATFORM="centos6-x86_64"
##[URL ]##########################################
BASE_URL64=http://ftp.kaist.ac.kr/mariadb/mariadb-$VER/yum/centos6-amd64/rpms
BASE_URL_BIN=http://ftp.kaist.ac.kr/mariadb/mariadb-$VER/bintar-linux-x86_64
BASE_URL_BIN55=http://ftp.kaist.ac.kr/mariadb/mariadb-$VER55/bintar-linux-x86_64
# http://ftp.kaist.ac.kr/mariadb/mariadb-10.1.21/bintar-linux-x86_64/mariadb-10.1.21-linux-x86_64.tar.gz
##[PKG ]#########################################
PKGLIST_EXT="galera-25.3.19-1.rhel6.el6.x86_64.rpm \
jemalloc-3.6.0-1.el6.x86_64.rpm \
jemalloc-devel-3.6.0-1.el6.x86_64.rpm"
PKGLIST=`cat <>>>>>>>> get_MariaDB.env >>>>>>>>>>"
echo " BASE_URL64 :[$BASE_URL64]"
echo " PKGLIST :[$PKGLIST]"
echo " PKGLIST_EXT:[$PKGLIST_EXT]"
if [ -f "get_Mariadb.env" ]
then
source ./get_Mariadb.env
else
echo " $0.sh : get_Mariadb.env Notfound !! "
exit
fi
### Download RPM ##################
mkdir Maria-$REV
mkdir Maria-$REV55;
# -----------------
for pkg in $PKGLIST
do
# pkg_name="Maria-10.1/MariaDB-${VER}-centos6-x86_64-compat.rpm"
pkg_name="Maria-$REV/$pkg"
down_url="$BASE_URL64/$pkg"
if [ ! -f "$pkg_name" ]
then
wget $down_url -O $pkg_name;
else
echo " > (MariaDB) download exists [$pkg_name] "
fi
Ret=$?
ls -al $pkg_name;
done
#--------------------------------------
# *** EXT : jemalloc, galera ****
#--------------------------------------
for pkg in $PKGLIST_EXT
do
# pkg_name="Maria-10.1/MariaDB-${VER}-centos6-x86_64-compat.rpm"
pkg_name="Maria-$REV/$pkg"
down_url="$BASE_URL64/$pkg"
if [ ! -f "$pkg_name" ]
then
wget $down_url -O $pkg_name;
else
echo " > (Maria_Ext) download exists [$pkg_name] "
fi
Ret=$?
ls -al $pkg_name;
done
### Download BIN ##################
function WGET () {
wget_opt=" --tries=2 "
if [ -z "$2" ]
then
file_name=$(basename $1 );
else
file_name=$(basename $2 );
fi
download_url=$1/$2
down_file=${2:-"Maria-$REV/$file_name"}
down_desc=${3:-"$file_name"}
if [ ! -f "$down_file" ]
then
wget $wget_opt $download_url -O $down_file
else
echo " >> WGET : $down_file Exists !!! "
fi
ls -al $down_file
echo " >>> WGET [$down_desc] : $down_file Done !!! "
}
#*********************************
## down load bin-pkg
# -------------------------
bin_name="Maria-$REV/mariadb-$VER-linux-x86_64.tar.gz"
bin_name55="Maria-$REV55/mariadb-$VER55-linux-x86_64.tar.gz"
WGET $BASE_URL_BIN $bin_name "bin_down-$REV"
WGET $BASE_URL_BIN55 $bin_name55 "bin_down-$REV55"
## down load Judy
# -------------------------
WGET $BIN_EXT_URL1
WGET $BIN_EXT_URL2
### INSTALL RPM ##################
if [ -z "$1" ]
then
echo " *>>>>>>****************************************"
echo " Usage : $0 install "
echo " download Done & install Skipped !! "
echo " ***********************************************"
exit;
else
# for install oqgraph-engine #
# libJudy.so.1()(64bit) is needed by MariaDB-oqgraph-engine-10.0.12-1.el6.x86_64
yum install -y judy judy-devel
if [ ! $Ret -eq 0 ]
then
echo " Custom install : Judy !! "
ls -al $Maria-$REV/Judy-*
fi
for pkg in $PKGLIST
do
# pkg_name="Maria-10.0/MariaDB-10.0.12-centos6-x86_64-$pkg.rpm"
pkg_name="Maria-$REV/$pkg"
if [ -e "$pkg_name" ]
then
rpm -Uvh $pkg_name && echo " install _successed $pkg_name !!"
else
echo " install _failed $pkg_name !!"
fi
done
rpm -qa | grep -i "mariadb"
fi
cd /usr/local/src/DBMS
cp -rp yum.repo/* /etc/yum.repos.d/
# --------------------------------------------
# Pre yum install
# --------------------------------------------
yum install -y libJudy unixODBC unixODBC-devel
# --------------------------------------------
# install Pkgs
# --------------------------------------------
yum install MariaDB-common MariaDB-devel MariaDB-client MariaDB-server MariaDB-shared MariaDB-gssapi-client MariaDB-gssapi-server MariaDB-connect-engine MariaDB-compat MariaDB-devel MariaDB-cassandra-engine MariaDB-oqgraph-engine
Ret=$?
if [ "$Ret" -eq 0 ]
then
echo " Try again after delete yum.rep mirror info "
echo ">> rm -rf /var/cache/yum/x86_64/6/epel "
fi
#######################################
# Yum.repo
# cp yum.rep/* /etc/yum.repo.d/
# yum install MariaDB .....
sh install_yum_Mariadb.sh
#######################################
## install Mariadb
# /etc/my.cnf.d/*.cnf
rsync -ar --progress my.cnf.d/* /etc/my.cnf.d
########################################
#####################
mkdir -p /DATABASE
vi /etc/fstab
/dev/sda1 /DATABASE ext4 defaults,noatime 1 1
mount -a
mount -o remount /dev/sda1
[root@Stage-Mysql01 Maria]# cat /proc/mounts | grep sda
/dev/sda1 /DATABASE ext4 rw,noatime,barrier=1,data=ordered 0 0
#####################
mkdir -p /DATABASE/MyData /DATABASE/MyLogs /DATABASE/WSREP_Data
chown mysql:mysql /DATABASE/MyData /DATABASE/MyLogs /DATABASE/WSREP_Data
################
Master node
#################
# mysql_install_db or
* /usr/bin/mysql_secure_installation
/etc/rc.d/init.d/mysql stop
mysqld_safe --wsrep-new-cluster
/etc/rc.d/init.d/mysql start
################
Master node
#################
rm -rf /DATABASE/MyData/*
rm -rf /DATABASE/MyLogs/*
* mysql_install_db or
# /usr/bin/mysql_secure_installation
/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysql start
[root@Stage-Mysql03 DATABASE]# /etc/rc.d/init.d/mysql start
Starting MySQL.170215 18:44:29 mysqld_safe Logging to '/DATABASE/MyData/mysql-error.log'.
170215 18:44:29 mysqld_safe Starting mysqld daemon with databases from /DATABASE/MyData
. [ OK ]
mysql -u root
use test
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
#######################################################
flush privileges;
CREATE USER 'wsrep'@'%' IDENTIFIED BY 'wsadmin';
CREATE USER 'root'@'%' IDENTIFIED BY 'dbadmin';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
flush privileges;