(5.2) mysql HA Series - test environment deployment

Keywords environment deployment:

[1] Planning
[1.1] Group A database server 8
192.168.1.200 ~ 192.168.1.207, host name db, db1 ~ db7
[1.2] SLB 2
192.168.1.211 ~ 192.168.1.212, host name, fz1, fz2
[1.3] middleware
192.168.1.221 ~ 192.168.1.222, host name, xm1, xm2


[2] virtual machine, model machine centos7
# IP address
IP address, 192.168.1.200
# modify the host name
hostname db1 # directly modifying the local host name
host name on the vi / etc / sysconfig / network # modify network

Disk # distribution
/ 50G
softvg: 30G
appvg: 51 is
datavg: 52 is
logvg: 53 is
bakvg: 54 is

lvm磁盘系统构建
#PV
pvcreate /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf
#VG
vgcreate softvg /dev/sdf
vgcreate appvg /dev/sdb
vgcreate datavg /dev/sdc
vgcreate logvg /dev/sdd
vgcreate bakvg /dev/sde
#LV
lvcreate -n softlv -L 30000M softvg
lvcreate -n mysqllv -L 50000M appvg
lvcreate -n datalv -L 50000M datavg
lvcreate -n loglv -L 50000M logvg
lvcreate -n baklv -L 49998M bakvg
#格式化
mkfs.xfs /dev/softvg/softlv
mkfs.xfs /dev/appvg/mysqllv
mkfs.xfs /dev/datavg/datalv
mkfs.xfs /dev/logvg/loglv
mkfs.xfs /dev/bakvg/baklv
#创建目录
mkdir -p /soft
mkdir -p /mysql/app
mkdir -p /mysql/data
mkdir -p /mysql/log
mkdir -p /mysql/backup

#挂载
mount /dev/softvg/softlv /soft
mount /dev/appvg/mysqllv /mysql/app
mount /dev/datavg/datalv /mysql/data
mount /dev/logvg/loglv /mysql/log
mount /dev/bakvg/baklv /mysql/backup

#修改 /etc/fstab 以便可以重启自动挂载
echo '/dev/softvg/softlv /soft xfs defaults 0 0'>>/etc/fstab
echo '/dev/appvg/mysqllv /mysql/app xfs defaults 0 0'>>/etc/fstab
echo '/dev/datavg/datalv /mysql/data xfs defaults 0 0'>>/etc/fstab
echo '/dev/logvg/loglv /mysql/log xfs defaults 0 0'>>/etc/fstab
echo '/dev/bakvg/baklv /mysql/backup xfs defaults 0 0'>>/ etc / fstab

# local host
echo '192.168.1.200 db' >>/etc/hosts
echo '192.168.1.201 db1' >>/etc/hosts
echo '192.168.1.202 db2' >>/etc/hosts
echo '192.168.1.203 db3' >>/etc/hosts
echo '192.168.1.204 db4' >>/etc/hosts
echo '192.168.1.205 db5' >>/etc/hosts
echo '192.168.1.206 db6' >>/etc/hosts
echo '192.168.1.207 db7' >>/etc/hosts
echo '192.168.1.211 fz1' >>/etc/hosts
echo '192.168.1.212 fz2' >>/etc/hosts
echo '192.168.1.221 xm1' >>/etc/hosts
echo '192.168.1.222 xm2' >>/etc/hosts

#配置字符集
echo "export LANG=en_US.UTF8">>~/.bash_profile
echo "export LANG=en_US.UTF8">>/etc/profile


# Mount the CD
mount / dev / cdrom / mnt


# Set the source yum
CD /etc/yum.repos.d/
mkdir BK
Music Videos Base.repo the CentOS-BK /
Touch Base.repo
echo "[Base]" >> Base.repo
echo "name = centos7.5_cdrom" >> Base.repo
echo "baseurl = File: /// mnt" >> Base.repo
echo "gpgcheck = 0" >> Base.repo
echo "Enabled = 1" >> Base.repo
yum yum source verification List #

