设为首页 收藏本站
查看: 617|回复: 0

[经验分享] centos7.3二进制安装mariadb

[复制链接]

尚未签到

发表于 2018-4-21 07:51:33 | 显示全部楼层 |阅读模式
官网二进制mariadb很多配置使写死的。所以配置文件的位置请留意不要出错哦。如/usr/loacl/mysql等。


1.确认没有maraiadb*包

rpm -qa mariadb*查看无包即可,若有,用yum remove 包名卸载即可。
mariadb软件包官网下载即可。


2.创建系统用户。很多服务都会用到对应的服务帐户。由于我们是手动安装,这个帐户只好自己创建了。
useradd -d /app/mysqldb -r -m -s /sbin/nologin mysql
getent passwd mysql
建议放在逻辑卷上,数据库会不断变大,不能扩展的分区后期处理起来就麻烦多了。


3.解压
tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local
cd /usr/local
ln -sv mariadb-10.2.8-linux-x86_64 mysql v显示过程


4.准备配置文件
mkdir /etc/mysql

cp /usr/local/mysqlsupport-files/my-huge.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
下面意为[mysqld]行下加入如下三行。
[mysqld]
datadir = /app/mysqldb 必须加
innodb_file_per_table = on 每表为一独立文件
skip_name_resolve = on 性能优化,禁止主机名解析


5../scripts/mysql_install_db --user=mysql --datadir=/app/mysqldb 运行脚本,创建系统数据库
ls /app/mysqldb 有东西了
(可能有报错,根据报错提醒,逐一排错)
因为是二进制编译,有些配置文件的位置是设定好的,这点需注意。
[root@centos7 mysql]# ./scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
Installing MariaDB/MySQL system tables in '/app/mysqldb' ...
2017-10-11 20:08:53 140592457275200 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2017-10-11 20:08:55 140592457275200 [ERROR] ./bin/mysqld: unknown variable 'datedir=/app/mysqldb'
2017-10-11 20:08:55 140592457275200 [ERROR] Aborting

6.准备服务脚本,并启动服务
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --list mysqld
chkconfig --add mysqld
service mysqld start
下面是服务不能启动的情况
[root@centos7 mysql]# service mysqld start
Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]
[root@centos7 mysql]# systemctl status mysqld.service -l
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2017-10-11 20:20:27 CST; 3min 32s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 10519 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)
Oct 11 20:20:26 centos7.magedu.com systemd[1]: Starting LSB: start and stop MySQL...
Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: Starting MySQL.171011 20:20:26 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: 171011 20:20:26 mysqld_safe Starting mysqld daemon with databases from /app/mysqldb
Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: [133B blob data]
Oct 11 20:20:27 centos7.magedu.com mysqld[10519]: ERROR!
Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service: control process exited, code=exited status=1
Oct 11 20:20:27 centos7.magedu.com systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 11 20:20:27 centos7.magedu.com systemd[1]: Unit mysqld.service entered failed state.
Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service failed.可以看到缺少了日志文件,日志文件对于mysql数据库还是很重要的。有时出现任务进行一半意外中断的情况,日志可以快速排错。接下来我们创建日志文件。注意权限。权限不对会导致服务无法启动。

touch /var/log/mariadb/mariadb.log
chown mysql /var/log/mariadb/mariadb.log
chown mysql /var/log/mariadb
service mysqld start


7.安全初始化环境配置
主要包括PATH环境变量及安全环境。
[root@centos7 mysql]# vim /etc/profile.d/mysql.sh
PATH=/usr/local/mysql/bin/:$PATH
可以同时开一个终端测试.
A:
[root@centos7 bin]# cd /usr/local/mysql/bin
[root@centos7 bin]# ./mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):  
B:查看当前登录用户

[root@centos7 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.8-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)A:

[root@centos7 bin]# ./mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]B:

[root@centos7 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)设置完成后再以root身份登录就要执行mysql -uroot -p命令了。

  

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-449802-1-1.html 上篇帖子: centos7.3编译安装php 下篇帖子: Centos 6.8 配置DHCP服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表