CentOS 6 Multi-instance compilation installation mariadb-5.5.59

Source: Internet
Author: User

Objective

System Platform:

CentOS Release 6.9 (Final)

Kernel 2.6.32-696.el6.x86_64

1. Go to the official website to download the appropriate source package

http://mariadb.org/

Mariadb-5.5.59.tar.gz

Check that the database is installed in the system.

#rpm -qa|grep MariaDB#rpm -qa|grep mysql
2. Go to the official website to download CMake source package

https://cmake.org/

CMake The latest version requires C++11 support, gcc4.8 the following is not included, so you need to download the cmake-3.9.6 version, this version does not require C + +11

Cmake-3.9.6.tar.gz

View current system GCC versions

#gcc -vgcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
3. Unzip the CMake package to any temporary directory
#tar xvf cmake-3.9.6.tar.gz -C /app
4. Compile and install CMake
安装依赖包# yum install ncurses-devel libaio-devel openssl-devel  -y# cd /app/cmake-3.9.6#./configure --prefix=/usr/local && gmake -j 4#gmake install#which cmake/usr/local/bin/cmake#cmake --versioncmake version 3.9.6
5. Create MySQL group and account
#groupadd -g 500 mysql#useradd -u 500 -g mysql -s /sbin/nologin -M mysql
6. Unzip the MARIADB package to any temporary directory
#tar xvf mariadb-5.5.59.tar.gz -C /app
7. Compile and install MARIADB
# cd mariadb-5.5.59以下的编译参数,根据自己的需求定制# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-5.5.59 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_DEBUG=0我使用的AUSU笔记本是 I5  1CPU 4核,2GB内存,8分钟编译完成。# make -j 4 && make install
8. Create a soft link MySQL point to the extracted directory
#cd /usr/local/#ln -s mariadb-5.5.59/ mysql
9. Modify the MySQL folder owner and owning group
#chown -R mysql.mysql /usr/local/mysql/
10. Add path to environment variable
#echo ‘PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile.d/mysql.sh检查文件#cat /etc/profile.d/mysql.sh加载环境变量文件 并检查#source /etc/profile.d/mysql.sh#echo $PATH
11. Create a database Hosting folder and Modify permissions
#mkdir -pv /data/sqldb/{3306,3307,3308}/{etc,log,data,pid,socket,tmp}#chown -R mysql.mysql /data/sqldb/#chmod -R 770 /data/sqldb/
12. Copy the Master profile my.cnf

This is the first to confirm how much memory is in the machine so that you can use a reference template.

#grep memory support-files/*

Find a template for native memory

The native memory is 512M, so the my-large.cnf configuration file is selected

#\cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
9. Modify the configuration file
#vim/ETC/MY.CNF because it is a multi-instance installation, here's the configuration note for reference to my. Of course, you can also use the script's own example to generate sample samples, self-modification #mysqld_multi--example in the configuration file using Mysqldn for multiple instances, where n represents the ID of the instance for specifying an instance in the Mysqld_multi command [ Mysqld_multi]mysqld =/usr/local/mysql/bin/mysqld_safemysqladmin =/usr/local/mysql/bin/mysqladminuser = Multi_a Dminpassword = multipass# the MariaDB server[mysqld3306]port = 3306socket =/data/sqldb/3306/socket/mysql330 6.sockpid-file =/data/sqldb/3306/pid/mysql3306.piddatadir =/data/sqldb/3306/datatmpdir =/data/sqldb/3306/ tmpinnodb_file_per_table = 1skip_name_resolve = 1#******************************* Logs settings ********************* Log-error =/data/sqldb/3306/log/3306error.log[mysqld3307]port = 3307socket =/data/sqldb/3307/s Ocket/mysql3307.sockpid-file =/data/sqldb/3307/pid/mysql3307.piddatadir =/data/sqldb/3307/datatmpdir =/data/sqldb /3307/tmp******************************* Logs Settings ***************************log-error =/data/sqldb/3307/log/ 3307error.log[mysqld3308]port = 3308socket =/data/sqldb/3308/socket/mysql3308.sockpid-file =/data/sqldb/3308/pid/mysql3308.pidda Tadir =/data/sqldb/3308/datatmpdir =/data/sqldb/3308/tmp******************************* Logs settings ************* Log-error =/data/sqldb/3308/log/3308error.log
10. Installing database-related files
# cd /usr/local/mysql

To view the installation parameters for the installation program

#./scripts/mysql_install_db --help

The following command must be executed within this folder, or the following error will be reported

FATAL ERROR: Could not find ./bin/my_print_defaults#./scripts/mysql_install_db --datadir=/data/sqldb/3306/data --user=mysql  --skip-name-resolve --basedir=/usr/local/mysql#./scripts/mysql_install_db --datadir=/data/sqldb/3307/data --user=mysql  --skip-name-resolve --basedir=/usr/local/mysql#./scripts/mysql_install_db --datadir=/data/sqldb/3307/data --user=mysql  --skip-name-resolve --basedir=/usr/local/mysql参数说明 :指定此实例的数据目录,跳过DNS解析,指定my_print_defaults的父级目录

