編譯安裝和二進制安裝需要重新編寫systemctl文件,yum安裝不需要,同時幫助文件也需要重新壓縮。
1.安裝準備
[root@master soft]# mkdir /share/mariadb/{data,log,etc} /share/{boost,cmake,boost} -pv
[root@master soft]# yum install -y bison bison-devel boost-devel centos-release-scl cmake devtoolset-7 gcc gcc-c++ gnutls-devel jemalloc jemalloc-devel libaio-devel libarchive-devel libcurl-devel libevent-devel libxml2-devel ncurses ncurses-devel openssl openssl-devel zlib-devel
cmake install if install require
[root@master soft]# tar xvf cmake-3.11.1.tar.gz #建議是3.0以上
[root@master soft]# cd cmake-3.11.1/
[root@master cmake-3.11.1]# ./configure --prefix=/share/cmake/ && gmake && make install
boost install. if install require
[root@master soft]# tar xf boost_1_67_0.tar.gz
[root@master soft]# cd boost_1_67_0/
[root@master boost_1_67_0]# ls
boost boostcpp.jam boost.png bootstrap.sh index.htm INSTALL libs more status
boost-build.jam boost.css bootstrap.bat doc index.html Jamroot LICENSE_1_0.txt rst.css tools
[root@master boost_1_67_0]# ./bootstrap.sh
[root@master boost_1_67_0]# ./b2 --prefix=/share/boost #或者安裝包拷貝 也可以不安裝
openssl install. if install require
[root@master soft]# tar xf openssl-1.1.0g.tar.gz
[root@master soft]# mkdir /share/openssl
[root@master soft]# cd openssl-1.1.0g/
[root@master openssl-1.1.0g]# ./config --prefix=/share/openssl && make && make install
pcre install. if install require
[root@master soft]# tar xf pcre2-10.30.tar.gz
[root@master soft]# cd pcre2-10.30/
[root@master pcre2-10.30]# ls
[root@master pcre2-10.30]# ./configure --prefix=/share/pcre && make && make install
填加mariadb用戶,可加可不加
[root@master boost_1_67_0]# groupadd -r maridb && useradd -r -g maridb -s /bin/false -d /share/maridb/ -M maridb
2.yum安裝
配置yum源
#官網提供的yum源,不推薦使用
[root@master soft]# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash
[root@node2 yum.repos.d]# vim mariadb.repo
[mariadb-10.5]
name=mariadb-10.5
baseurl=http://yum.mariadb.org/10.5/centos/7/aarch64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck = 1
[mariadb-10.4]
name=mariadb-10.4
baseurl=http://yum.mariadb.org/10.4/centos/7/aarch64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck = 1
[mariadb-10.3]
name=mariadb-10.2
baseurl=http://yum.mariadb.org/10.3/centos/7/aarch64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck = 1
[mariadb-10.2]
name=mariadb-10.2
baseurl=http://yum.mariadb.org/10.2/centos/7/aarch64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck = 1
[mariadb-10.1]
name=mariadb-10.1
baseurl=http://yum.mariadb.org/10.1/centos/7/aarch64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck = 1
[mariadb-10.0]
name=mariadb-10.0
baseurl=http://yum.mariadb.org/10.0/centos/7/aarch64/
enabled=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1
[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/7Server/x86_64/
gpgcheck = 0
enabled = 1
[root@master soft]# yum install -y rh-mariadb103
[root@master soft]# yum install MariaDB-server MariaDB-client
3.編譯安裝
3.1 git源碼
[root@master soft]# git clone https://github.com/MariaDB/server.git
[root@master soft]# cd server/
[root@master server]# ls
appveyor.yml config.h.cmake debian INSTALL-WIN-SOURCE mysql-test scripts support-files vio
BUILD configure.cmake Docs KNOWN_BUGS.txt mysys sql tests win
BUILD-CMAKE CONTRIBUTING.md EXCEPTIONS-CLIENT libmariadb mysys_ssl sql-bench THIRDPARTY wsrep-lib
client COPYING extra libmysqld plugin sql-common tpool zlib
cmake CREDITS include libservices randgen storage unittest
CMakeLists.txt dbug INSTALL-SOURCE man README.md strings VERSION
3.2 make源碼
[root@master soft]# cmake -version
cmake version 2.8.12.2
[root@master soft]# /share/cmake/bin/cmake -version
cmake version 3.11.1
[root@master server]# /share/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/share/mariadb -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNODB_MEMCACHED=ON -DWITH_SSL=system -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT="zsd edition" -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp -DMYSQL_UNIX_ADDR=/share/mariadb/data/mysql.sock -DFORCE_INSOURCE_BUILD=1 -DSYSCONFDIR=/share/mariadb/data -DWITH_PCRE=/share/pcre -DWITH_SSL=/share/openssl && make -j 12 && make install
安裝期間,會出現現在pcre2的壓縮包的問題,需要手動下載,並複製到安裝目錄中。
[root@master soft]# wget https://ftp.pcre.org/pub/pcre/pcre2-10.34.zip
[root@master soft]# cp pcre2-10.34.zip /share/soft/server/extra/pcre2/src/
cp: overwrite ‘/share/soft/server/extra/pcre2/src/pcre2-10.34.zip’? y
3.3 修改配置文件
[root@master bin]# vim /etc/my.cnf
[mysqld]
datadir=/share/data/mariadb
port=3306
skip_name_resolve=on
innodb_file_per_table=on
socket=/tmp/mysql.sock #mysql和mysqld要設置一樣的sock
[mysql]
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
3.4 添加環境變量
[root@master ~]# echo 'export MARIADB_HOME=/share/mariadb' >> /etc/profile
[root@master ~]# echo 'export PATH=$MARIADB_HOME/bin:$PATH' >> /etc/profile
[root@master ~]# echo 'export MARIADB_HOME=/share/mariadb' >> ~/.bashrc
[root@master ~]# echo 'export PATH=$MARIADB_HOME/bin:$PATH' >> ~/.bashrc
3.5 更改目錄權限
[root@master ~]# chown -R maridb:mairdb /share/mariadb
[root@master ~]# chown -R maridb:mairdb /share/data/mariadb
3.6 初始化數據庫
[root@master mariadb]# ./scripts/mariadb-install-db
Installing MariaDB/MySQL system tables in '/share/data/mariadb' ...
..................
3.7 驗證安裝
[root@master mariadb]# mysqld
2020-02-23 23:42:02 0 [Note] mysqld (mysqld 10.5.2-MariaDB) starting as process 11615 ...
mysqld: Please consult the Knowledge Base to find out how to run mysqld as root!
2020-02-23 23:42:02 0 [ERROR] Aborting
[root@master mariadb]# mysqld -uroot
2020-02-23 23:49:26 0 [Note] mysqld (mysqld 10.5.2-MariaDB) starting as process 12063 ...
2020-02-23 23:49:26 0 [Note] InnoDB: Using Linux native AIO
.....................
2020-02-23 23:49:26 0 [Note] mysqld: ready for connections.
Version: '10.5.2-MariaDB' socket: '/tmp/mysql.sock' port: 3306 zsd edition
[root@master bin]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.2-MariaDB zsd edition
4.二進制安裝
與源碼安裝雷同,缺少編譯源碼環節
5.編寫啓動文件
————Blueicex 2020/2/24 02:52 [email protected]