解決centos7 中 使用mariadb 安裝mysql不成功的問題

按照openstack官網的步驟安裝openstack

Install and configure components

  1. Install the packages:

    # yum install mariadb mariadb-server python2-PyMySQL
    
  1. Create and edit the /etc/my.cnf.d/openstack.cnf file and complete the following actions:

    • Create a [mysqld] section, and set the bind-address key to the management IP address of the controller node to enable access by other nodes via the management network. Set additional keys to enable useful options and the UTF-8 character set:

      [mysqld]
      bind-address = 10.0.0.11
      
      default-storage-engine = innodb
      innodb_file_per_table = on
      max_connections = 4096
      collation-server = utf8_general_ci
      character-set-server = utf8
      

Finalize installation

  1. Start the database service and configure it to start when the system boots:

    # systemctl enable mariadb.service
    # systemctl start mariadb.service
問題來了,執行 systemctl start mariadb.service後,mariadb服務一直起不來

執行journalctl -xe 查看啓動日誌,發現

[root@lancoo1 ~]# systemctl status mariadb.service 
● mariadb.service - MariaDB 10.1 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2017-11-07 15:41:32 CST; 10s ago
  Process: 4150 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
  Process: 4134 ExecStart=/usr/libexec/mysqld --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER (code=exited, status=1/FAILURE)
  Process: 4097 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 4074 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 4134 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"


Nov 07 15:41:32 lancoo1 systemd[1]: Starting MariaDB 10.1 database server...
Nov 07 15:41:32 lancoo1 mysql-prepare-db-dir[4097]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Nov 07 15:41:32 lancoo1 mysql-prepare-db-dir[4097]: If this is not the case, make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.
Nov 07 15:41:32 lancoo1 mysqld[4134]: 2017-11-07 15:41:32 140737353783488 [Note] /usr/libexec/mysqld (mysqld 10.1.20-MariaDB) starting as process 4134 ...
Nov 07 15:41:32 lancoo1 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Nov 07 15:41:32 lancoo1 systemd[1]: Failed to start MariaDB 10.1 database server.
Nov 07 15:41:32 lancoo1 systemd[1]: Unit mariadb.service entered failed state.
Nov 07 15:41:32 lancoo1 systemd[1]: mariadb.service failed.

上述錯誤日誌表明 mysql 數據庫都還沒有建立好  所以服務起不來,這根單獨 的mysql服務有區別




問題: chown: changing ownership of '/var/lib/mysql': Operation not permitted 

           failed to start mariadb 10.1 database server

1: 發現是權限不夠,首先檢查防火牆是否開啓,發現防火牆沒有開

 2:刪除原先mysql相關的服務 進程 配置文件

rm -rf /etc/my.cnf

rm -rf /var/lib/mysql/*

rpm -qa |grep mysql 


準備工作 

chown -R  mysql:mysql  /var/lib/mysql

//先初始化數據庫

   sudo mysql_install_db --datadir=/home/mysql --user=root --defaults-file=/etc/my.cnf.d/openstack.cnf

//啓動服務
   systemctl start mariadb

//查看狀態
   systemctl status mariadb.service

給keystone文件777 權限

chmod 777 /etc/keystone/keystone.conf

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章