CentOS_6.7脚本静默安装MySQL5.6
来源:互联网 发布:js 读取ios沙盒文件 编辑:程序博客网 时间:2024/06/06 20:52
对shell不是很熟悉, 断断续续的写了一个晚上,终于搞定
使用方式,root用户解压到某个目录下, 执行 ./autoinstall_mysql_5.6.sh 即可, 后面如果不加参数, 则默认安装3306端口的实例,可以加端口参数改变默认端口。
比如 ./autoinstall_mysql_5.6.sh 3307
脚本会添加环境变量 $MYSQL_HOME指向二进制可执行程序的目录
脚本会同时在home下新建3个sh,分别用于启动mysql,停止mysql和本机OS免登mysql
机器需要安装yum和wget,perl,用于下载二进制可执行文件。
yum install -y wget
yum install -y perl
yum install -y libaio
如果是要装mysql5.7的话,可能需要调整一下脚本, 修改里面的安装文件名,还有5.7的scripts目录已经迁移到了bin目录,需要做一些调整。
不过目前看5.6还是主流。
脚本默认会在/mysql/server下建立二进制执行文件
在/mysql/下建立实例数据/日志文件
主要的脚本内容如下
autoinstall_mysql_5.6.sh
#portport=3306if [ $# -gt 0 ]; thenport=$1fiecho 'install mysql service on port:'${port}yum install -y wgetyum install -y perlyum install -y libaio#constbasedir=/mysql/serverinstance_name=my${port}instance_home=/mysql/${instance_name}file_name=mysql-5.6.35-linux-glibc2.5-x86_64.tar.gzdownload_mysql_url=https://dev.mysql.com/get/Downloads/MySQL-5.6/${file_name}# create user and groupnum=`cat /etc/group | grep mysql | wc -l`if [ $num -eq 0 ]; thengroupadd mysqlfinum=`cat /etc/passwd | grep mysql | wc -l`if [ $num -eq 0 ]; thenuseradd -r -g mysql -s /bin/false mysqlfifunction create_instance_home(){mkdir -p ${instance_home}/log/{binlog,iblog}mkdir -p ${instance_home}/datamkdir -p ${instance_home}/tmpchown -R mysql:mysql ${instance_home}}#envif [ ! $MYSQL_HOME ]; thenecho 'export MYSQL_HOME='${basedir} >> ~/.bash_profileecho 'export PATH=$PATH:$MYSQL_HOME/bin' >> ~/.bash_profileecho 'please exec "source ~/.bash_profile" command first, then re-exec this install-shell'exit 0fi# create serverif [ ! -f ${basedir}/bin/mysql ]; thenmkdir -p ${basedir}if [ ! -f ${file_name} ]; thenwget ${download_mysql_url}fitempdir=`mktemp -d`tar xf ${file_name} --strip-components 1 -C ${tempdir}mv ${tempdir}/* ${basedir} && rm -rf ${tempdir}fi# recreateif [ -d ${instance_home} ]; thenecho "instance_home ${instance_home} exists, remove it ? Y/N"read choosecase ${choose} inY | y)rm -rf ${instance_home} ;;*)exit 0esacfi# create instancecreate_instance_home# sed shell and configrm -f ~/start_${instance_name}.shsed -e 's:${instance_home}:'${instance_home}':g' start_mysql.sh > ~/start_${instance_name}.shchmod +x ~/start_${instance_name}.shrm -f ~/stop_${instance_name}.shsed -e 's:${instance_home}:'${instance_home}':g' stop_mysql.sh > ~/stop_${instance_name}.shchmod +x ~/stop_${instance_name}.shrm -f ~/login_${instance_name}.shsed -e 's:${instance_home}:'${instance_home}':g' login_mysql.sh > ~/login_${instance_name}.shchmod +x ~/login_${instance_name}.shsed -e 's:${basedir}:'${basedir}':g' -e 's:${port}:'${port}':g' -e 's:${instance_home}:'${instance_home}':g' my.cnf > ${instance_home}/my.cnfchown mysql:mysql ${instance_home}/my.cnfcd ${MYSQL_HOME}./scripts/mysql_install_db --defaults-file=${instance_home}/my.cnf --user=mysql
my.cnf
[client]port=${port}socket=${instance_home}/mysql.sock[mysql]pid_file=${instance_home}/mysql.pid[mysqld]autocommit=1general_log=onexplicit_defaults_for_timestamp=true# systembasedir=${basedir}datadir=${instance_home}/datamax_allowed_packet=1gmax_connections=3000max_user_connections=2800open_files_limit=65535pid_file=${instance_home}/mysql.pidport=${port}server_id=10${port}skip_name_resolve=ONsocket=${instance_home}/mysql.socktmpdir=${instance_home}/tmp#binloglog_bin=${instance_home}/log/binlog/log-binbinlog_cache_size=32768binlog_format=rowexpire_logs_days=7log_slave_updates=ONmax_binlog_cache_size=2147483648max_binlog_size=524288000sync_binlog=100#logginglog_error=${instance_home}/log/error.logslow_query_log_file=${instance_home}/log/slow.loglog_queries_not_using_indexes=0slow_query_log=1log_slave_updates=ONlog_slow_admin_statements=1long_query_time=1#relayrelay_log=${instance_home}/log/relaylogrelay_log_index=${instance_home}/log/relay.indexrelay_log_info_file=${instance_home}/log/relay-log.info#slaveslave_load_tmpdir=${instance_home}/tmpslave_skip_errors=OFF#innodbinnodb_data_home_dir=${instance_home}/log/ibloginnodb_log_group_home_dir=${instance_home}/log/ibloginnodb_adaptive_flushing=ONinnodb_adaptive_hash_index=ONinnodb_autoinc_lock_mode=1innodb_buffer_pool_instances=8#defaultinnodb_change_buffering=insertsinnodb_checksums=ONinnodb_buffer_pool_size= 128Minnodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextendinnodb_doublewrite=ONinnodb_file_format=Barracudainnodb_file_per_table=ONinnodb_flush_log_at_trx_commit=1innodb_flush_method=O_DIRECTinnodb_io_capacity=1000innodb_lock_wait_timeout=10innodb_log_buffer_size=67108864innodb_log_file_size=1048576000innodb_log_files_in_group=4innodb_max_dirty_pages_pct=60innodb_open_files=60000innodb_purge_threads=1innodb_read_io_threads=4innodb_stats_on_metadata=OFFinnodb_support_xa=ONinnodb_use_native_aio=OFFinnodb_write_io_threads=10[mysqld_safe]datadir=${instance_home}/data
login_mysql.sh
cd $MYSQL_HOME./bin/mysql -S ${instance_home}/mysql.sock
start_mysql.sh
cd $MYSQL_HOME./bin/mysqld_safe --defaults-file=${instance_home}/my.cnf --user=mysql &
stop_mysql.sh
cd $MYSQL_HOME./bin/mysqladmin -S ${instance_home}/mysql.sock shutdown
共5个文件。
也可以通过百度云盘下载:
http://pan.baidu.com/s/1jIJVaKI
end
0 0
- CentOS_6.7脚本静默安装MySQL5.6
- MySQL5.6安装脚本
- CentOS_6.7上使用源码安装MySQL
- CentOS_6.7上使用二进制安装MySQL
- MySQL5.6一键编译安装脚本
- 安装centos_6.3_JDK
- CentOS_6安装Oracle_11g_R2手记
- CentOS_6.5安装GitLab_7
- CentOS_6.5安装Nginx
- win7命令行静默安装SQLServer2008R2脚本
- oracle静默傻瓜式安装脚本
- bat脚本批量静默安装程序
- MYSQL5.5.19源码安装脚本
- centos7安装mysql5.7脚本并配置开机启动
- centos6.7 安装 mysql5.6
- centOS6.6 安装 MySQL5.7
- Centos6.6 安装mysql5.7
- centos 7 安装mysql5.6
- JQueryEasyUI 组件 布局 portal组件
- 基本概念
- java.unit工具类的使用(Arrays类进行排序,查找;Random生成随机数)
- 数据结构—图II
- Leetcode Binary Watch
- CentOS_6.7脚本静默安装MySQL5.6
- Vi语法总结
- JQueryEasyUI 组件 datagrid组件(数据表格组件)
- 数据结构 — 查找I
- 485. Max Consecutive Ones
- SPOJ 纽约大学ACM第一题TEST
- Android应用主界面Tab切换框架详解之Fragment
- 数据结构 — 查找II
- 数据结构 — 查找II