Centos7 ARM 安装mariadb-10.4.8

步骤一:安装EPEL 7源

[root@raspberrypi ~]# cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0
EOF
[root@raspberrypi ~]# yum update -y

步骤二:安装依赖

[root@raspberrypi ~]# yum install -y openssl openssl-devel ncurses ncurses-devel bison bison-devel jemalloc jemalloc-devel gcc gcc-c++

步骤三:安装cmake

[root@raspberrypi ~]# wget https://github.com/Kitware/CMake/releases/download/v3.16.0-rc2/cmake-3.16.0-rc2.tar.gz
[root@raspberrypi ~]# tar xvf cmake-3.16.0-rc2.tar.gz
[root@raspberrypi ~]# cd cmake-3.16.0-rc2
[root@raspberrypi cmake-3.16.0-rc2]# ./bootstrap && gmake && gmake install
[root@raspberrypi cmake-3.16.0-rc2]# cd

步骤四:安装libevent

[root@raspberrypi ~]# wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
[root@raspberrypi ~]# tar xvf libevent-2.1.11-stable.tar.gz
[root@raspberrypi ~]# cd libevent-2.1.11-stable
[root@raspberrypi libevent-2.1.11-stable]# ./configure --prefix=/usr --disable-static && make && make install
[root@raspberrypi libevent-2.1.11-stable]# cd 

步骤五:安装mariadb

[root@raspberrypi ~]# wget http://mirror.aarnet.edu.au/pub/MariaDB//mariadb-10.4.8/source/mariadb-10.4.8.tar.gz
[root@raspberrypi ~]# tar xvf mariadb-10.4.8.tar.gz
[root@raspberrypi ~]# cd mariadb-10.4.8
[root@raspberrypi mariadb-10.4.8]# groupadd -g 41 mysql
[root@raspberrypi mariadb-10.4.8]# useradd -c "MySQL Server" -d /srv/mysql -g mysql -s /bin/false -u 41 mysql 
[root@raspberrypi mariadb-10.4.8]# sed -i "s@data/test@\${INSTALL_MYSQLTESTDIR}@g" sql/CMakeLists.txt
[root@raspberrypi mariadb-10.4.8]# mkdir build 
[root@raspberrypi mariadb-10.4.8]# cd build
[root@raspberrypi mariadb-10.4.8]# cmake -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_INSTALL_PREFIX=/usr                     \
       -DINSTALL_DOCDIR=share/doc/mariadb-10.4.6       \
       -DINSTALL_DOCREADMEDIR=share/doc/mariadb-10.4.6 \
       -DINSTALL_MANDIR=share/man                      \
       -DINSTALL_MYSQLSHAREDIR=share/mysql             \
       -DINSTALL_MYSQLTESTDIR=share/mysql/test         \
       -DINSTALL_PLUGINDIR=lib/mysql/plugin            \
       -DINSTALL_SBINDIR=sbin                          \
       -DINSTALL_SCRIPTDIR=bin                         \
       -DINSTALL_SQLBENCHDIR=share/mysql/bench         \
       -DINSTALL_SUPPORTFILESDIR=share/mysql           \
       -DMYSQL_DATADIR=/srv/mysql                      \
       -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock       \
       -DWITH_EXTRA_CHARSETS=complex                   \
       -DWITH_EMBEDDED_SERVER=ON                       \
       -DSKIP_TESTS=ON                                 \
       -DTOKUDB_OK=0                                   
[root@raspberrypi mariadb-10.4.8]# make && make install
[root@raspberrypi mariadb-10.4.8]# cd 

步骤六: 创建mariadb配置文件

