Browse Source

Add MySQL-5.7.sh

lj2007331 9 years ago
parent
commit
060d5bde6c
6 changed files with 244 additions and 38 deletions
  1. 1 1
      README.md
  2. 4 3
      apps.conf
  3. 5 3
      config/thinkphp.conf
  4. 3 3
      include/init_CentOS.sh
  5. 212 0
      include/mysql-5.7.sh
  6. 19 28
      install.sh

+ 1 - 1
README.md

@@ -4,7 +4,7 @@ Script properties:
 - Continually updated
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - Some security optimization
-- Providing a plurality of database versions (MySQL-5.6, MySQL-5.5, MariaDB-10.0, MariaDB-5.5, Percona-5.6, Percona-5.5)
+- Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.0, MariaDB-5.5, Percona-5.6, Percona-5.5)
 - Providing multiple PHP versions (php-5.3, php-5.4, php-5.5, php-5.6, php-7/phpng(RC))
 - Provide Nginx, Tengine
 - Providing a plurality of Tomcat version (Tomcat-8, Tomcat-7)

+ 4 - 3
apps.conf

@@ -3,7 +3,7 @@
 nginx_version=1.9.5
 tengine_version=2.1.1
 
-tomcat_7_version=7.0.64
+tomcat_7_version=7.0.65
 tomcat_8_version=8.0.28
 
 apache_2_version=2.2.31
@@ -13,6 +13,7 @@ apr_version=1.5.2
 apr_util_version=1.5.4
 
 # DB
+mysql_7_version=5.7.9
 mysql_6_version=5.6.27
 mysql_5_version=5.5.46
 
@@ -60,10 +61,10 @@ memcached_pecl_version=2.2.0
 memcache_pecl_version=2.2.7
 
 # phpMyadmin
-phpMyAdmin_version=4.4.15
+phpMyAdmin_version=4.4.15.1
 
 # jemalloc
-jemalloc_version=4.0.3
+jemalloc_version=4.0.4
 
 # tcmalloc
 tcmalloc_version=2.4

+ 5 - 3
config/thinkphp.conf

