当前位置:网站首页>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
边栏推荐
- 伪分布安装spark
- 面试百分百问到的进程,你究竟了解多少
- Easyexcel reads the geographical location data in the excel table and sorts them according to Chinese pinyin
- Introduction notes to PHP zero Foundation (13): array related functions
- Getting started with JDBC
- [pimf] openharmony paper Club - what is the experience of wandering in ACM survey
- Modify the test case name generated by DDT
- Calculate pie chart percentage
- Deepinv20 installation MariaDB
- 【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

Ali developed three sides, and the interviewer's set of combined punches made me confused on the spot

Quick install mongodb

Mock test

Cartoon: what are IAAs, PAAS, SaaS?

The font of the soft cell changes color

Sail soft calls the method of dynamic parameter transfer and sets parameters in the title

True math problems in 1959 college entrance examination

英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)

批量制造测试数据的思路,附源码
随机推荐
How to build tiktok user trust and drive fan growth
安装及管理程序
Nacos detailed explanation, something
VMware Workstation cannot connect to the virtual machine. The system cannot find the specified file
网络安全之渗透靶场实战详解
PHP高效读大文件处理数据
Bytevcharts visual chart library, I have everything you want
Detailed explanation of Niuke - Gloves
漫画:什么是IaaS、PaaS、SaaS?
关于 background-image 渐变gradient()那些事!
Xinwangda: HEV and Bev super fast charging fist products are shipped on a large scale
聊一聊浏览器缓存控制
Custom implementation of Baidu image recognition (instead of aipocr)
SQL database
Solution of garbled code on idea console
On the security of key passing and digital signature
Use if else to judge in sail software - use the title condition to judge
MySQL personal learning summary
Execution plan calculation for different time types
∑GL-透视投影矩阵的推导