MySQL-5.5.25 centos 一键安装脚本 auto install

来源:互联网 发布:泰罗奥特曼act淘宝 编辑:程序博客网 时间:2024/04/29 02:27

原文链接:http://blog.csdn.net/ylqmf/article/details/8064356

工作中经常要要在不同的机器上安装mysql,特意写了个一键安装脚本。

安装包在这里http://kuai.xunlei.com/d/VWKMOOFSUWGB,直接解压,运行install.sh 就可以了。安装目录和my.com部分要根据自己的情况选择使用。

#!/bin/sh#mysql-5.5.25 auto install shell#yuanliqiang@b2c.xx.com#from http://blog.csdn.net/ylqmf/article/details/8064356serverid=135objsocket="3306"curdir=$(cd "$(dirname "$0")"; pwd)basedir="/opt/soft/mysql"logdir="/logs/mysql/log${objsocket}"datadir="/data/mysql/data${objsocket}"mycnf="/etc/my${objsocket}.cnf"yum -y install gcc gcc-c++ ncurses-devel cmake bison make numactl libaio libaio-devel perl perl-DBD-MySQL perl-DBI libtool lsof/usr/sbin/groupadd -g 1001 mysql/usr/sbin/useradd -g mysql mysql -u 1001 -s /sbin/nologincat >> /etc/sysctl.conf << EOFfs.aio-max-nr = 1048576vm.swappiness = 0net.ipv4.tcp_syncookies = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_fin_timeout = 30EOF/sbin/sysctl -pmkdir -P ${basedir}mkdir -p ${logdir}mkdir -p ${datadir}rm -rf ${mycnf}tar -zxf libunwind-1.0.1.tar.gztar -zxf gperftools-2.0.tar.gztar -zxf mysql-5.5.25a.tar.gzsource /etc/profilecd libunwind-1.0.1CXX=gcc \CHOST="x86_64-pc-linux-gnu" \CFLAGS="-O3 " \CXXFLAGS="${CFLAGS}" \./configure && make -j 4 && make installcp ./src/.libs/libunwind.so.8 /usr/lib64/echo “/usr/local/lib” > /etc/ld.so.conf.d/usr_local_lib.conf/sbin/ldconfigcd ../gperftools-2.0CHOST="x86_64-pc-linux-gnu" \CFLAGS="-O3 " \CXXFLAGS="${CFLAGS}" \./configure && make -j 4 && make installcd ../mysql-5.5.25aHOST="x86_64-pc-linux-gnu" \CFLAGS="-O3" \CXXFLAGS="${CFLAGS}" \cmake -DCMAKE_INSTALL_PREFIX=${basedir} \-DMYSQL_DATADIR=$datadir \-DMYSQL_UNIX_ADDR=/tmp/mysql${objsocket}.sock \-DMYSQL_TCP_PORT=${objsocket} \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DWITH_EMBEDDED_SERVER=0 \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DENABLED_LOCAL_INFILE=1 \-DMYSQL_USER=mysql \-DWITH_DEBUG=0 \-DWITH_SSL=yesmake -j 4make installecho 'export PATH=$PATH:'${basedir}'/bin' >> /etc/profileecho "[client]:port                            = 3306socket                          = /tmp/mysql${objsocket}.sockdefault-character-set           = utf8[mysql]default-character-set           = utf8[mysqld]character-set-server            = utf8tmpdir                          = /tmpport                            = 3306socket                          = /tmp/mysql${objsocket}.sockpid_file                        = ${logdir}/mysql${objsocket}.pidmax_connect_errors              = 999999max_connections                 = 2048max_user_connections            = 1024back_log                        = 512thread_cache_size               = 300skip-external-lockingskip-name-resolvesafe-user-createlog_bin_trust_function_creators = 1interactive_timeout             = 60wait_timeout                    = 60open_files_limit                = 65535key_buffer_size                 = 16Kmax_allowed_packet              = 16Mtable_definition_cache          = 1024table_open_cache                = 1024max_length_for_sort_data        = 8Mmax_tmp_tables                  = 1024max_heap_table_size             = 256Mtmp_table_size                  = 256Mquery_cache_size                = 32Mquery_cache_limit               = 2M#sessionjoin_buffer_size                = 16Mmax_length_for_sort_data        = 8Msort_buffer_size                = 8Mread_buffer_size                = 8Mread_rnd_buffer_size            = 8Mnet_buffer_length               = 1Mthread_stack                    = 1Minnodb_support_xa               = 0innodb_stats_on_metadata        = 0innodb_file_per_tablememlockdefault-storage-engine          = innodbinnodb_buffer_pool_size         = 2Ginnodb_additional_mem_pool_size = 512Minnodb_change_buffering         = allinnodb_data_file_path           = ibdata1:1024M:autoextendinnodb_concurrency_tickets      = 1024innodb_log_group_home_dir       = ${logdir}innodb_max_dirty_pages_pct      = 75innodb_flush_method             = O_DIRECTinnodb_log_file_size            = 512Minnodb_log_files_in_group       = 3innodb_use_sys_malloc           = 1innodb_use_native_aio           = 1innodb_purge_threads            = 1innodb_adaptive_flushing        = 1innodb_io_capacity              = 2000innodb_thread_concurrency       = 0innodb_read_io_threads          = 8innodb_write_io_threads         = 8innodb_lock_wait_timeout        = 60sync_binlog                     = 0innodb_sync_spin_loops          = 0innodb_flush_log_at_trx_commit  = 1server-id                       = ${serverid}#log-slave-updates#log-bin                        = ${logdir}/mysql-bin#relay-log                      = ${logdir}/mysql-relay-bin#binlog_format                  = mixed#max_binlog_cache_size          = 2G#expire_logs_days               = 7#max_binlog_size                = 500M#skip_slave_startgeneral-log                     = 1general_log_file                = ${logdir}/general.logslow-query-log                  = 1slow_query_log_file             = ${logdir}/slow_query.loglong_query_time         = 2log-queries-not-using-indexes   = 1log_error                       = ${logdir}/log_error.err[mysqldump]quickmax_allowed_packet              = 16M[mysqladmin]#socket                         = /tmp/mysql${objsocket}.sock[mysql]no-auto-rehash[myisamchk]key_buffer_size                 = 8Msort_buffer_size                = 8M[mysqlhotcopy]interactive-timeout"> ${mycnf}cd ${basedir}${basedir}/scripts/mysql_install_db  --defaults-file=${mycnf}  --basedir=${basedir}  --datadir=${datadir}  --user=mysqlsed '2iexport LD_PRELOAD="/usr/local/lib/libtcmalloc.so"' -i ${basedir}/bin/mysqld_safechown mysql:mysql ${basedir} -Rchown mysql:mysql ${datadir} -Rchown mysql:mysql ${logdir} -Recho "nice -n -20 ${basedir}/bin/mysqld_safe --defaults-file=${mycnf} --datadir=${datadir} --user=mysql &"source /etc/profileecho "lsof -n | grep tcmalloc"

原文链接:http://blog.csdn.net/ylqmf/article/details/8064356

原创粉丝点击