Kaynağa Gözat

Install MySQL from Generic Binaries

lj2007331 9 yıl önce
ebeveyn
işleme
90a78da379
9 değiştirilmiş dosya ile 82 ekleme ve 101 silme
  1. 3 3
      apps.conf
  2. 12 0
      include/check_port.py
  3. 1 1
      include/download.sh
  4. 14 23
      include/mysql-5.6.sh
  5. 16 37
      include/mysql-5.7.sh
  6. 1 0
      include/tomcat-7.sh
  7. 1 0
      include/tomcat-8.sh
  8. 33 36
      include/upgrade_db.sh
  9. 1 1
      vhost.sh

+ 3 - 3
apps.conf

@@ -19,7 +19,7 @@ mysql_5_6_version=5.6.30
 mysql_5_5_version=5.5.49
 
 mariadb_10_1_version=10.1.13
-mariadb_10_0_version=10.0.24
+mariadb_10_0_version=10.0.25
 mariadb_5_5_version=5.5.49
 
 percona_5_7_version=5.7.11-4
@@ -41,8 +41,8 @@ php_7_version=7.0.6
 zendopcache_version=7.0.5
 xcache_version=3.2.0
 apcu_version=4.0.10
-ImageMagick_version=6.8.8-10
-imagick_version=3.3.0
+ImageMagick_version=6.9.3-10
+imagick_version=3.3.1
 GraphicsMagick_version=1.3.23
 gmagick_version=1.1.7RC3
 libiconv_version=1.14

+ 12 - 0
include/check_port.py

@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+import sys,os,socket
+def IsOpen(ip,port):
+    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    try:
+        s.connect((ip,int(port)))
+        s.shutdown(2)
+        print True 
+    except:
+        print False
+if __name__ == '__main__':
+    IsOpen(sys.argv[1],int(sys.argv[2]))

+ 1 - 1
include/download.sh

