linux下一键部署mysql_linux下一键编译搭建mysql服务器脚本
===============================================
此安装程序分为两个结构,一个是安装脚本,一个是配置文件目录,其结构如下:
[root@helloween /]# tree /mysql_pro/
mysql_pro/
├── dconfig
│ ├── my.cnf
│ ├── mysql-5.1.50.tar.gz
│ └── varconfig
└── install.sh
1 directory, 4 files
[root@helloween /]#
其中:
my.cnf是编译安装之后,服务要用到的服务端配置文件
varconfig是安装时,安装脚本用到的一些变量配置文件
mysql-5.1.50.tar.gz是安装源码包
install.sh是安装时需要执行的脚本文件,执行成功后,mysql服务器即可搭建成功
===============================================
以下是各个文件的具体内容:
------------------------------------------------------------------------------------------------------
[root@helloween dconfig]# cat varconfig
#安装包名
V_name="mysql-5.1.50.tar.gz"
#解压包目录名
D_name="mysql-5.1.50"
#编译安装参数变量
Conf_arguments="'--prefix=/usr/local/mysql' '--localstatedir=/data/dbdata' '--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock' '--with-charset=utf8' '--with-extra-charsets=complex' '--with-pthread' '--enable-thread-safe-client' '--with-ssl' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive' '--enable-shared' '--enable-assembler'"
#数据文件目录变量
Data_dir=:"/data/dbdata"
#安装目录变量
Base_dir="/usr/local/mysql"
#初始化参数变量
Init_arguments="--user=mysql --basedir=${Base_dir} --datadir=${Data_dir}"
[root@helloween dconfig]#
------------------------------------------------------------------------------------------------------
[root@helloween mysql_pro]# cat install.sh
#!/bin/bash
#written by helloween
#2014-4-19
#mysql-install
#====================================
#配置文件检查函数
CheckConfig()
{
if [ -f my.cnf -a -f varconfig -a -f ${V_name} ];then
echo "OK!config_file exists,it will be continue!"
else
echo "Error!config_file not exists,it will be quit!"
exit
fi
}
Main()
{
#进入配置文件目录
[ -d ./dconfig ] && cd ./dconfig
#安装前进行变量设置
. varconfig
#检查配置文件
CheckConfig;
#安装依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel libtool* >/dev/null 2>&1
#解压安装包
tar xf $V_name >/dev/null 2>&1
#进入安装目录
cd $D_name
#开始进行编译安装
./configure $Conf_arguments && make && make install
#初始化
id mysql || useradd mysql
mkdir $Data_dir
chown -R mysql:mysql $Base_dir
chown -R mysql:mysql $Data_dir
$Base_dir/bin/mysql_install_db $Init_arguments
/bin/cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysql
sed -i "/^basedir=/d" /etc/init.d/mysql
echo "basedir=${Base_dir}" >> /etc/init.d/mysql
sed -i "/^datadir=/d" /etc/init.d/mysql
echo "datadir=${Data_dir}" >>/etc/init.d/mysql
#开机启动服务和设置环境变量
sed -i '/^MYSQL=/d' /etc/profile
echo "MYSQL=/usr/local/mysql/bin">>/etc/profile
sed -i '/^PATH=$PATH:$MYSQL/d'
echo 'PATH=$PATH:$MYSQL'>>/etc/profile
echo "export PATH">>/etc/profile
source /etc/profile
#配置文件
/bin/cp ./my.cnf /etc
#启动服务
/etc/init.d/mysqld start
}
Main;
------------------------------------------------------------------------------------------------------
[root@helloween dconfig]# cat my.cnf | grep -v "^#" | grep -v "^$"
[client]
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock
[mysqld]
datadir=/data/dbdata/
basedir = /usr/local/mysql/
skip-name-resolve
lower_case_table_names=1
innodb_file_per_table=1
expire_logs_days = 10
federated
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock
back_log = 50
max_connections = 330
max_connect_errors = 1000
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 2M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 4M
thread_cache_size = 64
thread_concurrency = 8
query_cache_size = 128M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = innodb
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
log-bin=mysql-bin
binlog_format=mixed
slow_query_log
long_query_time = 0.5
server-id = 1
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 32M
innodb_buffer_pool_size = 8G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_io_threads = 8
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 60
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 256M
[mysql]
no-auto-rehash
prompt=\\u@\\d \\R:\\m>
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
[root@helloween dconfig]#
===============================================
做完以上步骤即可使用mysql服务了。
以上为个人见解,错误之处敬请指正。
指导老师:双星科技曾勇老师
linux下一键部署mysql_linux下一键编译搭建mysql服务器脚本相关推荐
- daemon.json无法启动docker_devops一键部署|详解如何搭建git+maven+jenkins+docker
流程及原理 流程梳理: 微服务一键部署实现后只需要将测试好的代码提交至版本管理工具(如:git.SVN),程序会自动实现更新代码并打包发布等后面的流程,省心省力. 实现过程 前置环境: 默认已经装好J ...
- mysql服务器搭建方法_windows下搭建MySQL服务器步骤详解
Mysql是一个数据库系统,它包括数据库服务器,并且有一个数据库管理系统对数据库服务器进行管理,同时还包括有一个数据库客户端,用于与用户交互. 从官方网站下载Mysql数据库系统的安装包程序,http ...
- Linux搭建mysql服务器
该文章由作者精心整理与总结,详细记录了对问题的思考与解决过程,原创文章,转载请在文章明显位置注明出处与原文链接!大家一起成长!!! 一.环境准备 (1)下载Linux版本的mysql服务器,这里根据自 ...
- 在linux挂载网络驱动器,利用centos 6.6 搭建iscsi服务器并在centos挂载iscsi网络驱动器...
################################################################## 搭建iscsi服务器: 参考自:http://www.linuxi ...
- linux下php支持mysql_linux下php扩展mysqli的支持 .
mysqli是优化后的mysql,具体的优点baidu下就ok了 cd php-5.2.8 在这下面有个ext文件夹里有mysqli cd ext/mysqli linux下将源码文件编译应该都有 ...
- linux上离线安装mysql_Linux下安装mysql(离线安装和在线安装)
一:在线安装mysql 1.首先检测一下,mysql之前有没有被安装 命令:rpm -qa | grep mysql 2.删除mysql的命令: rpm -e --nodeps `rpm -qa | ...
- linux上oracle导入mysql_linux下的oracle数据库和表空间的导入导出
由于oracle是安装在linux上面,因此需要oracle的导入导出都是使用命令进行操作.oracle允许整个数据库导入导出和表空间的导入导出. 数据库导入导出 以下操作是在操作系统控制台命令中执行 ...
- linux上oracle导入mysql_Linux 下 oracle 导入数据库—数据泵方式导入dmp文件
dmp导出数据源的oracle版本是12c,我本地oracle版本是11g,这在导入数据过程中导致出现错误 一.用system 用户登录oracle,我忘记了system密码,解决办法: [oracl ...
- 如何在linux下yum安装mysql_linux下使用yum安装mysql详解
1.安装客户端和服务器端 确认mysql是否已安装: yum list installed mysql* rpm -qa | grep mysql*查看是否有安装包: yum list mysql*安 ...
最新文章
- 深度分析蔡徐坤的百万流量数据,揭底哪些是假的!
- 【400】numpy.pad 为数组加垫(迷宫类题目)
- js倒计时代码最简单的_32个史上最有用的js代码
- C#中自定义属性的例子
- 让vs中网站的sln文件使用相对路径的办法
- python cursor游标重置位置scroll_MySQL的游标
- MongoDB副本集学习(一):概述和环境搭建
- shell 学习笔记整理(一)
- google浏览器呗7654流氓解除
- 二维码的制作之根据Excel数据批量制作二维码
- python 实现Web版股票行情界面
- 新疆上半年工业品价格总水平创十七年新低
- PaddleX---dEEPlABv3+语义分割
- hadoopsnappy解压_配置Hadoop2.7.2和Hbase1.1.5支持Snappy解压压缩库
- html单元格上下拆分代码,在HTML / CSS中如何垂直拆分表格单元格(特殊版本)
- java集合(容器)
- 龙之气息服务器维护,【龙之气息:从入坑到肝硬化】
- 年轻的优秀博士:网络牛人刘云浩,王新兵,朱其立
- 当BIM遇见建筑,设计灵感无限,欣赏有趣的BIM建筑
- Linux防火墙白名单限制