# set the default 3 startup mode, multi-user mode
systemctl GET-default multi-user.target
systemctl GET-default verification #

Parameter optimization # (. 1)
echo "300000 * Soft MEMLOCK" >> / etc / Security / limits.cnf Memory Lock # 300M
echo "* Hard MEMLOCK 300000" >> / etc / Security / limits.cnf
echo "vm.nr_hugepages = 150 ">> / etc / the sysctl.conf
echo" vm.swappiness = 10 ">> / etc / the sysctl.conf - virtual memory page swapping when less than 10% of physical memory to enable
echo" vm.min_free_kbytes = 51200 " >> / etc / sysctl.conf - to the operating system reserved 50M, recommended test environment
echo "# vm.min_free_kbytes = 512000" >> / etc / sysctl.conf - to the operating system reserved 500M, recommended to the production environment
sysctl -p # verify

# parameter optimization (2)
echo "* Soft nproc 65535" >> / etc / Security / limits.conf #nproc process limit the number of user-created
echo "* hard nproc 65535" >> / etc / security / limits .conf
echo "* Soft nofile 65535" >> / etc / Security / Limits.conf #nofile process number of open file limit
echo "* hard nofile 65535" >> / etc / security / limits.conf
echo "* soft stack 65535" >>/etc/security/limits.conf #存放变量的指针
echo "* hard stack 65535" >>/etc/security/limits.conf

systemctl stop avahi-daemon.socket avahi-daemon.service
systemctl disable avahi-daemon.socket avahi-daemon.service

#selinux关闭
echo "* - nproc 16384">/etc/security/limits.d/90-nproc.conf #nproc 进程数限制
echo "SELINUX=disable">/etc/selinux/config #关闭selinux
echo "#SELINUXTYPE=targeted">>/etc/selinux/config
cat /etc/selinux/config
setenforce 0
getenforce

# Firewall close
systemctl Status firewalld.service
systemctl STOP firewalld.service
systemctl disable firewalld.service

#IO scheduling algorithm
# a total of four kinds, the default is the CFQ (completely random access, relatively speaking, this algorithm is not very good for mysql, will IO delay caused by a small increase, msql official website recommendation algorithm replaced deadline algorithm, which is relatively stable IO).
#sas and stat official website is recommended to use this
echo 'DEADLINE'> / SYS / Block / SDB / Queue / Scheduler
echo 'DEADLINE'> / SYS / Block / SDC / Queue / Scheduler
echo 'DEADLINE'> / SYS / Block / SDD / Queue / Scheduler
echo 'DEADLINE'> / SYS / Block / SDE / Queue / Scheduler
echo 'DEADLINE'> / SYS / Block / SDF / Queue / Scheduler
#ssd with this
echo 'NOOP'> / sys / block / sd * / scheduler

#减少预读(默认128)
echo '16'>/sys/block/sdb/queue/read_ahead_kb
echo '16'>/sys/block/sdc/queue/read_ahead_kb
echo '16'>/sys/block/sdd/queue/read_ahead_kb
echo '16'>/sys/block/sde/queue/read_ahead_kb
echo '16'>/sys/block/sdf/queue/read_ahead_kb

#增大队列
echo '512'>/sys/block/sdb/queue/nr_requests
echo '512'>/sys/block/sdc/queue/nr_requests
echo '512'>/sys/block/sdd/queue/nr_requests
echo '512'>/sys/block/sde/queue/nr_requests
echo '512'>/sys/block/sdf/queue/nr_requests

#x修改时区为上海
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Replace the memory mode, without using a NUMA mode
VI / etc / default / GRUB
GRUB_CMDLINE_LINUX = "Auto rhgb quiet NUMA crashkernel = OFF =" # this line into this
grub2 -o-mkconfig /etc/grub2.cfg
numastat
numactl - Show
numactl --hardware
the shutdown -r now

Guess you like

Origin www.cnblogs.com/gered/p/11260952.html