解决centos7 中 使用mariadb 安装mysql不成功的问题,centos7mariadb
按照openstack官网的步骤安装openstack
Install and configure components¶
-
Install the packages:
# yum install mariadb mariadb-server python2-PyMySQL
-
Create and edit the
/etc/my.cnf.d/openstack.cnf
file and complete the following actions:-
Create a
[mysqld]
section, and set thebind-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¶
-
Start the database service and configure it to start when the system boots:
# systemctl enable mariadb.service # systemctl start mariadb.service
执行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