当前位置:网站首页>CentOS MySQL multi instance deployment
CentOS MySQL multi instance deployment
2022-04-23 16:48:00 【A coir boat in the broken white clouds】
One . Clear the original environment mysql、mariadb
# Check to see if there is mysql Of rpm package
rpm -qa|grep mysql
Delete the queried package ( Delete... According to the actual situation )
rpm -e name
Two . Install multiple instances
# Enter the temporary folder
cd /tmp
ls
# decompression mysql Compressed package
tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
ls
# Move to installation directory
mv mysql-5.7.30-linux-glibc2.12-x86_64/ /usr/local/mysql
# Enter the installation directory
cd /usr/local/mysql
ls
# Create... In the system mysql account number
groupadd -g 1002 mysql
useradd -u 1002 -g 1002 -M -s /sbin/nologin mysql
# verification mysql account number
id mysql
# Add environment variables
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
# establish data Storage directory
mkdir /data/mysql_platform/data
mkdir /data/mysql_storage/data
mkdir /data/mysql_production/data
mkdir /data/mysql_sale/data
mkdir /data/mysql_aggregate/data
#my.cnf Storage address ( Customize
#my.cnf To configure
[mysql]
# Set up mysql Client default character set
default-character-set=utf8
[mysqld]
# Port number ( Can't repeat , Distinguish multiple instances by port number
port=3302
# Set up mysql Installation directory
basedir=/usr/local/mysql
# Set up mysql Database data storage directory
datadir=/data/mysql_storage/data
# Server's id( Can't repeat
server-id=102
# Multiple instances start at this address
socket=/data/mysql_storage/mysql.sock
# Error log storage directory
log_error=/data/mysql_storage/logs/mysql.log
# Binary log storage directory
log_bin=/data/mysql_storage/logs/mysql-bin
# Binary file format
binlog-format=MIXED
# Maximum connections allowed
max_connections=200
# The character set used by the server defaults to 8 Bit coded latin1 Character set
character-set-server=utf8
# The default storage engine that will be used when creating a new table
default-storage-engine=INNODB
# The name of the synchronized database
replicate-do-db=storage_release
# establish slave_master_info Table of
master-info-repository = table
# establish mysql.slave_relay_info Table to record the location information of synchronization
relay-log-info-repository = table
# Of other instances my.cnf The configuration is the same as above
# Will all .service The documents are stored in /etc/systemd/system Under the table of contents
# modify defaults-file For its counterpart my.cnf The configuration file
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
#defaults-file my.cnf Storage path
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_storage/my.cnf
# Of other instances .servicef The configuration is the same as above
# Initialization file
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql_platform/data --basedir=/usr/local/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql_storage/data --basedir=/usr/local/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql_production/data --basedir=/usr/local/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql_sale/data --basedir=/usr/local/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql_aggregate/data --basedir=/usr/local/mysql
# Modify the permissions -R Whole folder Give permission to the owner of the entire folder mysql Under group mysql user
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql_*
# start-up mysql-- Check the status of each database
systemctl status mysql_platform.service
systemctl status mysql_storage.service
systemctl status mysql_production.service
systemctl status mysql_sale.service
systemctl status mysql_aggregate.service
# Start the database in turn
systemctl start mysql_platform.service
systemctl status mysql_platform.service
systemctl start mysql_storage.service
systemctl status mysql_storage.service
systemctl start mysql_production.service
systemctl status mysql_production.service
systemctl start mysql_sale.service
systemctl status mysql_sale.service
systemctl start mysql_aggregate.service
systemctl status mysql_aggregate.service
# Verify startup
netstat -lnp|grep 33
# Connection database verification and modification root The connection permission of the account .
# No password to use mysql -S /data/mysql_platform/mysql.sock
# With password mysql -u user name -p -S /data/mysql_platform/mysql.sock
mysql -S /data/mysql_platform/mysql.sock
# Check account information
select user,host from mysql.user;
# Set up root account number IP Address permissions for all IP
update mysql.user set host='%' where user='root';
# Refresh the permissions
flush privileges;
# sign out
quit;
# Several other databases operate the same as above .
mysql -S /data/mysql_storage/mysql.sock
mysql -S /data/mysql_sale/mysql.sock
mysql -S /data/mysql_production/mysql.sock
mysql -S /data/mysql_aggregate/mysql.sock
# Set boot up
systemctl enable mysql_platform.service
systemctl enable mysql_storage.service
systemctl enable mysql_sale.service
systemctl enable mysql_production.service
systemctl enable mysql_aggregate.service
# close selinux
vim /etc/sysconfig/selinux ( After entering i-> edit ->esc->:wq)
take SELINUX It is amended as follows DISABLED, namely SELINUX=DISABLED
# Firewall open port
firewall-cmd --zone=public --add-port=3301/tcp --permanent
firewall-cmd --zone=public --add-port=3302/tcp --permanent
firewall-cmd --zone=public --add-port=3303/tcp --permanent
firewall-cmd --zone=public --add-port=3304/tcp --permanent
firewall-cmd --zone=public --add-port=3305/tcp --permanent
# service iptables restart
firewall-cmd --reload
# Restart the computer to test self startup
reboot
The end! ~
版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400068336.html
边栏推荐
- English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
- 深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
- 【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
- LVM and disk quota
- Do you really understand the principle of code scanning login?
- ◰ GL shadow map core steps
- OMNeT学习之新建工程
- Use case execution of robot framework
- Sail soft implements a radio button, which can uniformly set the selection status of other radio buttons
- STM32__ 03 - beginner timer
猜你喜欢
随机推荐
Gartner 發布新興技術研究:深入洞悉元宇宙
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
Query the data from 2013 to 2021, and only query the data from 2020. The solution to this problem is carried out
Use itextpdf to intercept the page to page of PDF document and divide it into pieces
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
Pytorch: the pit between train mode and eval mode
Selenium IDE and XPath installation of chrome plug-in
Gartner announces emerging technology research: insight into the meta universe
Detailed explanation of Niuke - Gloves
Custom implementation of Baidu image recognition (instead of aipocr)
05 Lua control structure
信息摘要、数字签名、数字证书、对称加密与非对称加密详解
Sail soft calls the method of dynamic parameter transfer and sets parameters in the title
How magical is the unsafe class used by all major frameworks?
织梦DEDECMS安全设置指南
The font of the soft cell changes color
Disk management and file system
Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
Cartoon: what are IAAs, PAAS, SaaS?
面试百分百问到的进程,你究竟了解多少