Linux server under MARIADB 10 automated Installation Deployment _mongodb

Source: Internet
Author: User
Tags log log mkdir

Go to mariadb official website to download MARIADB This article uses is the MARIADB 10.1.16
https://downloads.mariadb.org

Select binary version, download to/root directory
Mariadb-10.1.16-linux-x86_64.tar.gz

Start installation
[Root@he3 ~]# Cat mariadb_auto_install.sh

###### binary Automatic installation database script root password manager places scripts and installation packages in the/root directory to ############### ##### #数据库目录/usr/local/mysql############ ###### Data Directory/data/mysql############ ##### #日志目录/log/mysql############ ##### #端口号默认3306其余参数按需自行修改 ############ ############## # #author: rrhelei@126.com# ################## #!/bin/bash Path=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin : ~/bin Export PATH # Check if user isroot if [$ (id-u)!= "0"]; Then echo "Error:you must is root to Runthis script, please use the root to install" Exit 1 fi Clear echo "============= ============================================================ "echo" A tool Toauto-compile & Install MariaDB-10.1.16 on Redhat/centos Linux "echo" ===================================================================== = = = "cur_dir=$ (pwd) #set MySQL rootpassword echo" =========================== "mysqlrootpwd=" MANAGER "ECHO-E" please Input the root password of MySQL: "Read-p" (Default Password:manager): "Mysqlrootpwd if[" "$mysqlrootpwd" = ""]; Then Mysqlrootpwd= "MANAGER" fi echo "===========================" echo "MySQL root password: $mysqlrootpwd" echo "===================
======== "#which MySQL versiondo you want to install? echo "===========================" isinstallmysql56= "n" echo "Install mariadb-10.1.16,please input Y" read-p "(please Put y, N): "The isinstallmysql56 case" $isinstallmysql the "in y| y| yes| yes|yes|yes|yes|
Yes|yes) echo "You'll install mariadb 10.1.16" isinstallmysql56= "Y";; *) echo "INPUT error,you'll exit Install mariadb 10.1.16" isinstallmysql56= "n" Exit Esac Get_char () {savedstty= ' Stty -G ' Stty-echo sttycbreak #ddif =/dev/tty bs=1 count=1 2>/dev/null stty-raw sttyecho Stty$savedstty} echo "echo" Press
Any key to Start...or press CTRL + C to cancel char= ' Get_char ' # Initialize the installation related content. Functioninitinstall () {cat/etc/issue uname-a memtotal= ' free-m | grep Mem | awk ' {print $} ' echo-e ' \ n Memory is: ${ Memtotal} MB "#Settimezone rm-rf/etc/localtime ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime #Delete old MySQL program rpm-qa|grep mysql rpm-e mysql #DisableSeLinux if[-s/et C/selinux/config]; Then Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config fi setenforce 0} #Installation Ofdepen
D on and optimization options. Functioninstalldependsandopt () {CD $cur _dir cat>>/etc/security/limits.conf<<eof * Soft nproc 65535 * hard n Proc 65535 * Soft nofile 65535 * Hard nofile 65535 EOF echo "fs.file-max=65535" >>/etc/sysctl.conf} #Install my SQL functionInstallMySQL56 () {echo "============================install mariadb 10.1.16============================ = = = = = = "CD $cur _dir #Backup old my.cnf #rm-F/etc/my.cnf if [-s/etc/my.cnf]; Then mv/etc/my.cnf/etc/my.cnf ' date+%y%m%d%h%m%s '. Bak fi #mysql directoryconfiguration groupadd mysql-g512 useradd -u 512-gmysql-s/sbin/nologin-d/home/mysql mysql tar xvf/root/mariadb-10.1.16-linux-x86_64.tar.gz mv/root/mariadb-10 .1.16-linux-x86_64/uSr/local/mysql mkdir-p/data/mysql mkdir-p/log/mysql chown-r mysql:mysql/data/mysql chown-r Mysql:mysql/usr/local/mys QL chown-r mysql:mysql/log serverid= ' Ifconfigeth0 | grep "inet addr" | awk ' {print $} ' | Awk-f. ' {print$4 ' 3306 '} ' cat>>/etc/my.cnf<<eof [client] port =3306 socket =/tmp/mysql.sock Default-ch Aracter-set=utf8 [MySQL] default-character-set=utf8 [mysqld] Port =3306 socket =/tmp/mysql.sock Basedir =/USR DataDir =/data/mysql open_files_limit = 3072 Back_log =/local/mysql max_connections =800 max_connect_errors Table_open_cache =512 external-locking =false max_allowed_packet =32m sort_buffer_size =2M join_buffer_size =2M Thread _cache_size =51 query_cache_size =32m tmp_table_size = 96M max_heap_table_size= 96M slow_query_log = 1 slow_query_log_file =/log/mysql/slow.log Log-error =/log/mysql/error.log long_query_time = 1 Server-id = $SERVERID Log-bin =/log/mysql/ Mysql-bin sync_binlog = 1 binlog_cache_size =4m Max_binlog_cache_size= 8M max_binlog_size =1024m expire_logs_days =60 key_buffer_size =32m read_buffer_size =1M read_rnd_buffer_size= 16M bulk_insert_buffer_size= 64M Character-set-server=utf8 default-storage-engine= InnoDB binlog_format = row innodb_ buffer_pool_dump_at_shutdown= 1 innodb_buffer_pool_load_at_startup= 1 binlog_rows_query_log_events= 1 explicit_
defaults_for_timestamp= 1 #log_slave_updates =1 #gtid_mode =on #enforce_gtid_consistency =1 #innodb_write_io_threads = 8 #innodb_read_io_threads = 8 #innodb_thread_concurrency = 0 transaction_isolation= repeatable-read Innodb_additional_ mem_pool_size= 16M innodb_buffer_pool_size= 512M #innodb_data_home_dir = innodb_data_file_path= ibdata1:1024m: Autoextend innodb_flush_log_at_trx_commit= 1 innodb_log_buffer_size= 16M innodb_log_file_size= 512M Innodb_log_files_ in_group= 2 innodb_max_dirty_pages_pct= innodb_file_per_table= 1 innodb_locks_unsafe_for_binlog= 0 wait_timeout = 14400 interactive_timeout= 14400 skip-name-resolve [mysqldump] Quick MAX_allowed_packet =32m Eof/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/my SQL--defaults-file=/etc/my.cnf--user=mysql cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld chmod 700/etc/init.d/mysqld chkconfig--add MySQL chkconfig--leve l2345 on Cat mysqld . conf<<eof/usr/local/mysql/lib EOF Ldconfig If [-D "/proc/vz"];then Ulimit-s Unlimited Fi/etc/init.d/mysqlds Tart Cat >>/etc/profile <<eof export path= $PATH:/usr/local/mysql/bin export ld_library_path=/usr/local/my Sql/lib eof/usr/local/mysql/bin/mysqladmin-u root password $mysqlrootpwd cat >/tmp/mysql_sec_script<<eof u
Se MySQL;
Delete Frommysql.user where user!= ' root ' or host!= ' localhost ';
Flush privileges; Eof/usr/local/mysql/bin/mysql-u root-p$mysqlrootpwd-h localhost </tmp/mysql_sec_script #rm-F/TMP/MYSQL_SEC_SCR Ipt/etc/init.d/mysqldrestart Source/etc/profile ECho "============================mariadb 10.1.16 installcompleted========================="} functionCheckInstall (
{echo "===================================== Check install===================================" Clear ismysql= "" echo "Checking ..." if [-s/usr/local/mysql/bin/mysql] && [-s/usr/local/mysql/bin/mysqld_safe]&& [-S /ETC/MY.CNF]; Then echo "Mysql:ok" ismysql= "OK" Else echo "ERROR:/usr/local/mysql notfound!!! MySQL install failed. "fi if [" $ismysql "=" OK "]; Then echo "Mariadb 10.1.16 completed! Enjoy it. "echo" ========================================================================= "Netstat-ntl else echo" sorry,failed to install mysql! "echo" for your cantail/root/mysql-install.log from your server. "fi} #The Installationlog I nitinstall2>&1 | Tee/root/mysql-install.log checkanddownloadfiles2>&1 | Tee-a/root/mysql-install.log installdependsandopt2>&1 | Tee-a/root/mysql-install.log installmysql562>&1 | TEE-A/Root/mysql-install.log checkinstall2>&1 | Tee-a/root/mysql-install.log

[Root@he3 ~]# Mysql-uroot-p

Enter Password:
Welcome to the MARIADB Monitor. Commands End With; or \g.
Your mariadb Connection ID is 6
Server VERSION:10.1.16-MARIADB MARIADB Server
Copyright (c), 2016, Oracle, mariadb Corporation Ab and others.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
MARIADB [(None)]> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.00 sec)

At this point, the mariadb-10.1.16 installation was successful

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.