SHELL脚本之自动化安装通用二进制格式MariaDB
2015-02-11 09:19
337 查看
#!/bin/bash datadir="/mydata/data" sqlconf=/etc/mysql installdir=/usr/local/mysql # 关于安装包大家可以去官网下载,注意下载通用二进制格式的 ,然后放在ftp服务器上即可 # 此处假设我把mariadb5.5的安装包放在了ftp上的/pub/Sources/6.x86_64/mariadb下面 case $1 in 36) package=mariadb-5.5.36-linux-x86_64.tar.gz dir=mariadb-5.5.36-linux-x86_64 wget lftp 172.16.0.1:/pub/Sources/6.x86_64/mariadb/$package ;; 40) package=mariadb-5.5.40-linux-x86_64.tar.gz dir=mariadb-5.5.40-linux-x86_64 wget lftp 172.16.0.1:/pub/Sources/6.x86_64/mariadb/$package ;; *) echo "Usage /bin/bash `basename $0` 36|40" exit 1 esac #echo 'get mariadb-5.5.36-linux-x86_64.tar.gz #bye ' | lftp 172.16.0.1:/pub/Sources/6.x86_64/mariadb tar xf ${package} -C /usr/local cd /usr/local # 为其创建链接mysql方便以后管理 ln -s ${dir} mysql cd ${installdir} #创建mysql系统用户 if ! id mysql &> /dev/null; then useradd -r mysql fi # 创建数据文件目录 if [ ! -d ${datadir} ]; then mkdir -pv ${datadir} &> /dev/null chown -R mysql:mysql ${datadir} fi # 初始化mariadb cd ${installdir} scripts/mysql_install_db --user=mysql --datadir=/mydata/data &> /dev/null # 为mariadb添加配置文件 if [ ! -d ${sqlconf} ]; then mkdir -p /etc/mysql &> /dev/null fi cd ${installdir} cp support-files/my-large.cnf /etc/mysql/my.cnf sed -i '/^thread_ca/a \datadir = /mydata/data \ninnodb_file_per_table = on \nskip_name_resolve = on' /etc/mysql/my.cnf # 为mariadb添加服务脚本 cp ${installdir}/support-files/mysql.server /etc/rc.d/init.d/mysqld chkconfig --add mysqld # 添加mariadb命令至PATH环境变量 echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh . /etc/profile.d/mysql.sh # 添加man手册 sed -i '/^MAN.*\/usr\/man/a MANPATH /usr/local/mysql/man/' /etc/man.config echo 'The mariadb has installed successfully' echo 'Please exect ". /etc/profile.d/mysql.sh" to update PATH'
相关文章推荐
- 用shell脚本实现通用二进制格式mysql 5.5.28 x86_64的安装
- 用SHELL脚本自动化安装Nagios服务器端和客户端的
- 通过shell脚本实现自动化安装LINUX
- apache服务自动化安装_shell脚本
- CentOS 7以通用二进制格式安装mariadb
- portalAgent自动化安装以及shell脚本小结
- 使用shell脚本自动化安装Nagios服务器端和客户端
- shell脚本和ansible实践MariaDB源码编译自动安装
- mysql最新通用二进制分发版本5.7.16自动安装shell脚本
- mariadb通用二进制格式安装
- 使用shell脚本自动化安装zabbix客户端
- Shell脚本实现自动化安装
- ubuntu 下shell 命令的学习1----(编写自动化安装脚本)
- mysql最新通用二进制分发版本5.7.16自动安装shell脚本
- 用SHELL脚本自动化安装Nagios服务器端和客户端的 推荐
- 用SHELL脚本自动化安装Nagios服务器端和客户端的
- linux下自动化格式分区方法(非交互,可以用于shell脚本)
- CentOS6.5中使用通用二进制格式安装mariadb-5.5.36
- shell脚本自动化安装docker_install.sh
- shell 脚本安装MariaDB