zoukankan      html  css  js  c++  java
  • CentOS7.3编译安装MariaDB10.2.6

    1. 删除CentOS7.3默认数据库配置文件

    
    	[root@localhost ~]# find -H /etc/ | grep my.c
    	/etc/pki/tls/certs/make-dummy-cert
    	/etc/pki/tls/certs/renew-dummy-cert
    	/etc/my.cnf.d
    	/etc/my.cnf.d/mysql-clients.cnf
    	/etc/my.cnf
    
    	[root@localhost ~]# rm -rf /etc/my.cnf /etc/my.cnf.d/
    	[root@localhost ~]# find -H /etc/ | grep my.c
    	/etc/pki/tls/certs/make-dummy-cert
    	/etc/pki/tls/certs/renew-dummy-cert
    
    

    2. 卸载系统自带mariadb-libs

    • 查询
    
    	[root@localhost ~]# rpm -qa|grep mariadb-libs
    
    
    
    	mariadb-libs-5.5.52-1.el7.x86_64
    
    
    • 卸载
    
    	[root@localhost ~]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps
    
    
    

    安装相关包

    
    	[root@localhost ~]# yum -y install libaio 
    	[root@localhost ~]# yum -y install libaio-devel 
    	[root@localhost ~]# yum -y install bison 
    	[root@localhost ~]# yum -y install bison-devel 
    	[root@localhost ~]# yum -y install zlib-devel 
    	[root@localhost ~]# yum -y install openssl
    	[root@localhost ~]# yum -y install openssl-devel 
    	[root@localhost ~]# yum -y install ncurses 
    	[root@localhost ~]# yum -y install ncurses-devel
    	[root@localhost ~]# yum -y install libcurl-devel
    	[root@localhost ~]# yum -y install libarchive-devel 
    	[root@localhost ~]# yum -y install boost 
    	[root@localhost ~]# yum -y install boost-devel 
    	[root@localhost ~]# yum -y install lsof 
    	[root@localhost ~]# yum -y install wget
    	[root@localhost ~]# yum -y install gcc 
    	[root@localhost ~]# yum -y install gcc-c++
    	[root@localhost ~]# yum -y install make
    	[root@localhost ~]# yum -y install cmake
    	[root@localhost ~]# yum -y install perl
    	[root@localhost ~]# yum -y install kernel-headers
    	[root@localhost ~]# yum -y install kernel-devel 
    	[root@localhost ~]# yum -y install pcre-devel
    
    

    3. 创建家目录存放软件包目录

    
    	[root@localhost ~]# mkdir soft
    
    	[root@localhost ~]# cd soft
    
    

    4. MariaDB官网复制源码包链接地址并下载解压

    
    	[root@localhost soft]# wget https://downloads.mariadb.org/interstitial/mariadb-10.2.6/source/mariadb-10.2.6.tar.gz
    
    	[root@localhost soft]# ll
    	total 66016
    	-rw-r--r--. 1 root root 67599197 May 14 19:13 mariadb-10.2.6.tar.gz
    
    	[root@localhost soft]# tar -zxvf mariadb-10.2.6.tar.gz
    
    
    

    5. 创建MariaDB安装目录、数据库存放目录、建立用户和目录

    这里提前预定MariaDB的安装目录为/usr/local/mysql并且数据目录为/data/mysql,这里要建立用户和目录,并且赋予maria用户权限,操作如下:

    
    	> 添加用户组 mysql
    
    	[root@localhost soft]# groupadd -r mysql
    
    	> 添加用户到组 mysql 并且可以在不登录的情况下使用
    
    	[root@localhost soft]# useradd -g mysql -s /sbin/nologin mysql
    
    	> 创建maria安装目录
    
    	[root@localhost soft]# mkdir -p /usr/local/mysql
    
    	> 创建数据库存放目录
    
    	[root@localhost soft]# mkdir -p /data/mysql
    
    	> 改变数据库存放目录所属组为 mysql:mysql
    	
    	[root@localhost soft]# chown -R mysql:mysql /data/mysql
    
    

    执行编译安装

    
    	> 进入到解压后的源码包文件夹
    
    	[root@localhost soft]# cd mariadb-10.2.6
    
    	> 输入编译参数
    
    	cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    	 -DMYSQL_DATADIR=/data/mysql 
    	 -DSYSCONFDIR=/etc 
    	 -DWITHOUT_TOKUDB=1 
    	 -DWITH_INNOBASE_STORAGE_ENGINE=1 
    	 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 
    	 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    	 -DWIYH_READLINE=1 
    	 -DWIYH_SSL=system 
    	 -DVITH_ZLIB=system 
    	 -DWITH_LOBWRAP=0 
    	 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
    	 -DDEFAULT_CHARSET=utf8 
    	 -DDEFAULT_COLLATION=utf8_general_ci
    
    	> 如果编译失败请删除CMakeCache.txt
    
    	[root@localhost soft]# rm -f CMakeCache.txt
    
    	> 让指令重新执行,否则每次读取这个文件,命令修改正确也是报错
    
    	> cmake没问题,可以编译并且安装了: make && make install 时间会有点长根据个人机器吧,你可以干别的事情去!
    
    	[root@localhost soft]# make && make install
    
    	> 执行完成也就是安装完成了, 不过请注意, 这只是安装了, 并没有启动, 启动不成功等于没安装, 不能用也是徒劳无功不是?
    
    

    6. 配置MariaDB

    	
    	> 进行到 maria 安装目录
    	
    	[root@localhost ~]# cd /usr/local/mysql/
    
    	> 使用maria用户执行脚本, 安装数据库到数据库存放目录
    
    	[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
    
    	> 输入以下信息:
    
    	[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
    	Installing MariaDB/MySQL system tables in '/data/maria' ...
    	OK
    
    	To start mysqld at boot time you have to copy
    	support-files/mysql.server to the right place for your system
    
    	PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
    	To do so, start the server, then issue the following commands:
    
    	'./bin/mysqladmin' -u root password 'new-password'
    	'./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
    
    	Alternatively you can run:
    	'./bin/mysql_secure_installation'
    
    	which will also give you the option of removing the test
    	databases and anonymous user created by default.  This is
    	strongly recommended for production servers.
    
    	See the MariaDB Knowledgebase at http://mariadb.com/kb or the
    	MySQL manual for more instructions.
    
    	You can start the MariaDB daemon with:
    	cd '.' ; ./bin/mysqld_safe --datadir='/data/maria'
    
    	You can test the MariaDB daemon with mysql-test-run.pl
    	cd './mysql-test' ; perl mysql-test-run.pl
    
    	Please report any problems at http://mariadb.org/jira
    
    	The latest information about MariaDB is available at http://mariadb.org/.
    	You can find additional information about the MySQL part at:
    	http://dev.mysql.com
    	Consider joining MariaDB's strong and vibrant community:
    	https://mariadb.org/get-involved/
    
    
    

    6. 复制maria配置文件到/etc目录

    
    	> 进行到 maria 安装目录
    	
    	[root@localhost ~]# cd /usr/local/maria/
    
    	> 拷贝support-files目录下的文件my-large.cnf到/etc目录并重命名为my.cnf
    
    	[root@localhost maria]# cp support-files/my-large.cnf /etc/my.cnf
    
    

    7. 创建启动脚本

    
    	[root@localhost maria]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
    
    

    8. 启动mysqld服务

    
    	[root@localhost maria]# /etc/rc.d/init.d/mysqld start
    
    

    9. 配置环境变量, 以便在任何目录下输入mysql

    	
    	> 打开并新建文件
    
    	[root@localhost maria]# vim /etc/profile.d/mysql.sh
    
    	> 输入以下内容
    
    	export PATH=$PATH:/usr/local/maria/bin/
    
    	> 保存并退出
    
    	:wq
    
    	> 为脚本赋于可执行权限
    
    	[root@localhost maria]# chmod 0777 /etc/profile.d/mysql.sh
    
    	> 进行mysql.sh脚本所在目录, 并执行脚本, 以立即生效环境变量
    
    	[root@localhost maria]# source /etc/profile.d/mysql.sh
    
    

    10. 初始化MariaDB

    	
    	> 运行MariaDB初始化脚本
    
    	[root@localhost mysql]# ./bin/mysql_secure_installation
    
    	> 以下提示:
    
    	Enter current password for root (enter for none): 	输入当前root密码(没有输入)
    
    	Set root password? [Y/n] 	设置root密码?(是/否)
    
    	New password:	输入新root密码
    
    	Re-enter new password:		确认输入root密码
    
    	Password updated successfully! 		密码更新成功
    
    	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.
    
    	默认情况下,MariaDB安装有一个匿名用户,
    	允许任何人登录MariaDB而他们无需创建用户帐户。
    	这个目的是只用于测试,安装去更平缓一些。
    	你应该进入前删除它们生产环境。
    
    	Remove anonymous users? [Y/n] 		删除匿名用户?(是/否)
    
    	Normally, root should only be allowed to connect from 'localhost'.  This
    	ensures that someone cannot guess at the root password from the network.
    
    	通常情况下,root只应允许从localhost连接。
    	这确保其他用户无法从网络猜测root密码。
    
    	Disallow root login remotely? [Y/n] 	不允许root登录远程?(是/否)
    
    	By default, MariaDB comes with a database named 'test' that anyone can
    	access.  This is also intended only for testing, and should be removed
    	before moving into a production environment.
    
    	默认情况下,MariaDB提供了一个名为“测试”的数据库,任何人都可以访问。
    	这也只用于测试,在进入生产环境之前应该被删除。
    
    	Reloading the privilege tables will ensure that all changes made so far
    	will take effect immediately.
    
    	重新加载权限表将确保所有到目前为止所做的更改将立即生效。
    
    	Reload privilege tables now? [Y/n]  	现在重新加载权限表(是/否)
    
    	All done!  If you've completed all of the above steps, your MariaDB
    	installation should now be secure.
    	
    	全部完成!如果你已经完成了以上步骤,MariaDB安装现在应该安全。
    
    	Thanks for using MariaDB!
    
    	感谢使用MariaDB!
    
    

    编译安装MariaDB后所有配置

    
    	Last login: Sun Jun 11 13:50:59 2017 from 192.168.1.101
    	[root@localhost ~]# rm -rf /etc/my.cnf /etc/my.cnf.d/
    	[root@localhost ~]# cd /usr/local/mysql/
    	[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
    	Installing MariaDB/MySQL system tables in '/data/mysql/' ...
    	OK
    
    	To start mysqld at boot time you have to copy
    	support-files/mysql.server to the right place for your system
    
    	PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
    	To do so, start the server, then issue the following commands:
    
    	'./bin/mysqladmin' -u root password 'new-password'
    	'./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
    
    	Alternatively you can run:
    	'./bin/mysql_secure_installation'
    
    	which will also give you the option of removing the test
    	databases and anonymous user created by default.  This is
    	strongly recommended for production servers.
    
    	See the MariaDB Knowledgebase at http://mariadb.com/kb or the
    	MySQL manual for more instructions.
    
    	You can start the MariaDB daemon with:
    	cd '.' ; ./bin/mysqld_safe --datadir='/data/mysql/'
    
    	You can test the MariaDB daemon with mysql-test-run.pl
    	cd './mysql-test' ; perl mysql-test-run.pl
    
    	Please report any problems at http://mariadb.org/jira
    
    	The latest information about MariaDB is available at http://mariadb.org/.
    	You can find additional information about the MySQL part at:
    	http://dev.mysql.com
    	Consider joining MariaDB's strong and vibrant community:
    	https://mariadb.org/get-involved/
    
    	[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf
    	[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
    	[root@localhost mysql]# /etc/rc.d/init.d/mysqld start
    	Reloading systemd:                                         [  OK  ]
    	Starting mysqld (via systemctl):                           [  OK  ]
    	[root@localhost mysql]# vim /etc/profile.d/mysql.sh
    	[root@localhost mysql]# touch /etc/profile.d/mysql.sh
    	[root@localhost mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin/' > /etc/profile.d/mysql.sh 
    	[root@localhost mysql]# chmod 0777 /etc/profile
    	profile    profile.d/ 
    	[root@localhost mysql]# chmod 0777 /etc/profile.d/mysql.sh 
    	[root@localhost mysql]# source /etc/profile.d/mysql.sh 
    	[root@localhost mysql]# mysql
    	Welcome to the MariaDB monitor.  Commands end with ; or g.
    	Your MariaDB connection id is 10
    	Server version: 10.2.6-MariaDB-log Source distribution
    
    	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)]> 
    
    
  • 相关阅读:
    Linux Hung Task分析
    Linux内存都去哪了:(1)分析memblock在启动过程中对内存的影响
    《Linux/UNIX系统编程手册》第63章 IO多路复用、信号驱动IO以及epoll
    Linux内核和用户空间通信之netlink
    Linux soft lockup分析
    一款DMA性能优化记录:异步传输和指定实时信号做async IO
    Linux下时钟框架实践---一款芯片的时钟树配置
    使用Kernel NetEm和tc模拟复杂网络环境
    使用Flame Graph进行系统性能分析
    sigsuspend()阻塞:异步信号SIGIO为什么会被截胡?
  • 原文地址:https://www.cnblogs.com/warnerwu/p/7020542.html
Copyright © 2011-2022 走看看