On line project configuration of Linux Cluster Architecture (3)
Write it at the front
So far, the installation and configuration of all application projects have been described. Today, we will introduce the database installation, configuration, master-slave synchronization and other related processes
How to install MySQL
As for the installation and configuration of the database, many methods have been introduced in the previous article. Several installation methods of the general database are as follows:
1. Yum install
This kind of installation is generally used in the environment with low requirement for database in Intranet, such as monitoring service, etc
2. General compilation installation
The version before 5.5 can be directly compiled and installed by using. / configure make & & make install, but the later version needs to refer to the third-party software cmake, and then compile and install
3. RPM package installation
Download the corresponding RPM package for installation
4. Binary installation
Download the corresponding version of the binary installation package, decompression, initialization can complete the installation
For which method to install, according to the actual needs
Install MySQL service
Today, we introduce how to use binary installation package to install mysql
Install dependent Libraries
yum install libao libao-devel -y
Add user
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin –M
Download a software
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86\_64.tar.gz
Unzip to the directory
[[email protected] ~]# tar zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# ln -s /usr/local/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
[[email protected] mysql]# mkdir /data
[[email protected] mysql]#chown –R mysql.mysql /data
Initialize database
[[email protected] ~]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
2017-09-23T09:14:16.724707Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-23T09:14:17.698204Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-09-23T09:14:17.888059Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-09-23T09:14:17.977944Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 93b7f20c-a03f-11e7-b91d-000c29d812ec.
2017-09-23T09:14:17.988894Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-09-23T09:14:17.995157Z 1 [Note] A temporary**password is generated for [email protected]: csnbtzNIf0-6**
Copy boot file
[[email protected] ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[[email protected] ~]# chmod +x /etc/init.d/mysqld
[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[[email protected] ~]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 1639 mysql 20u IPv6 15683 0t0 TCP *:mysql (LISTEN)
[[email protected] ~]# ln -s /data/mysql.sock /tmp/
The default login is via / tmp/ mysql.sock File to connect to MySQL, you can specify the path in the configuration file, or you can achieve this effect, otherwise login will report an error
########The above configuration of other slave databases is the same as the above operation###############
Master slave synchronization configuration of database
In fact, the relevant configuration has been introduced in the previous article, but for the integrity of the whole project, the whole operation process is introduced again here
Modify the configuration file of master-slave server
[[email protected] ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir = /data
socket = /data/mysql.sock
server-id = 1
log-bin = /data/mysql-bin
relay-log = /data/master.relay-bin
relay-log-info-file = /data/master.relay-log.info
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
replicate-ignore-db=mysql
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[[email protected] ~]# vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data
socket=/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id = 2
#log-bin = /data/mysql-bin
relay-log = /data/slave.relay-bin
relay-log-info-file = /data/slave.relay-log.info
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The configuration file comment is just a brief introduction. Please refer to the previous article
The master database creates and authorizes synchronized users
mysql> grant replication slave on *.* to [email protected]'10.0.0.%' identified by'123456';
Query OK, 0 rows affected, 1 warning (0.04 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
The master and slave servers restart the service, and the master database is fully standby
Push full file to slave Library
Restore from library
Execute the change master statement
[[email protected] ~]# mysql -uroot -p123456 </root/master.sql
[[email protected] ~]# mysql -uroot -p123456
mysql> change master to
-> master_host='10.0.0.11',
-> master_port=3306,
-> master_user='rep',
-> master_password='123456',
-> master_log_file='mysql-bin.000001',
-> master_log_pos=154;
Query OK, 0 rows affected, 2 warnings (0.04 sec)
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
View synchronization status
Test master slave synchronization
The whole process configuration of master-slave synchronization is completed. In the actual production environment, this architecture will be expanded to read-write separation, one master-slave, two-master-slave, etc. the actual production requirements, personal technical points and learning costs will be looked at. The related read-write separation and highly available architecture combat will be introduced in the follow-up, please look forward to it!!!
Installation and configuration of redis and ZABBIX
Redis installation is very simple
Download, unzip to the specified directory, start to complete
Please refer to the previous related articles
Redis production of high availability solutions
Monitoring installation is no longer discussed here. There is a large article on the installation and configuration process
ZABBIX installation and configuration
ZABBIX monitors MySQL service configuration