The presence of 2 OK means that the installation is normal.

11. Copy the multi-instance start service script to the/ETC/INIT.D directory
#cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi
12. Starting an instance 3306
# mysqld_multi start 3306
13. Make the Security Configuration

Because the Mysql_secure_installation tool in this source package is connected by default using the/tmp/mysql.sock file, you can point to a custom socket file by creating a soft connection

#ln -s /data/sqldb/3306/socket/mysql3306.sock /tmp/mysql.sock
#/usr/local/mysql/bin/mysql_secure_installationEnter current password for root 默认为空Set root password   设置mysql root密码Remove anonymous users  是否移除匿名用户登录Disallow root login remotely    是否禁止root远程登录Remove test database and access to it?  是否移除test数据和test账号Reload privilege tables now?    是否立即更新权限Thanks for using MariaDB!
14. Repeat the 2 steps above to configure each instance safely
注意 ln -s /data/sqldb/这里要变化/socket/mysql这里要变化.sock /tmp/mysql.sock
15. Add a secure Shutdown database account for each instance

Mysqld_multi can start normally with the above configuration, but it does not shut down properly when it is turned off. Therefore, you need to create a separate security account, call the Mysqladmin command to close.

  #mysql-uroot-p-s/data/sqldb/3306/socket/mysql3306.sock-e "Grant shutdown on *. * to [email protected] ' localhost ' identified by ' Multipass '; "  #mysql-uroot-p-s/data/sqldb/3307/socket/mysql3307.sock-e "Grant shutdown on * * to [email protected] ' localhost ' Identified by ' Multipass '; "  #mysql-uroot-p-s/data/sqldb/3308/socket/mysql3308.sock-e "Grant shutdown on * * to [email protected] ' localhost ' Identified by ' Multipass '; " Confirm that the following command replaces the socket and executes again. #mysql-uroot-p-s/data/sqldb/3306/socket/mysql3306.sock-e ' select User,password,host from Mysql.user where user= ' mult I_admin ";" Enter Password: +-------------+-------------------------------------------+-----------+| user | password | Host |+-------------+-------------------------------------------+-----------+| Multi_admin | *4fd92416c02ec3bd04a97613db2cb33717e99d0f | localhost |+-------------+-------------------------------------------+-----------+  

16. Add the account password you just created to the main profile/etc/my.cnf

[mysqld_multi]user       = multi_adminpassword   = multipass

If the two instance of the database shutdown password (mysql password, not the system password) at the same time, can be set by the above method, if different, you need to comment out the Mysqld_multi key password items (equivalent to the global configuration),

Add the corresponding pasword password in each instance (configuration with active scope).

17. Add Boot Boot
#chkconfig --add mysqld_multi#chkconfig --list mysqld_multimysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off默认这样添加脚本的话,在启动时会报以下错误WARNING: my_print_defaults command not found.Please make sure you have this command available andin your path. The command is available from the latestMySQL distribution.ABORT: Can‘t find command ‘my_print_defaults‘.This command is available from the latest MySQLdistribution. Please make sure you have the commandin your PATH.解决方法:第一种.在/etc/init.d/mysqld_multi脚本中的最开始行添加PATHPATH=/usr/local/mysql/bin:$PATH第二种.添加一个软链接#ln -s /usr/local/mysql/bin/my_print_defaults /usr/bin/
18. How to use server scripts
# mysqld_multi [options] {start|stop|reload|report} [实例编号[,实例编号] ...]实例编号在/etc/my.cnf中这些位置[mysqld实例编号]如:mysqld_multi start 1-3 启动实例1、2、3mysqld_multi stop 1-3 关闭实例1、2、3mysqld_multi stop 8,10-13 关闭实例8、10至13mysqld_multi stop     没有参数就是全部关闭mysqld_multi start     启动全部实例
19. Client Connection
本机通过mysql命令进行连接时会受到影响,需要通过-S选项指定socket文件的位置,而远程主机连接不受影响。如:#mysql -uroot -p -S /data/sqldb/3306/socket/mysql3306.sock#mysql -uroot -p -h192.168.5.100

At this point, the MARIADB multi-instance compilation installation method is complete.

The shortcomings

Mysqld_multi Unified management of multiple MySQL instances. Although there is convenience, but in the process of use. Also found some shortcomings,

1. The options are too simple. There is only start, stop, Report, and no status item, so the state of the service cannot be viewed;

2. When starting and shutting down the service, just run start, stop such an operation. Without tracking the results of the operation, it is not possible to ensure that the operation runs successfully.

CentOS 6 Multi-instance compilation installation mariadb-5.5.59

Related Article

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.