MariaDB-Galera10源码安装
官方网站
http://mirrors.neusoft.edu.cn/mariadb/mariadb-galera-10.0.14/source
http://mirrors.neusoft.edu.cn/mariadb/mariadb-galera-10.0.14/galera-25.3.5/
环境:CentOS6.5 x64一.准备编译环境
1.卸载linux预装的mysql-libs
rpm -e --nodeps mysql-libs
2.安装编译必备工具及库
yum -y install gcc gcc-c++
libaio-devel pam-devel
libnl-devel popt-devel
popt-static
二、安装MariaDB-Galera
1.下载相关软件源码包
wget --no-check-certificate http://mirrors.neusoft.edu.cn/mariadb/mariadb-galera-10.0.14/source/mariadb-galera-10.0.14.tar.gzwget --no-check-certificate
2.建mysql服务的用户和用户组
[root@node2 rhel6]# groupadd mysql[root@node2 rhel6]# useradd -s /sbin/nologin -g mysql -M mysql
[root@node2 rhel6]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
3.解压mariadb-galera到临时安装目录,通常放在/usr/local/src目录下
[root@node2 ~]# ls
mariadb-galera-10.0.14.tar.gz
[root@node2 ~]# tar -xvf mariadb-galera-10.0.14.tar.gz -C
/usr/local/src/
4.通过cmake编译安装
[root@node2 ~]# cd /usr/local/src/mariadb-10.0.14/
[root@node2 mariadb-10.0.14]# mkdir rhel6
[root@node2 mariadb-10.0.14]# cd rhel6/
[root@node2 rhel6]# cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock
-DMYSQL_DATADIR=/var/lib/mysql
-DSYSCONFDIR=/etc
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_XTRADB_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DWITH_EXTRA_CHARSETS=1
-DWITH_BIG_TABLES=1
-DWITH_EMBEDDED_SERVER=1
-DWITH_DEBUG=0
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_SSL=system
[root@node2 rhel6]# make && make install
5.安装galera
[root@node2 ~]# rpm -ivh
galera-25.3.5-1.rhel6.x86_64.rpm
Preparing...
[root@node2 ~]# rpm -ql galera
/etc/init.d/garb
/etc/sysconfig/garb
/usr/bin/garbd
/usr/lib64/galera/libgalera_smm.so
/usr/share/doc/galera/COPYING
/usr/share/doc/galera/LICENSE.asio
/usr/share/doc/galera/LICENSE.chromium
/usr/share/doc/galera/LICENSE.crc32c
/usr/share/doc/galera/README
/usr/share/doc/galera/README-MySQL
三.配置MariaDB
1.将mysql管理调式工具添加到PATH路径
[root@node2 ~]# echo 'PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile[root@node2 ~]# source /etc/profile
顺道也加一个man记录
[root@node2 ~]# ls /usr/local/mysql/man/
man1
[root@node2 ~]# echo MANPATH /usr/local/mysql/man
>>/etc/man.config
[root@node2 ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/lib/mysql
WARNING: The host 'node1' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MariaDB version. The MariaDB daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MariaDB privileges !
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
141125 11:39:24 [Note] WSREP: Read nil XID from storage engines, skipping position init
141125 11:39:24 [Note] WSREP: wsrep_load(): loading provider library 'none'
141125 11:39:24 [Note] InnoDB: Using mutexes to ref count buffer pool pages
... ...
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
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
3.配置/etc/my.cnf和/etc/init.d/mysql
[root@node2 ~]# cp
/usr/local/src/mariadb-10.0.14/rhel6/support-files/my-huge.cnf
/etc/my.cnf
[root@node2 ~]# cp
/usr/local/src/mariadb-10.0.14/rhel6/support-files/mysql.server
/etc/init.d/mysql
[root@node2 ~]# chmod +x /etc/init.d/mysql
[root@node2 ~]# ll /etc/init.d/mysql
-rwxr-xr-x. 1 root root 12055 Nov 24 14:25 /etc/init.d/mysql
4.启服务
[root@node2 ~]# /etc/init.d/mysql startStarting MySQL. SUCCESS!
[root@node2 ~]# /etc/init.d/mysql status
[root@node2 ~]# netstat -tunlp|grep mysqld
tcp
[root@node2 ~]# chkconfig mysql on
[root@node2 ~]# chkconfig --list mysql
mysql
5.安全设置
[root@rhel7-test1 ~]# mysql_secure_installation
/usr/local/mysql/bin/mysql_secure_installation: line 379:
find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL
MariaDB
In order to log into MariaDB to secure it, we'll need the current
password for the root user.
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
初次使用密码为空,这里直接回车即可
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
这里设置mariadb的root密码
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.
go a bit smoother.
production environment.
Remove anonymous users? [Y/n] y
删除匿名用户
Normally, root should only be allowed to connect from 'localhost'.
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
不允许mariadb root用户远程登录
By default, MariaDB comes with a database named 'test' that anyone can
access.
before moving into a production environment.
Remove test database and access to it? [Y/n] y
删除test数据库
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
权限下发
Cleaning up...
All done!
installation should now be secure.
Thanks for using MariaDB!
也可以手动完成,
mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "dbrootpwd" with grant option;"四.测试
mysql -e "grant all privileges on *.* to root@'localhost' identified by "dbrootpwd" with grant option;"
mysql -uroot -pdbrootpwd -e "delete from mysql.user where Password='';"
mysql -uroot -pdbrootpwd -e "delete from mysql.db where User='';"
mysql -uroot -pdbrootpwd -e "drop database test;"
[root@node2 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.
Your MariaDB connection id is 13
Server version: 10.0.14-MariaDB-wsrep-log Source distribution, wsrep_25.10.r4144
Copyright (c) 2000, 2014, Oracle, SkySQL 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 |
+--------------------+
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> show enginesG;
*************************** 1. row ***************************