@@ -9,7 +9,7 @@
 #       https://github.com/lj2007331/oneinstack
 
 Download_src() {
-    [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || wget -c --no-check-certificate $src_url
+    [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget -c --no-check-certificate $src_url; sleep 1; }
     if [ ! -e "${src_url##*/}" ];then
         echo "${CFAILURE}${src_url##*/} download failed, Please contact the author! ${CEND}"
         kill -9 $$

+ 14 - 23
include/mysql-5.6.sh

@@ -10,37 +10,28 @@
 
 Install_MySQL-5-6() {
 cd $oneinstack_dir/src
-src_url=http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-$mysql_5_6_version.tar.gz && Download_src
+
+if [ "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
+    DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6
+else
+    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
+fi
+
+src_url=$DOWN_ADDR_MYSQL/mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz && Download_src
 
 id -u mysql >/dev/null 2>&1
 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
 
+[ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
 mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
-tar zxf mysql-$mysql_5_6_version.tar.gz
-cd mysql-$mysql_5_6_version
+
+tar zxf mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
+mv mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}/* $mysql_install_dir
 if [ "$je_tc_malloc" == '1' ];then
-    EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
+    sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe
 elif [ "$je_tc_malloc" == '2' ];then
-    EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
+    sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mysql_install_dir/bin/mysqld_safe
 fi
-make clean
-[ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir 
-cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
--DMYSQL_DATADIR=$mysql_data_dir \
--DSYSCONFDIR=/etc \
--DWITH_INNOBASE_STORAGE_ENGINE=1 \
--DWITH_PARTITION_STORAGE_ENGINE=1 \
--DWITH_FEDERATED_STORAGE_ENGINE=1 \
--DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
--DWITH_MYISAM_STORAGE_ENGINE=1 \
--DENABLED_LOCAL_INFILE=1 \
--DENABLE_DTRACE=0 \
--DDEFAULT_CHARSET=utf8mb4 \
--DDEFAULT_COLLATION=utf8mb4_general_ci \
--DWITH_EMBEDDED_SERVER=1 \
-$EXE_LINKER
-make -j `grep processor /proc/cpuinfo | wc -l` 
-make install
 
 if [ -d "$mysql_install_dir/support-files" ];then
     echo "${CSUCCESS}MySQL install successfully! ${CEND}"

+ 16 - 37
include/mysql-5.7.sh

@@ -11,50 +11,27 @@
 Install_MySQL-5-7() {
 cd $oneinstack_dir/src
 
-[ "$IPADDR_STATE"x == "CN"x ] && { DOWN_ADDR_MYSQL=http://mirrors.linuxeye.com/oneinstack/src; DOWN_ADDR_BOOST=$DOWN_ADDR_MYSQL; } || { DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7; DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/1.59.0; }
-
-if [ ! -e "/usr/local/lib/libboost_system.so" ];then
-    src_url=$DOWN_ADDR_BOOST/boost_1_59_0.tar.gz && Download_src
-    tar xzf boost_1_59_0.tar.gz
-    cd boost_1_59_0
-    ./bootstrap.sh
-    ./bjam --prefix=/usr/local
-    ./b2 install
-    cd ..
+if [ "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
+    DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7
+else
+    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.7 || DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
 fi
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
 
-if [ "$je_tc_malloc" == '1' ];then
-    EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-elif [ "$je_tc_malloc" == '2' ];then
-    EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
-fi
+src_url=$DOWN_ADDR_MYSQL/mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz && Download_src
 
-src_url=$DOWN_ADDR_MYSQL/mysql-$mysql_5_7_version.tar.gz && Download_src
 id -u mysql >/dev/null 2>&1
 [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
+
 [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir 
 mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
-tar zxf mysql-$mysql_5_7_version.tar.gz
-cd mysql-$mysql_5_7_version
-make clean
-cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
--DMYSQL_DATADIR=$mysql_data_dir \
--DSYSCONFDIR=/etc \
--DWITH_INNOBASE_STORAGE_ENGINE=1 \
--DWITH_PARTITION_STORAGE_ENGINE=1 \
--DWITH_FEDERATED_STORAGE_ENGINE=1 \
--DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
--DWITH_MYISAM_STORAGE_ENGINE=1 \
--DENABLED_LOCAL_INFILE=1 \
--DENABLE_DTRACE=0 \
--DDEFAULT_CHARSET=utf8mb4 \
--DDEFAULT_COLLATION=utf8mb4_general_ci \
--DWITH_EMBEDDED_SERVER=1 \
-$EXE_LINKER
-make -j `grep processor /proc/cpuinfo | wc -l` 
-make install
+
+tar zxf mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz 
+mv mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}/* $mysql_install_dir
+if [ "$je_tc_malloc" == '1' ];then
+    sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe
+elif [ "$je_tc_malloc" == '2' ];then
+    sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mysql_install_dir/bin/mysqld_safe
+fi
 
 if [ -d "$mysql_install_dir/support-files" ];then
     echo "${CSUCCESS}MySQL install successfully! ${CEND}"
@@ -67,6 +44,8 @@ else
 fi
 
 /bin/cp $mysql_install_dir/support-files/mysql.server /etc/init.d/mysqld
+sed -i "s@^basedir=.*@basedir=$mysql_install_dir@" /etc/init.d/mysqld
+sed -i "s@^datadir=.*@datadir=$mysql_data_dir@" /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
 [ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
 [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults

+ 1 - 0
include/tomcat-7.sh

@@ -21,6 +21,7 @@ id -u $run_user >/dev/null 2>&1
 tar xzf apache-tomcat-$tomcat_7_version.tar.gz
 [ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
 /bin/cp -R apache-tomcat-$tomcat_7_version/* $tomcat_install_dir
+rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
 
 if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib

+ 1 - 0
include/tomcat-8.sh

@@ -21,6 +21,7 @@ id -u $run_user >/dev/null 2>&1
 tar xzf apache-tomcat-$tomcat_8_version.tar.gz
 [ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
 /bin/cp -R apache-tomcat-$tomcat_8_version/* $tomcat_install_dir
+rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
 
 if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib

+ 33 - 36
include/upgrade_db.sh

@@ -24,6 +24,7 @@ elif [ -n "$DB_tmp" -a "$DB_tmp" != 'MariaDB' ];then
     DB=Percona
     OLD_DB_version=$OLD_DB_version_tmp
 else
+    [ "$IPADDR_STATE"x == "CN"x ] && DOWN_ADDR=http://mirrors.sohu.com/mysql || DOWN_ADDR=http://cdn.mysql.com/Downloads
     DB=MySQL
     OLD_DB_version=$OLD_DB_version_tmp
 fi
@@ -58,6 +59,7 @@ echo
 echo "Current $DB Version: ${CMSG}$OLD_DB_version${CEND}"
 [ -e /usr/local/lib/libjemalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
 [ -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=2; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"; }
+[ -e /usr/local/lib/libjemalloc.so -a -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
 
 while :
 do
@@ -71,8 +73,8 @@ do
             DB_name=percona-server-$NEW_DB_version
             DB_URL=http://www.percona.com/redir/downloads/Percona-Server-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/LATEST/source/tarball/$DB_name.tar.gz
         elif [ "$DB" == 'MySQL' ];then
-            DB_name=mysql-$NEW_DB_version
-            DB_URL=http://cdn.mysql.com/Downloads/MySQL-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/$DB_name.tar.gz
+            [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` != '5.5' ] && DB_name=mysql-${NEW_DB_version}-linux-glibc2.5-${SYS_BIT_b} || DB_name=mysql-$NEW_DB_version
+            DB_URL=$DOWN_ADDR/MySQL-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/$DB_name.tar.gz
         fi
             [ ! -e "$DB_name.tar.gz" ] && wget --no-check-certificate -c $DB_URL > /dev/null 2>&1
             
@@ -93,8 +95,8 @@ if [ -e "$DB_name.tar.gz" ];then
     char=`get_char`
     if [ "$DB" == 'MariaDB' ];then 
         service mysqld stop
-        mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d"`}
-        mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d"`}
+        mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+        mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
         mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir
         tar xzf $DB_name.tar.gz
         [ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir
@@ -150,8 +152,8 @@ $EXE_LINKER
         fi
         make -j `grep processor /proc/cpuinfo | wc -l`
         service mysqld stop
-        mv ${percona_install_dir}{,_old_`date +"%Y%m%d"`}
-        mv ${percona_data_dir}{,_old_`date +"%Y%m%d"`}
+        mv ${percona_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+        mv ${percona_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
         [ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir
         mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir
         make install
@@ -169,10 +171,10 @@ $EXE_LINKER
         $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
         [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
     elif [ "$DB" == 'MySQL' ];then
-        tar zxf $DB_name.tar.gz
-        cd $DB_name
-        make clean
         if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.5' ];then
+            tar zxf $DB_name.tar.gz
+            cd $DB_name
+            make clean
             cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
 -DMYSQL_DATADIR=$mysql_data_dir \
 -DSYSCONFDIR=/etc \
@@ -189,35 +191,30 @@ $EXE_LINKER
 -DDEFAULT_COLLATION=utf8mb4_general_ci \
 -DWITH_EMBEDDED_SERVER=1 \
 $EXE_LINKER
-        else
-            cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
--DMYSQL_DATADIR=$mysql_data_dir \
--DSYSCONFDIR=/etc \
--DWITH_INNOBASE_STORAGE_ENGINE=1 \
--DWITH_PARTITION_STORAGE_ENGINE=1 \
--DWITH_FEDERATED_STORAGE_ENGINE=1 \
--DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
--DWITH_MYISAM_STORAGE_ENGINE=1 \
--DENABLED_LOCAL_INFILE=1 \
--DENABLE_DTRACE=0 \
--DDEFAULT_CHARSET=utf8mb4 \
--DDEFAULT_COLLATION=utf8mb4_general_ci \
--DWITH_EMBEDDED_SERVER=1 \
-$EXE_LINKER
-        fi
-        make -j `grep processor /proc/cpuinfo | wc -l`
-        service mysqld stop
-        mv ${mysql_install_dir}{,_old_`date +"%Y%m%d"`}
-        mv ${mysql_data_dir}{,_old_`date +"%Y%m%d"`}
-        [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
-        mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
-        make install
-        cd ..
-        if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ];then
-            $mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
-        else
+
+            make -j `grep processor /proc/cpuinfo | wc -l`
+            service mysqld stop
+            mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+            mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+            [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
+            mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+            make install
+            cd ..
             $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+        else
+            tar zxf $DB_name.tar.gz
+            service mysqld stop
+            mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+            mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+            [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
+            mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+            mv $DB_name/* $mysql_install_dir/
+            [ "$je_tc_malloc" == '1' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe
+            [ "$je_tc_malloc" == '2' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mysql_install_dir/bin/mysqld_safe
+            [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.6' ] && $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+            [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ] && $mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
         fi
+
         chown mysql.mysql -R $mysql_data_dir
         [ -e "$mysql_install_dir/my.cnf" ] && rm -rf $mysql_install_dir/my.cnf
         service mysqld start

+ 1 - 1
vhost.sh

@@ -256,7 +256,7 @@ if [ "$moredomainame_yn" == 'y' ]; then
             fi
         done
         [ "$nginx_ssl_yn" == 'y' ] && HTTP_flag=https || HTTP_flag=http 
-        [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n\trewrite ^/(.*)\$ \$scheme://$domain/\$1 permanent;\n\t}")
+        [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n    rewrite ^/(.*)\$ \$scheme://$domain/\$1 permanent;\n    }")
     fi
 fi