linux下一键编译安装MariaDB10.0.12

虽然网上有很多的lnmp一键安装包,可以直接安装集成环境。

但是有时候我们需要单独的安装mariadb,则可以使用下面的脚本来安装。

# 一键CMAKE编译安装mariadb-10.0.12

# 安装到/usr/local/mariadb

# 数据目录为/data/mysql

# my.cnf文件是我自己修改的

一键安装包的文件目录结构如下:

我们只要自己将下面的文件组合成上图的结构,执行sh install.sh脚本即可完成安装。

install.sh脚本内容如下:

#!/bin/bash

# Date: 2016/08/03

# Author: Lee

# 一键CMAKE编译安装mariadb-10.0.12

# 安装到/usr/local/mariadb

# 数据目录为/data/mysql

# my.cnf文件是我自己修改的

echo -e "\033[32m即将安装MariaDB到 /usr/local \033[0m"

echo -e "\033[32m数据目录为/data/mysql,请确保有足够的空间存放数据\033[0m"

echo -e "\033[31m你有10秒钟的时间取消该操作(按ctrl+c取消)\033[0m"

echo

sleep 10

if [ ! -f src/mariadb-10.0.12.tar.gz ];then

echo -e "\033[31m不存在mariadb-10.0.12包.Quit\033[0m"

exit

fi

tar xf src/mariadb-10.0.12.tar.gz -C src/

cd src/mariadb-10.0.12

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \

-DSYSCONFDIR=/etc \

-DWITH_ARIA_STORAGE_ENGINE=1 \

-DWITH_XTRADB_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_READLINE=1 \

-DWITH_SSL=bundled \

-DWITH_ZLIB=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1

make && make install

groupadd mariadb

useradd -r -s /sbin/nologin -g mariadb mariadb

chown mariadb.mariadb /usr/local/mariadb -R

cp /usr/local/mariadb/support-files/mysql.server /etc/init.d/mariadb

chmod +x /etc/init.d/mariadb

\cp ../../my.cnf /etc/my.cnf

mkdir /data/mysql -p

chown mariadb.mariadb /data/mysql -R

/usr/local/mariadb/scripts/mysql_install_db --user=mariadb --basedir=/usr/local/mariadb --datadir=/data/mysql

/etc/init.d/mariadb start

if ss -lnt|grep 3306 --color=auto ;then

echo -e "\033[32mMariaDB已启动.\n默认server-id为1. \033[0m"

echo -e "\033[31m在主从或主主复制环境下请修改server-id并重启MariaDB!!\033[0m"

fi

优化后的my.cnf配置文件:

[client]

user = root

#password   = your_password

port        = 3306

socket      = /tmp/mysql.sock

[mysql]

default_character_set = utf8

prompt = [\d] >

[mysqld]

####basic####

user = mariadb

port  = 3306

socket  = /tmp/mysql.sock

datadir = /data/mysql/

basedir = /usr/local/mariadb/

pid_file = /var/run/mysql.pid

default_storage_engine = InnoDB

wait_timeout = 28800

interactive_timeout = 28800

# others setting

skip_name_resolve = ON

skip_external_locking

character-set-server = utf8

# Timeout

connect_timeout = 20

wait_timeout = 14400

interactive_timeout = 14400

back_log = 500

myisam_recover

event_scheduler = ON

# Query Cache Setting

query_cache_type = OFF

query_cache_size = 0

# LOG Settings

server-id = 1

log-bin = mysql.bin

binlog_format = mixed

max_binlog_size = 1G

expire_logs_days = 10

binlog_cache_size = 8M

slow_query_log = ON

slow_query_log_file = /data/mysql/localhost_slow.log

long_query_time = 5

log_error = /data/mysql/localhost.error

log_warnings = 2

tmp_table_size = 32M

max_heap_table_size = 32M

max_connections = 1000

max_allowed_packet = 50M

thread_cache_size = 300

open_files_limit = 65535

# 建议设置的比Open_tables大一倍

table_open_cache = 4096

# InnoDB Optimize

innodb_file_per_table = ON

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 32M

