• centos 7.4 + mysql 5.7 + yum 安装


    os: centos7.4
    db: mysql 5.7.21

    安装一些依赖包

    # yum install make cmake *gcc* libaio libaio-devel automake autoconf bz bison libtool ncurses wget perl-DBI perl-DBD-MySQL perl-JSON perl-Time-HiRes perl-devel numactl* bzip2 git openssl openssl-devel
    

    修改 NOZEROCONF

    # vi /etc/sysconfig/network
    NOZEROCONF=YES

    修改IO调度器设置
    elevator=deadline
    关闭 NUMA 特性
    numa=off
    禁用透明大页
    transparent_hugepage=never

    # vi /etc/default/grub
    # grub2-mkconfig -o /boot/grub2/grub.cfg   

    修改内核参数

    # vi /etc/sysctl.conf
    vm.swappiness = 1 

    调整资源限制

    # vi  /etc/security/limits.conf
    * soft nofile 65535
    * hard nofile 65535
    
    * soft nproc 65535
    * hard nproc 65535

    禁止selinux

      vi /etc/sysconfig/selinux
      SELINUX=DISABLED
      或者
      vi /etc/selinux/config
      SELINUX=disabled

    sshd中关闭UseDNS:

    vi /etc/ssh/sshd_config
    
    UseDNS no
    systemctl restart sshd

    确认安装sysstat

    rpm -qa | grep sysstat

    centos 7 安装mysql时,默认的是mariadb

    # yum install mysql
    ---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be updated
    ---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be an update

    所以需要安装mysql的yum源
    https://dev.mysql.com/downloads/repo/yum/

    下载 mysql57-community-release-el7-11.noarch.rpm

    # rpm -ivh /tmp/mysql57-community-release-el7-11.noarch.rpm
    # cd /etc/yum.repos.d
    # ls -l |grep -i mysql
    -rw-r--r--  1 root root 1838 Apr 27  2017 mysql-community.repo
    -rw-r--r--  1 root root 1885 Apr 27  2017 mysql-community-source.repo

    安装mysql 5.7

    # yum install mysql
    
    Dependencies Resolved
    
    =======================================================================================================================================================================================
     Package                                                Arch                              Version                                   Repository                                    Size
    =======================================================================================================================================================================================
    Installing:
     mysql-community-client                                 x86_64                            5.7.21-1.el7                              mysql57-community                             24 M
     mysql-community-libs                                   x86_64                            5.7.21-1.el7                              mysql57-community                            2.1 M
         replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
     mysql-community-libs-compat                            x86_64                            5.7.21-1.el7                              mysql57-community                            2.0 M
         replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
    Installing for dependencies:
     mysql-community-common                                 x86_64                            5.7.21-1.el7                              mysql57-community                            272 k
    
    Transaction Summary
    =======================================================================================================================================================================================
    Install  3 Packages (+1 Dependent package)
    
    Total download size: 28 M
    Is this ok [y/d/N]: y
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY|  85 kB  --:--:-- ETA 
    Public key for mysql-community-common-5.7.21-1.el7.x86_64.rpm is not installed
    (1/4): mysql-community-common-5.7.21-1.el7.x86_64.rpm                                                                                                           | 272 kB  00:00:00     
    (2/4): mysql-community-libs-5.7.21-1.el7.x86_64.rpm                                                                                                             | 2.1 MB  00:00:01     
    (3/4): mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm                                                                                                      | 2.0 MB  00:00:01     
    (4/4): mysql-community-client-5.7.21-1.el7.x86_64.rpm                                                                                                           |  24 MB  00:01:24     
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                                  342 kB/s |  28 MB  00:01:24     
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Importing GPG key 0x5072E1F5:
     Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
     Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
     Package    : mysql57-community-release-el7-11.noarch (@/mysql57-community-release-el7-11.noarch)
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Is this ok [y/N]: y
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : mysql-community-common-5.7.21-1.el7.x86_64                                                                                                                          1/5 
      Installing : mysql-community-libs-5.7.21-1.el7.x86_64                                                                                                                            2/5 
      Installing : mysql-community-client-5.7.21-1.el7.x86_64                                                                                                                          3/5 
      Installing : mysql-community-libs-compat-5.7.21-1.el7.x86_64                                                                                                                     4/5 
      Erasing    : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                                           5/5 
      Verifying  : mysql-community-common-5.7.21-1.el7.x86_64                                                                                                                          1/5 
      Verifying  : mysql-community-libs-5.7.21-1.el7.x86_64                                                                                                                            2/5 
      Verifying  : mysql-community-client-5.7.21-1.el7.x86_64                                                                                                                          3/5 
      Verifying  : mysql-community-libs-compat-5.7.21-1.el7.x86_64                                                                                                                     4/5 
      Verifying  : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                                                                                                                           5/5 
    
    Installed:
      mysql-community-client.x86_64 0:5.7.21-1.el7               mysql-community-libs.x86_64 0:5.7.21-1.el7               mysql-community-libs-compat.x86_64 0:5.7.21-1.el7              
    
    Dependency Installed:
      mysql-community-common.x86_64 0:5.7.21-1.el7                                                                                                                                         
    
    Replaced:
      mariadb-libs.x86_64 1:5.5.44-2.el7.centos                                                                                                                                            
    
    Complete!
    # yum install mysql-server
    
    Dependencies Resolved
    
    =======================================================================================================================================================================================
     Package                                            Arch                               Version                                     Repository                                     Size
    =======================================================================================================================================================================================
    Installing:
     mysql-community-server                             x86_64                             5.7.21-1.el7                                mysql57-community                             164 M
    
    Transaction Summary
    =======================================================================================================================================================================================
    Install  1 Package
    
    Total download size: 164 M
    Installed size: 740 M
    Is this ok [y/d/N]: y
    Downloading packages:
    mysql-community-server-5.7.21-1.el7.x86_64.rpm                                                                                                                  | 164 MB  00:01:01     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : mysql-community-server-5.7.21-1.el7.x86_64                                                                                                                          1/1 
      Verifying  : mysql-community-server-5.7.21-1.el7.x86_64                                                                                                                          1/1 
    
    Installed:
      mysql-community-server.x86_64 0:5.7.21-1.el7                                                                                                                                         
    
    Complete!

    所有安装的mysql rpm文件

    mysql57-community-release-el7-11.noarch.rpm
    
    mysql-community-client-5.7.21-1.el7.x86_64  
    mysql-community-common-5.7.21-1.el7.x86_64                                                                                                                          1/5 
    mysql-community-libs-5.7.21-1.el7.x86_64                                                                                                                            2/5                                                                                                         3/5 
    mysql-community-libs-compat-5.7.21-1.el7.x86_64 
    
    mysql-community-server-5.7.21-1.el7.x86_64

    查看依赖的lib库是否安装全了

    # ldd /sbin/mysqld
        linux-vdso.so.1 =>  (0x00007ffc102f5000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fea7784b000)
        libaio.so.1 => /lib64/libaio.so.1 (0x00007fea77649000)
        libnuma.so.1 => /lib64/libnuma.so.1 (0x00007fea7743c000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fea77205000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fea77001000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fea76df8000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fea76af0000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fea767ee000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fea765d7000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fea76214000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fea77a6f000)
        libfreebl3.so => /lib64/libfreebl3.so (0x00007fea76011000)

    初始化并启动mysql

    # systemctl status mysqld.service
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: inactive (dead)
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
    # cat /usr/lib/systemd/system/mysqld.service
    
    # Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; version 2 of the License.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    #
    # systemd service file for MySQL forking server
    #
    
    [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
    
    Type=forking
    
    PIDFile=/var/run/mysqld/mysqld.pid
    
    # Disable service start and stop timeout logic of systemd for mysqld service.
    TimeoutSec=0
    
    # Execute pre and post scripts as root
    PermissionsStartOnly=true
    
    # Needed to create system tables
    ExecStartPre=/usr/bin/mysqld_pre_systemd
    
    # Start main service
    ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS
    
    # Use this to switch malloc implementation
    EnvironmentFile=-/etc/sysconfig/mysql
    
    # Sets open_files_limit
    LimitNOFILE = 5000
    
    Restart=on-failure
    
    RestartPreventExitStatus=1
    
    PrivateTmp=false
    # systemctl start mysqld.service 
    Mar 26 11:28:37 mysql-18-235 mysqld_pre_systemd: 2018-03-26T03:28:37.692515Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

    –explicit_defaults_for_timestamp
    在MySQL 5.6.6及以后的版本和MySQL 5.7之前的版本中,如果在配置文件中没有指定explicit_defaults_for_timestamp参数,启动时error日志中会报如下警告:

    [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

    注意观察日志
    /var/log/messages
    /var/log/mysqld.log

    # vi /etc/my.cnf
    explicit_defaults_for_timestamp=1

    修改密码策略,测试环境,不需要那么严格

    # vi /etc/my.cnf
    validate_password_length=4          
    validate_password_mixed_case_count=0
    validate_password_number_count=0
    validate_password_policy=0
    validate_password_special_char_count=0

    修改密码

    set password for 'root'@'localhost'= password('TE3edc4rfv@');

    创建用户

    create user 'usr_abc'@'%.%.%.%' identified by 'usr_abc';
    select host,user,authentication_string
    from mysql.user
    where 1=1
    order by user,host
    ;

    查看错误信息

    # perror 24
    OS error code  24:  Too many open files
  • 相关阅读:
    ExcelManager基于.Net的Excel读写管理类库(二)
    ExcelManager基于.Net的Excel读写管理类库(一)
    NHibernate初探!
    也谈软件工程!
    本人初学WCF ,请教一个问题
    初来咋到,今天终于在这里建起了一个家!
    c#中委托和直接函数调用用什么区别,好处和目的在哪?
    CreateThread, AfxBeginThread,_beginthread, _beginthreadex的区别
    C++线程同步
    C++中using的作用
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9793033.html
Copyright © 2020-2023  润新知