mariadb多實例搭建

 

  測試環境基於centos7.2,騰訊雲實驗室,學習搭建!mysql

        https://www.qcloud.com/developersql

  多實例mysql,能更加理解mysql安裝的基本過程!及簡單使用。。。數據庫

  mariadb是mysql的衍生版(原做者退出mysql團隊,主要是賣給oracle公司!本身想保持開源共享的特性。。。不得不說做者很屌)vim

       Mariadb官方: https://mariadb.com/centos

00、yum測試

[root@VM_94_232_centos ~]# yum search mariadb
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
=================================== N/S matched: mariadb ====================================
mariadb-bench.x86_64 : MariaDB benchmark scripts and data
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-embedded.i686 : MariaDB as an embeddable library
mariadb-embedded.x86_64 : MariaDB as an embeddable library
mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable library
mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable library
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-server.x86_64 : The MariaDB server and related files
mariadb.x86_64 : A community developed branch of MySQL
mariadb-test.x86_64 : The test suite distributed with MariaD
percona-xtrabackup.x86_64 : Online backup for InnoDB/XtraDB in MySQL, Percona Server and  #很出名名的數據庫備份,修復的公司,吊炸天安全

0一、安裝mysql

yum    install    -y mariadb-serveroracle

mkdir /mvpbang/{data3333,data3334}  #建立數據庫文件存放位置app

0二、初始化數據庫

mysql_install_db  --datadir=/mvpbang/data33343--user=mysqlsocket

mysql_install_db  --datadir=/mvpbang/data3334 --user=mysqltcp

chown -R mysql: /mvpbang/*    #權限設置

Installing MariaDB/MySQL system tables in '/mvpbang/data3334' ...
170823 19:58:08 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 10956 
...OK
Filling help tables...
170823 19:58:10 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 10965 
...OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password' '/usr/bin/mysqladmin' -u root -h VM_94_232_centos password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation' #安全設置(刪除test庫,禁止root遠程登陸)

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/mvpbang/data3334'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from MariaDB
Corporation Ab. You can contact us about this at sales@mariadb.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/

0三、設置my_multi.cnf

注意:本配置只在意簡單的多實例。對於對引擎等參數的設置,本文該不作介紹

show variables;    #默認參數信息,可根據作對應的調整

[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root #只能root管理

[mysqld3333]
socket = /tmp/mysql_3333.sock
port = 3333
pid-file = /mvpbang/data3333/3333.pid
datadir = /mvpbang/data3333
log = /mvpbang/log/mysql3333.log
user = mysql


[mysqld3334]
socket = /tmp/mysql_3334.sock
port = 3334
pid-file = /mvpbang/data3333/3334.pid
datadir = /mvpbang/data3334
log = /mvpbang/log/mysql3334.log
user = mysql

0四、啓動關閉

mysqld_multi   --defaults-extra-file=/etc/my_multi.cnf start | stop 3333,3334    #批量啓動關閉
mysqld_multi      --defaults-extra-file=/etc/my_multi.cnf start | stop 3333
mysqld_multi   --defaults-extra-file=/etc/my_multi.cnf start | stop 3334   #單個進行操做

亦能夠設置開機啓動

vim /etc/rc.d/rc.local

mysqld_multi   --defaults-extra-file=/etc/my_multi.cnf start  3333,3334

0五、設置root密碼設置密碼

設置密碼

mysqladmin   -uroot    -S   /tmp/mysql_3333.sock   password 123123;   #sock套接字快速鏈接
mysqladmin   -uroot   -S   /tmp/mysql_3334.sock    password 123123;

mysql登陸

mysql   -uroot   -p      -S /tmp/mysql_3306.sock

0六、常見命令參數

mysqld_multi

[root@VM_94_232_centos ~]# mysqld_multi  --help
mysqld_multi version 2.16 by Jani Tolonen

Description:
mysqld_multi can be used to start, or stop any number of separate
mysqld processes running in different TCP/IP ports and UNIX sockets.

mysqld_multi can read group [mysqld_multi] from my.cnf file. You may
want to put options mysqld=... and mysqladmin=... there.  Since
version 2.10 these options can also be given under groups [mysqld#], which gives more control over different versions.  One can have the
default mysqld and mysqladmin under group [mysqld_multi], but this is
not mandatory. Please note that if mysqld or mysqladmin is missing
from both [mysqld_multi] and [mysqld#], a group that is tried to be
used, mysqld_multi will abort with an error.

mysqld_multi will search for groups named [mysqld#] from my.cnf (or
the given --defaults-extra-file=...), where '#' can be any positive 
integer starting from 1. These groups should be the same as the regular
[mysqld] group, but with those port, socket and any other options
that are to be used with each separate mysqld process. The number
in the group name has another function; it can be used for starting,
stopping, or reporting any specific mysqld server.

#使用方法 Usage: mysqld_multi [OPTIONS] {start
|stop|report} [GNR,GNR,GNR...] #report 運行狀態報告 or mysqld_multi [OPTIONS] {start|stop|report} [GNR-GNR,GNR,GNR-GNR,...] The GNR means the group number. You can start, stop or report any GNR, or several of them at the same time. (See --example) The GNRs list can be comma separated or a dash combined. The latter means that all the GNRs between GNR1-GNR2 will be affected. Without GNR argument all the groups found will either be started, stopped, or reported. Note that syntax for specifying GNRs must appear without spaces. Options: These options must be given before any others: --no-defaults Do not read any defaults file --defaults-file=... Read only this configuration file, do not read the #經常使用語單實例 standard system-wide and user-specific files --defaults-extra-file=... Read this configuration file in addition to the #多實例配置文件 standard system-wide and user-specific files Using: --example Give an example of a config file with extra information. --help Print this help and exit. --log=... Log file. Full path to and the name for the log file. NOTE: If the file exists, everything will be appended. Using: --mysqladmin=... mysqladmin binary to be used for a server shutdown. Since version 2.10 this can be given within groups [mysqld#] Using: --mysqld=... mysqld binary to be used. Note that you can give mysqld_safe to this option also. The options are passed to mysqld. Just make sure you have mysqld in your PATH or fix mysqld_safe. Using: Please note: Since mysqld_multi version 2.3 you can also give this option inside groups [mysqld#] in ~/.my.cnf, where '#' stands for an integer (number) of the group in question. This will be recognised as a special option and will not be passed to the mysqld. This will allow one to start different mysqld versions with mysqld_multi. --no-log Print to stdout instead of the log file. By default the log file is turned on. --password=... Password for mysqladmin user. --silent Disable warnings. --tcp-ip Connect to the MySQL server(s) via the TCP/IP port instead of the UNIX socket. This affects stopping and reporting. If a socket file is missing, the server may still be running, but can be accessed only via the TCP/IP port. By default connecting is done via the UNIX socket. --user=... mysqladmin user. Using: root --verbose Be more verbose. --version Print the version number and exit.
相關文章
相關標籤/搜索