Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The practice of optimal configuration of MySQL production Environment

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Operating system environment configuration (optimal configuration for production environment)

4.1 hosts

echo "192.168.1.51 db1" >>/etc/hosts

cat /etc/hosts

4.2 Configure English environment echo "export LANG=en_US " >> ~/.bash_profile cat ~/.bash_profile4.3 Modify resource parameters

nproc, the operating system's resource limit on the number of processes created by the user

nofile, the number of times each process can open a file (file descriptor), mysql is a process versus multiple threads

stack, the size of the variable stored (heap size)

vi /etc/security/limits.conf

soft nproc 65535hard nproc 65535soft nofile 65535hard nofile 65535soft stack 65535hard stack 65535

#ulimit -a

echo "* - nproc 65535" > /etc/security/limits.d/90-nproc.conf

4.4 Set system security policy

1) selinux

vi /etc/selinux/config

SELINUX = disabled

setenforce 0

2)turn off the firewall

---Public network, it is recommended to open a firewall, set a reasonable security plan, limit access to the external network, this is the work of Linux system management, but DBAs also need to know. 6.x: iptales ,7.x: firewalld

service itptables stop

chkconfig --level 2345 itptables off

3)Control resource allocation restrictions

echo "session required pam_limits.so" >> /etc/pam.d/login

cat /etc/pam.d/login

4.5 Turn off NUMA functionality

view status

numastat

vi /etc/grub.conf

numa=off

numstat

numactl --show

numactl --hardware

reboot --reboot together later

4.6 IO Scheduling Algorithm and IO Optimization

IO scheduling algorithm

cat /sys/block/sd/queue/scheduler

--sas/stat

echo 'deadline' > /sys/block/sd/queue/scheduler

--ssd

echo 'NOOP' > /sys/block/sd*/queue/scheduler

--Reduce pre-reading

echo '16' > /sys/block/sdb/queue/read_ahead_kb

echo '16' > /sys/block/sdc/queue/read_ahead_kb

--Increase queue

echo '512' > /sys/block/sdb/queue/nr_requests

echo '512' > /sys/block/sdc/queue/nr_requests

--Effective after opening

vi /etc/rc.local

echo '512' > /sys/block/sdb/queue/nr_requests

echo '512' > /sys/block/sdc/queue/nr_requests

echo '16' > /sys/block/sdb/queue/read_ahead_kb

echo '16' > /sys/block/sdc/queue/read_ahead_kb

--4.7 Virtual memory vs. reserved memory

vi /etc/sysctl.conf

vm. swap =10 --Memory swap pages are used only when the system has 10% of physical memory left

vm.min_free_kbytes=5120 ---Test environment

#vm.min_free_kbytes=512000 --Production environment

sysctl -p

--5 yum Source Environment Configuration

mount /dev/sr0 /mnt

cd /etc/yum.repos.d

mkdir bk

mv *.repo bak

vi /etc/yum.repos.d/media.repo

[OEL6]

name=linux 6.9

baseurl=file:///mnt

gpgcheck=0

enabled=1

yum list

--6. Prepare disks and partitions---the most standardized

Installation directory: /mysql/app/mysql

Data directory: /mysql/data

Log directory: /mysql/log

Backup directory: /mysql/backup

LVM

/dev/sdb 100g

/dev/sdc 110g

#Database recommendation to do raid10

#Local Storage Scheme:

#physical disk try to do raid10, and then create partitions, regular FTP

#or sync tool to external storage.

pvcreate /dev/sdb /dev/sdc

vgcreate mysqlvg /dev/sdb

vgcreate bakvg /dev/sdc

lvcreate -n mysqllv -L 30G mysqlvg

lvcreate -n datalv -L 30G mysqlvg

lvcreate -n loglv -L 30G mysqlvg

lvcreate -n baklv -L 50G bakvg

pvs

vgs vgdisplay

lvs lvdisplay

mkfs.ext4 /dev/mysqlvg/mysqllv

mkfs.ext4 /dev/mysqlvg/datalv

mkfs.ext4 /dev/mysqlvg/loglv

mkfs.ext4 /dev/bakvg/baklv

mkdir -p /mysql/app

mkdir -p /mysql/log

mkdir -p /mysql/data

mkdir -p /mysql/backup

mount /dev/mysqlvg/mysqllv /mysql/app

mount /dev/mysqlvg/datalv /mysql/data

mount /dev/mysqlvg/loglv /mysql/log

mount /dev/bakvg/baklv /mysql/backup

df -h

vi /etc/fstab

/dev/mysqlvg/mysqllv /mysql/app ext4 defaults 0 0

/dev/mysqlvg/datalv /mysql/data ext4 defaults 0 0

/dev/mysqlvg/loglv /mysql/log ext4 defaults 0 0

/dev/bakvg/baklv /mysql/backup ext4 defaults 0 0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report