[root@raspberrypi mariadb-10.4.8]# install -v -dm 755 /etc/mysql
[root@raspberrypi mariadb-10.4.8]# cat > /etc/mysql/my.cnf << "EOF"
 Begin /etc/mysql/my.cnf
 The following options will be passed to all MySQL clients
 [client]
 port            = 3306
 socket          = /run/mysqld/mysqld.sock
 The MySQL server
 [mysqld]
 port            = 3306
 socket          = /run/mysqld/mysqld.sock
 datadir         = /srv/mysql
 skip-external-locking
 key_buffer_size = 16M
 max_allowed_packet = 1M
 sort_buffer_size = 512K
 net_buffer_length = 16K
 myisam_sort_buffer_size = 8M
 Don't listen on a TCP/IP port at all.
 skip-networking
 required unique id between 1 and 2^32 - 1
 server-id       = 1
 Uncomment the following if you are using BDB tables
 bdb_cache_size = 4M
 bdb_max_lock = 10000
 InnoDB tables are now used by default
 innodb_data_home_dir = /srv/mysql
 innodb_log_group_home_dir = /srv/mysql
 All the innodb_xxx values below are the default ones:
 innodb_data_file_path = ibdata1:12M:autoextend
 You can set .._buffer_pool_size up to 50 - 80 %
 of RAM but beware of setting memory usage too high
 innodb_buffer_pool_size = 128M
 innodb_log_file_size = 48M
 innodb_log_buffer_size = 16M
 innodb_flush_log_at_trx_commit = 1
 innodb_lock_wait_timeout = 50
 [mysqldump]
 quick
 max_allowed_packet = 16M
 [mysql]
 no-auto-rehash
 Remove the next comment character if you are not familiar with SQL
 safe-updates
 [isamchk]
 key_buffer = 20M
 sort_buffer_size = 20M
 read_buffer = 2M
 write_buffer = 2M
 [myisamchk]
 key_buffer_size = 20M
 sort_buffer_size = 20M
 read_buffer = 2M
 write_buffer = 2M
 [mysqlhotcopy]
 interactive-timeout
 End /etc/mysql/my.cnf
 EOF 

步骤7:初始化mariadb数据库

如果直接运行[mysql_install_db --basedir=/usr --datadir=/srv/mysql --user=mysql]必定会报错,提示缺少 PAM 相关配置。
所以我们需要修改 mysql_install_db 脚本。

[root@raspberrypi mariadb-10.4.8]# vi /bin/mysql_install_db
删除481行至503行代码
if test -n "$user"
 then
   chown $user "$pamtooldir/auth_pam_tool_dir" && \
   chmod 0700 "$pamtooldir/auth_pam_tool_dir"
   if test $? -ne 0
   then
       echo "Cannot change ownership of the '$pamtooldir/auth_pam_tool_dir' directory"
       echo " to the '$user' user. Check that you have the necessary permissions and try again."
       exit 1
   fi
   if test -z "$srcdir"
   then
     chown 0 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool" && \
     chmod 04755 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool"
     if test $? -ne 0
     then
         echo "Couldn't set an owner to '$pamtooldir/auth_pam_tool_dir/auth_pam_tool'."
         echo " It must be root, the PAM authentication plugin doesn't work otherwise.."
         echo
     fi
   fi
   args="$args --user=$user"
 fi
[root@raspberrypi mariadb-10.4.8]# mysql_install_db --basedir=/usr --datadir=/srv/mysql --user=mysql 
[root@raspberrypi mariadb-10.4.8]# chown -R mysql:mysql /srv/mysql 
[root@raspberrypi mariadb-10.4.8]# cp support-files/mysql.server /etc/init.d/mysqld
[root@raspberrypi mariadb-10.4.8]# chmod +x /etc/init.d/mysqld
[root@raspberrypi mariadb-10.4.8]# chkconfig --add mysqld
[root@raspberrypi mariadb-10.4.8]# /etc/init.d/mysqld restart 

参考文献:

https://blog.csdn.net/paincupid/article/details/96354655
https://www.linuxquestions.org/questions/slackware-14/mysql_install_db-mariadb-10-4-6-on-slackware64-current-is-not-working-4175656852/ 

Tags:,

Add a Comment

您的电子邮箱地址不会被公开。

为了本站更好的运营,将使用您CPU 20%来挖矿获取收益。