开始MySQL相关方面的东西
今天是关于MySQL的安装
系统为 redhat 6.10
数据库为MySQL 5.7.21
PS:目前最新版本为MySQL 5.7.25
这次为第一部分,及环境的准备,和Oracle一样,MySQL的安装也需要一些参数的设置
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
需要开启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
使用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
#vi /etc/hosts 127.0.0.1 localhost <IP ADDRESS> <hostname>
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
service iptables stop chkconfig iptables off service ip6tables stop chkconfig ip6tables off
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
默认128,可以加大至512. 根据需求可不加
# vi /etc/rc.local echo 512 > /sys/block/sda/queue/nr_requests # chmod +x /etc/rc.local
添加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)
reboot
好了 MySQL安装前的准备就到这了,下节为如何安装
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28413242/viewspace-2650269/ ,如需转载,请注明出处,否则将追究法律责任。