next up previous contents
Next: 第一次使用 Up: 安裝與配置 Mariadb Previous: 安裝與配置 Mariadb   Contents   DYWANG_HOME

建立使用環境

  1. 遠端登入 kvm8.deyu.wang 虛擬機。
    [root@dyw219 ~]# ssh root@kvm8.deyu.wang
    root@kvm8.deyu.wang's password: 
    Last login: Mon Jan  6 09:45:29 2020 from 192.168.122.1
    [root@kvm8 ~]#
    
  2. 安裝 mariadb-server。
    [root@kvm8 ~]# yum -y install mariadb-server
    
  3. 設定開機自動啟動 mariadb 服務,且馬上啟動。
    [root@kvm8 ~]# systemctl enable --now mariadb.service 
    Created symlink /etc/systemd/system/mysql.service →
     /usr/lib/systemd/system/mariadb.service.
    Created symlink /etc/systemd/system/mysqld.service →
     /usr/lib/systemd/system/mariadb.service.
    Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service →
     /usr/lib/systemd/system/mariadb.service.
    
  4. 查看 mariadb 服務狀態,雖然啟動成功,但有警告訊息:max_open_files 需要 4183。
    [root@kvm8 ~]# systemctl status mariadb.service 
    ● mariadb.service - MariaDB 10.3 database server
       Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
       Active: active (running) since Fri 2020-01-24 20:36:16 CST; 1min 40s ago
         Docs: man:mysqld(8)
               https://mariadb.com/kb/en/library/systemd/
      Process: 16772 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
      Process: 16638 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
      Process: 16614 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
     Main PID: 16740 (mysqld)
       Status: "Taking your SQL requests now..."
        Tasks: 30 (limit: 11520)
       Memory: 83.2M
       CGroup: /system.slice/mariadb.service
               └─16740 /usr/libexec/mysqld --basedir=/usr
    
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     Please report any problems at http://mariadb.org/jira
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     The latest information about MariaDB is available at http://mariadb.org/.
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     You can find additional information about the MySQL part at:
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     http://dev.mysql.com
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     Consider joining MariaDB's strong and vibrant community:
    Jan 24 20:36:15 kvm8.deyu.wang mysql-prepare-db-dir[16638]:
     https://mariadb.org/get-involved/
    Jan 24 20:36:15 kvm8.deyu.wang mysqld[16740]: 2020-01-24 20:36:15 0 
    [Note] /usr/libexec/mysqld (mysqld 10.3.11-MariaDB) starting as process 16740 ...
    Jan 24 20:36:15 kvm8.deyu.wang mysqld[16740]: 2020-01-24 20:36:15 0 
    [Warning] Could not increase number of max_open_files
     to more than 1024 (request: 4183)
    Jan 24 20:36:15 kvm8.deyu.wang mysqld[16740]: 2020-01-24 20:36:15 0 
    [Warning] Changed limits: max_open_files:
     1024  max_connections: 151 (was 151)  table_cache: 421 (was 2000)
    Jan 24 20:36:16 kvm8.deyu.wang systemd[1]: Started MariaDB 10.3 database server.
    
  5. 在 mariadb.service 的 service 段落中加入 LimitNOFILE=10000
    [root@kvm8 ~]# vim /etc/systemd/system/multi-user.target.wants/mariadb.service 
    [root@kvm8 ~]# grep -B1 ^LimitNOFILE /etc/systemd/system/multi-user.target.wants/mariadb.service 
    [Service]
    LimitNOFILE=10000
    
  6. 因為 mariadb.service 變動了,所以必須重新載入。
    [root@kvm8 ~]# systemctl daemon-reload
    
  7. 重新啟動 mariadb.service。
    [root@kvm8 ~]# systemctl restart mariadb.service
    
  8. 查看 mariadb 版本。
    [root@kvm8 ~]# mysqladmin --version
    mysqladmin  Ver 9.1 Distrib 10.3.11-MariaDB, for Linux on x86_64
    
  9. 查看 mariadb port 為 3306。
    [root@kvm8 ~]# ss -ltpn | grep 3306
    LISTEN   0      80      *:3306     *:*      users:(("mysqld",pid=17174,fd=22))
    



De-Yu Wang 2020-04-07