MySQL在Linux平台安装前需要做哪些准备
本篇内容介绍了“MySQL在Linux平台安装前需要做哪些准备”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
1. Selinux关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
2. 时间同步
2.1 redhat 5/6
需要开启slew time。
vi /etc/sysconfig/ntpd OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid" service ntpd restart chkconfig ntpd on
配置NTP服务
# vi /etc/ntp.conf server <NTP_SERVER_ADDR> iburst
停止NTP服务,手动同步时间。
service ntpd stop ntpdate -b <NTP_SERVER_ADDR> service ntpd start
时钟写回主板
hwclock --systohc hwclock;date
2.2 redhat 7
使用Chrony服务
vi /etc/chrony.conf server <NTP_SERVER_ADDR> iburst
重启时间同步服务:
systemctl restart chronyd.service systemctl enable chronyd.service
查看时间同步源:
chronyc sources -v
时钟写回主板
hwclock --systohc hwclock;date
3. 网络设置
#vi /etc/hosts 127.0.0.1 localhost <IP ADDRESS> <hostname>
4. 配置Limits
cat>>/etc/security/limits.conf<<EOF mysql soft nofile 1024 mysql hard nofile 65536 mysql soft nproc 4095 mysql hard nproc 16384 mysql soft stack 10240 mysql hard stack 32768 EOF cat>>/etc/security/limits.d/90-nproc.conf<<EOF mysql soft nproc 4095 mysql hard nproc 16384 EOF
5.禁用防火墙
service iptables stop chkconfig iptables off service ip6tables stop chkconfig ip6tables off
6. 系统内核参数
shmmax和shmall的设置
shmmax指的是单个内存段的最大值,单位为bytes
shmall指的是能使用的最大内存大小,单位为pages,
pages大小可通过 getconf PAGE_SIZE 命令查询,一般操作系统page大小为4096 bytes
如操作系统内存为8G,给80%给Oracle使用,则
kernel.shmmax=(8 * 0.8 * 1024 * 1024 * 1024 )=6871947673
kernel.shmall=kernel.shmmax/4096=1677721
如默认值比较大 请保持默认值
cat>>/etc/sysctl.conf<<EOF fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 fs.aio-max-nr = 1048576 # vm.min_free_kbytes = 524288 vm.swappiness= 5 # vm.nr_hugepages =1024 # vm.hugetlb_shm_group = 2000 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 net.ipv4.ip_local_port_range = 1024 65500
使其生效
# sysctl -p
7. 加大磁盘队列深度
默认128,可以加大至512. 根据需求可不加
# vi /etc/rc.local echo 512 > /sys/block/sda/queue/nr_requests # chmod +x /etc/rc.local
8. 文件系统配置
添加noatime,nodiratime选项 根据需求可不添加
# vi /etc/fstab /dev/mapper/centos-app /app xfs defaults,noatime,nodiratime 0 0
重新挂载后确认
# mount|grep noatime /dev/mapper/centos-app on /app type xfs (rw,noatime,nodiratime,attr2,inode64,noquota)
9. 重启系统
reboot
好了 MySQL安装前的准备就到这了,下节为如何安装
“MySQL在Linux平台安装前需要做哪些准备”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!