@@ -1,4 +1,6 @@
-if (!-e $request_filename) {
-    rewrite ^/(.*)$ /index.php/$1;
-    #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
+location / {
+    if (!-e $request_filename) {
+        rewrite ^/(.*)$ /index.php/$1;
+        #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
+    }
 }

+ 3 - 3
include/init_CentOS.sh

@@ -170,15 +170,15 @@ service sshd restart
 if [ ! -e "`which tmux`" ];then
     cd src
     src_url=http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz && Download_src 
-    src_url=http://downloads.sourceforge.net/project/tmux/tmux/tmux-2.0/tmux-2.0.tar.gz && Download_src 
+    src_url=http://mirrors.linuxeye.com/oneinstack/src/tmux-2.1.tar.gz && Download_src 
     tar xzf libevent-2.0.22-stable.tar.gz
     cd libevent-2.0.22-stable
     ./configure
     make && make install
     cd ..
 
-    tar xzf tmux-2.0.tar.gz
-    cd tmux-2.0
+    tar xzf tmux-2.1.tar.gz
+    cd tmux-2.1
     CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
     make && make install
     cd ../../

+ 212 - 0
include/mysql-5.7.sh

@@ -0,0 +1,212 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_MySQL-5-7()
+{
+cd $oneinstack_dir/src
+
+[ "$IPADDR_STATE"x == "CN"x ] && { DOWN_ADDR_MYSQL=http://linuxeye.file.alimmdn.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; }
+
+src_url=$DOWN_ADDR_BOOST/boost_1_59_0.tar.gz && Download_src
+src_url=$DOWN_ADDR_MYSQL/mysql-$mysql_7_version.tar.gz && Download_src
+
+id -u mysql >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
+
+mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+tar xzf boost_1_59_0.tar.gz
+tar zxf mysql-$mysql_7_version.tar.gz
+cd mysql-$mysql_7_version
+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
+make clean
+[ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir 
+cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \
+-DMYSQL_DATADIR=$mysql_data_dir \
+-DDOWNLOAD_BOOST=1 \
+-DWITH_BOOST=../boost_1_59_0 \
+-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}"
+    cd ..
+    rm -rf mysql-$mysql_7_version
+else
+    rm -rf $mysql_install_dir
+    echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+fi
+
+/bin/cp $mysql_install_dir/support-files/mysql.server /etc/init.d/mysqld
+chmod +x /etc/init.d/mysqld
+OS_CentOS='chkconfig --add mysqld \n
+chkconfig mysqld on'
+OS_Debian_Ubuntu='update-rc.d mysqld defaults'
+OS_command
+cd ..
+
+# my.cf
+[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
+cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+default-character-set = utf8mb4
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+
+basedir = $mysql_install_dir 
+datadir = $mysql_data_dir
+pid-file = $mysql_data_dir/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+init-connect = 'SET NAMES utf8mb4'
+character-set-server = utf8mb4
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128 
+max_allowed_packet = 4M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+query_cache_type = 1
+query_cache_size = 8M
+query_cache_limit = 2M
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+expire_logs_days = 30
+
+log_error = $mysql_data_dir/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = $mysql_data_dir/mysql-slow.log
+
+performance_schema = 0
+explicit_defaults_for_timestamp
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+myisam_repair_threads = 1
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 16M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+if [ $Mem -gt 1500 -a $Mem -le 2500 ];then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+    sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+elif [ $Mem -gt 2500 -a $Mem -le 3500 ];then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+    sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+elif [ $Mem -gt 3500 ];then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+    sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+fi
+
+$mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+
+chown mysql.mysql -R $mysql_data_dir
+service mysqld start
+[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$mysql_install_dir/bin:\$PATH" >> /etc/profile 
+[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $mysql_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$mysql_install_dir/bin:\1@" /etc/profile
+. /etc/profile
+
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;"
+$mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$mysql_install_dir/lib" > /etc/ld.so.conf.d/mysql.conf 
+ldconfig
+service mysqld stop
+}

+ 19 - 28
install.sh

@@ -39,19 +39,6 @@ PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
 
 mkdir -p $wwwroot_dir/default $wwwlogs_dir
 
-# choice upgrade OS
-#while :
-#do
-#    echo
-#    read -p "Do you want to upgrade operating system? [y/n]: " upgrade_yn
-#    if [ "$upgrade_yn" != 'y' -a "$upgrade_yn" != 'n' ];then
-#        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-#    else
-#        #[ "$upgrade_status" == '0' ] && { echo "${CWARNING}Your system is already upgraded! ${CEND}" ; upgrade_yn=Other ; }
-#        break
-#    fi
-#done
-
 # Use default SSH port 22. If you use another SSH port on your server
 if [ -e "/etc/ssh/sshd_config" ];then
     [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
@@ -187,16 +174,17 @@ do
             do
                 echo
                 echo 'Please select a version of the Database:'
-                echo -e "\t${CMSG}1${CEND}. Install MySQL-5.6"
-                echo -e "\t${CMSG}2${CEND}. Install MySQL-5.5"
-                echo -e "\t${CMSG}3${CEND}. Install MariaDB-10.0"
-                echo -e "\t${CMSG}4${CEND}. Install MariaDB-5.5"
-                echo -e "\t${CMSG}5${CEND}. Install Percona-5.6"
-                echo -e "\t${CMSG}6${CEND}. Install Percona-5.5"
-                read -p "Please input a number:(Default 1 press Enter) " DB_version
-                [ -z "$DB_version" ] && DB_version=1
-                if [ $DB_version != 1 -a $DB_version != 2 -a $DB_version != 3 -a $DB_version != 4 -a $DB_version != 5 -a $DB_version != 6 ];then
-                    echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6 ${CEND}"
+                echo -e "\t${CMSG}1${CEND}. Install MySQL-5.7"
+                echo -e "\t${CMSG}2${CEND}. Install MySQL-5.6"
+                echo -e "\t${CMSG}3${CEND}. Install MySQL-5.5"
+                echo -e "\t${CMSG}4${CEND}. Install MariaDB-10.0"
+                echo -e "\t${CMSG}5${CEND}. Install MariaDB-5.5"
+                echo -e "\t${CMSG}6${CEND}. Install Percona-5.6"
+                echo -e "\t${CMSG}7${CEND}. Install Percona-5.5"
+                read -p "Please input a number:(Default 2 press Enter) " DB_version
+                [ -z "$DB_version" ] && DB_version=2
+                if [ $DB_version != 1 -a $DB_version != 2 -a $DB_version != 3 -a $DB_version != 4 -a $DB_version != 5 -a $DB_version != 6 -a $DB_version != 7 ];then
+                    echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6,7${CEND}"
                 else
                     while :
                     do
@@ -523,21 +511,24 @@ fi
 
 # Database
 if [ "$DB_version" == '1' ];then
+    . include/mysql-5.7.sh 
+    Install_MySQL-5-7 2>&1 | tee -a $oneinstack_dir/install.log 
+elif [ "$DB_version" == '2' ];then
     . include/mysql-5.6.sh 
     Install_MySQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log 
-elif [ "$DB_version" == '2' ];then
+elif [ "$DB_version" == '3' ];then
     . include/mysql-5.5.sh
     Install_MySQL-5-5 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '3' ];then
+elif [ "$DB_version" == '4' ];then
     . include/mariadb-10.0.sh
     Install_MariaDB-10-0 2>&1 | tee -a $oneinstack_dir/install.log 
-elif [ "$DB_version" == '4' ];then
+elif [ "$DB_version" == '5' ];then
     . include/mariadb-5.5.sh
     Install_MariaDB-5-5 2>&1 | tee -a $oneinstack_dir/install.log 
-elif [ "$DB_version" == '5' ];then
+elif [ "$DB_version" == '6' ];then
     . include/percona-5.6.sh
     Install_Percona-5-6 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '6' ];then
+elif [ "$DB_version" == '7' ];then
     . include/percona-5.5.sh 
     Install_Percona-5-5 2>&1 | tee -a $oneinstack_dir/install.log 
 fi