# innodb_buffer_pool_size官方建议设置为内存大小的50%~80%

innodb_buffer_pool_size = 4G

# 事务日志文件的大小

innodb_log_file_size = 512M

# Innodb共享表空间的大小

innodb_data_file_path = ibdata1:1G:autoextend:max:2G

innodb_buffer_pool_instances = 8

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_buffer_pool_dump_at_shutdown = ON

innodb_buffer_pool_load_at_startup = ON

[mysqldump]

quick

max_allowed_packet = 48M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

时间: 2024-10-08 10:31:42

linux下一键编译安装MariaDB10.0.12的相关文章

源码编译安装mariadb-10.0.12数据库

源码安装mariadb-10.0.12 1.获取源码包 mariadb-10.0.12.tar.gz 2.编译环境准备 # yum groupinstall -y Development Tools # yum install -y ncurses-devel openssl-devel openssl 3.创建mysql用户 # groupadd mysql # useradd -s /sbin/nologin -g mysql -M mysql # id mysql uid=500(mysq

linux 下手动编译安装无线网卡驱动

//先参照 <本地yum源安装GCC >安装好gcc hp的笔记本上安装了CentOS6.3,没有安装无线网卡驱动,安装这个驱动,在Google上找了好多资料,最后终于解决了这个问题.在这里做点记录,希望也能帮到别人. 我的机子是32位,CentOS的内核版本是2.6.32-279.19.1.el6.i686,下载的无线网卡驱动是hybrid-portsrc_x86_32-v5_100_82_112.tar.gz 下面是具体的步骤 一:确定无线网卡的型号,驱动下载 第一步要确定机子的无线网卡型

Linux下nginx编译安装教程和编译参数详解

这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # yum install pcre* //如过你已经装了,请跳过这一步 2.安装openssl 需要ssl的支持,如果不需要ssl支持,请跳过这一步 复制代码代码如下: # yum install openssl* 3.gzip 类库安装 复制代码代码如下: yum install zlib zlib-

CentOS7.3编译安装MariaDB10.2.12

在CentOS7.3编译安装MariaDB10.2.12详细教程 1. 删除CentOS7.3默认数据库配置文件 查看默认数据库配置文件 [[email protected] ~]# 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 删除默

图解Linux下源码安装PHP7.0.9 +Nginx

上一次,在<Linux下源码安装php7.0.6>,安装过PHP7.0.3,本文将记录安装PHP7.0.9过程. 测试环境 Linux 2.6.32-279.el6.i686 nginx-1.9.15.tar http://nginx.org/download/nginx-1.9.15.tar.gz php-7.0.9.tar.gz http://am1.php.net/distributions/php-7.0.9.tar.gz 安装Nginx wget http://nginx.org/d

CentOS安装mariadb-10.0.12和php-5.5.15

1: yum install cmake make ncurses-devel gcc-c++ bison 2: cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 3: yum install wget make gcc gcc-c++ bison autoconf patch pcre-devel zlib-devel openssl-devel net-snmp-devel ncurses-devel libxml2-devel bzip2-deve

Linux Centos7.2 编译安装PHP7.0.2

操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz $ tar -zxvf php-7.0.2.tar.gz $ cd php-7.0.2 1.1 编译前检查 请检查是否安装了gcc ,没有的话执行yum install gcc 检查是否安装了libxml2 ,没有的话执行yum insta

一键编译安装Redis-4.0.14,实现systemctl启动

一键编译安装脚本如下: yum ×××tall gcc jemalloc-devel wget -y &>/dev/null #初始化安装环境 cd /usr/local/src/ wget http://download.redis.io/releases/redis-4.0.14.tar.gz &>/dev/null tar xvf redis-4.0.14.tar.gz cd redis-4.0.14/deps/ make hiredis jemalloc linenoi

编译安装MariaDB-10.0.21

一.源码编译安装gcc-5.1.0 1.下载gcc源码包 Download (HTTP): http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2 Download (FTP): ftp://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2 2.解压压缩包 1 [[email protected] ~]# tar -xf  gcc-5.1.0.tar.gz 3.下载编译所需的依赖包 这个步骤有