必威体育Betway必威体育官网
当前位置:首页 > IT技术

CentOS 7 下编译安装AliSQL

时间:2019-06-14 20:42:06来源:IT技术作者:seo实验室小编阅读:63次「手机版」
 

alisql

运行环境:centos 7.5 + alisql5.6.32-9版本
# cat /etc/redhat-release 
CentOS linux release 7.5.1804 (Core) 

下载软件:
# wget https://github.com/alibaba/alisql/archive/AliSQL-5.6.32-9.tar.gz
# du -sh AliSQL-5.6.32-9.tar.gz 
42M  AliSQL-5.6.32-9.tar.gz

编译安装的gcc和cmake版本要求( gcc >= 4.7, cmake >= 2.8)
安装基础的软件:
# yum install gcc gcc-c++ ncurses-devel perl  cmake bison zlib zlib-devel openssl-devel autoconf
...
Downloading packages:
Delta RPMs disabled because /usr/bin/APPlydeltarpm not installed.
(1/17): cmake-2.8.12.2-2.el7.x86_64.rpm                             | 7.1 MB  00:00:02     
(2/17): cpp-4.8.5-28.el7_5.1.x86_64.rpm                             | 5.9 MB  00:00:03     
(3/17): glibc-devel-2.17-222.el7.x86_64.rpm                         | 1.1 MB  00:00:00     
(4/17): gcc-c++-4.8.5-28.el7_5.1.x86_64.rpm                         | 7.2 MB  00:00:03     
(5/17): glibc-headers-2.17-222.el7.x86_64.rpm                       | 678 kB  00:00:00     
(6/17): libgcc-4.8.5-28.el7_5.1.x86_64.rpm                          | 101 kB  00:00:00     
(7/17): kernel-headers-3.10.0-862.11.6.el7.x86_64.rpm               | 7.1 MB  00:00:01     
(8/17): libgomp-4.8.5-28.el7_5.1.x86_64.rpm                         | 156 kB  00:00:00     
(9/17): libarchive-3.1.2-10.el7_2.x86_64.rpm                        | 318 kB  00:00:00     
(10/17): libstdc++-4.8.5-28.el7_5.1.x86_64.rpm                      | 303 kB  00:00:00     
(11/17): libmpc-1.0.1-3.el7.x86_64.rpm                              |  51 kB  00:00:00     
(12/17): libstdc++-devel-4.8.5-28.el7_5.1.x86_64.rpm                | 1.5 MB  00:00:00     
(13/17): mpfr-3.1.1-4.el7.x86_64.rpm                                | 203 kB  00:00:00     
(14/17): m4-1.4.16-10.el7.x86_64.rpm                                | 256 kB  00:00:00     
(15/17): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm             | 712 kB  00:00:00     
(16/17): bison-3.0.4-1.el7.x86_64.rpm                               | 674 kB  00:00:06     
(17/17): gcc-4.8.5-28.el7_5.1.x86_64.rpm                            |  16 MB  00:00:08     
-------------------------------------------------------------------------------------------
Total                                                      5.6 MB/s |  49 MB  00:00:08   
...



useradd -r -g mysql mysql
groupadd mysql 

[root@node1 ~]# useradd -r -g mysql mysql
useradd: user 'mysql' already exists
[root@node1 ~]# groupadd mysql
groupadd: group 'mysql' already exists
[root@node1 ~]# 
--解压文件:
#tar -xzvf AliSQL-5.6.32-9.tar.gz  -C /usr/local/
#mv /usr/local/AliSQL-AliSQL-5.6.32-9/ /usr/local/alisql
--创建目录:alisql的目录疑似指定了编译的目录/opt/alisql,指定为别的目录启动的时候报错。
mkdir -p /opt/alisql
chown -R mysql:mysql /opt/alisql

--获取cmake支持的选项:
# cmake . -LH
--实际编译的步骤:
# cd /usr/local/alisql
#
cmake .                              \
-DCMAKE_build_TYPE="Release"         \
-DCMAKE_INSTALL_PREFIX="/opt/alisql" \
-DWITH_EMBEDDED_SERVER=0             \
-DDEFAULT_CHARSET=utf8mb4   \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1       \
-DWITH_INNOBASE_STORAGE_ENGINE=1     \
-DWITH_PARTITION_STORAGE_ENGINE=1    \
-DWITH_CSV_STORAGE_ENGINE=1          \
-DWITH_ARCHIVE_STORAGE_ENGINE=1      \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1    \
-DWITH_FEDERATED_STORAGE_ENGINE=1    \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1   \
-DWITH_TOKUDB_STORAGE_ENGINE=1

--编译提示信息:
-- Generating done
-- Build files have been written to: /usr/local/alisql


make -j4 && make install
说明:
-j4 表示开 4 个并发编译进程,加速编译,根据机器 cpu 核数调整,一般是 CPU 核数 + 1,最终二进制安装在 /opt/alisql 目录下。
上述的编译安装耗时较久,视CPU的性能和资源而定。
 
 
创建数据目录并授权

mkdir -p /data/alisql
chown -R mysql:mysql /data/alisql
chmod -R 775 /data/alisql

 
准备工作:
1.设置
echo never > /sys/kernel/mm/transparent_hugepage/enabled ##开启TokuDB,不执行会提示:[ERROR] TokuDB: Huge pages are enabled, disable them before continuing
2.参数文件:
cp support-files/my-default.cnf /etc/my.cnf
这里参照alisql官方提供的即可。
[mysqld]
user = mysql
explicit_defaults_for_timestamp=true
socket =  /tmp/alisql.sock
datadir = /data/alisql
pid-file = /tmp/alisql.pid
tmpdir = /tmp
port = 3306
back_log = 3000
character_set_server = utf8mb4
max_connect_errors = 100
max_connections = 4050
max_user_connections = 4050
max_heap_table_size = 64M
max_allowed_packet = 1024M
max_binlog_size = 500M
thread_stack = 256K
interactive_timeout = 7200
wait_timeout = 86400
sort_buffer_size = 848KB
read_buffer_size = 848KB
read_rnd_buffer_size = 432KB
join_buffer_size = 432KB
net_buffer_length = 16K
thread_cache_size = 100
ft_min_word_len = 4
transaction_isolation = READ-COMMITTED
tmp_table_size = 2097152
table_open_cache = 2000
skip_name_resolve
core-file
lower_case_table_names = 1
log_bin_trust_function_creators = 1
log-bin =  mysql-bin.log
log-bin-index = log-bin.index
log-error = error.log
relay-log = relay.log
relay-log-info-file = relay-log.info
relay-log-index =  relay-log.index
master-info-file = master.info
log-slave-updates = 1
binlog_cache_size = 2048KB
sync_binlog = 1
log_warnings
slow_query_log_file = slow_query.log
slow_query_log = 1
log_output = TABLE
long_query_time = 1
binlog_format = ROW
server_id = 1844593058
auto_increment_increment = 1
auto_increment_offset = 1
slave_net_timeout = 60
key_buffer_size = 16M
bulk_insert_buffer_size = 4M
innodb_data_home_dir = /data/alisql
innodb_log_group_home_dir = /data/alisql
innodb_additional_mem_pool_size = 2097152
innodb_buffer_pool_size = 13108M
innodb_data_file_path = ibdata1:200M:autoextend
innodb_file_per_table =on
innodb_file_io_threads = 4
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 1500M
innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 75
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 50
innodb_doublewrite = 1
innodb_rollback_on_timeout = OFF
innodb_autoinc_lock_mode = 1
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_io_capacity = 2000
innodb_purge_threads = 1
master_info_repository = TABLE
relay_log_info_repository = TABLE
query_cache_type = 0
concurrent_insert = 1
query_cache_limit = 1048576
query_cache_min_res_unit = 1K
log-slow-admin-statements
innodb_stats_on_metadata = OFF
innodb_file_format = Barracuda
innodb_read_ahead = 0
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
default_storage_engine = InnoDB
innodb_stats_sample_pages = 8
open_files_limit = 65535
gtid_mode = ON
innodb_ft_max_token_size = 84
enforce-gtid-consistency = 1
log_bin_use_v1_row_events = 1
loose_performance_schema = off
loose_binlog_order_commits = OFF
loose_rds-anonymous-in-gtid-out-enable = 1
loose_tokudb_cache_size = 13108M
loose_opt_rds_enable_set_default_engine = OFF
loose_innodb_rds_autoinc_persistent_Interval = 1
delay_key_write = ON
key_cache_pision_limit = 100
innodb_old_blocks_pct = 37
loose_rds_gtid_precommit = ON
loose_implicit_primary_key = 1
ft_query_expansion_limit = 20
innodb_ft_min_token_size = 3
loose_tokudb_checkpointing_period = 60
innodb_thread_sleep_delay = 10000
loose_innodb_log_compressed_pages = OFF
init_connect = ''
loose_rds_sql_select_filter = ''
innodb_print_all_deadlocks = OFF
delayed_insert_timeout = 300
loose_thread_pool_stall_limit = 30
loose_thread_pool_oversubscribe = 10
loose_max_statement_time = 0
loose_tokudb_commit_sync = ON
binlog_stmt_cache_size = 32768
net_retry_count = 10
binlog_checksum = CRC32
low_priority_updates = 0
loose_tokudb_support_xa = ON
autocommit = 1
loose_rds_set_connection_id_enabled = ON
key_cache_age_threshold = 300
innodb_concurrency_tickets = 5000
loose_innodb_rds_log_checksum_algorithm = INNODB
table_definition_cache = 512
loose_rds_check_core_file_enabled = ON
loose_tokudb_rpl_lookup_rows = OFF
innodb_use_native_aio = 0
net_write_timeout = 60
loose_rds_threads_running_high_watermark = 50000
slave_exec_mode = strict
query_alloc_block_size = 8192
loose_tokudb_fs_reserve_percent = 5
max_prepared_stmt_count = 16382
net_read_timeout = 30
loose_innodb_rds_min_concurrency_tickets = 50
loose_rds_ic_reduce_hint_enable = OFF
max_write_lock_count = 102400
innodb_old_blocks_time = 1000
innodb_stats_method = nulls_equal
max_length_for_sort_data = 1024
query_prealloc_size = 8192
innodb_large_prefix = OFF
delayed_insert_limit = 100
group_concat_max_len = 1024
innodb_disable_sort_file_cache = ON
loose_tokudb_buffer_pool_ratio = 0
loose_innodb_rds_autoinc_persistent = ON
innodb_ft_min_token_size = 3
loose_rds_enable_log_global_var_update = ON
loose_opt_rds_last_error_gtid = ON
loose_skip_symbolic_links = ON
loose_tokudb_rpl_unique_checks = OFF
key_cache_block_size = 1024
loose_tokudb_directio = OFF
slow_launch_time = 2
innodb_online_alter_log_max_size = 134217728
innodb_open_files = 3000
eq_range_index_pe_limit = 10
p_precision_increment = 4
binlog_row_image = full
innodb_strict_mode = OFF
delayed_queue_size = 1000
default_week_format = 0
log_queries_not_using_indexes = OFF
innodb_read_ahead_threshold = 56
connect_timeout = 10
default_time_zone = SYSTEM
sql_mode = ''
innodb_table_locks = ON
query_cache_size = 3145728
innodb_adaptive_hash_index = ON
innodb_purge_BATch_size = 300
loose_innodb_rds_adaptive_tickets_algo = ON
loose_rpl_semi_sync_slave_trace_level = 1
loose_rpl_semi_sync_master_timeout = 1000
loose_rpl_semi_sync_master_trace_level = 1
loose_rpl_semi_sync_slave_enabled = OFF
loose_rpl_semi_sync_master_enabled = OFF
loose_rpl_semi_sync_master_wait_no_slave = ON
loose_rds_slave_read_no_lock = ON
loose_slave_parallel_workers = 8
loose_rds_expand_fast_index_creation = ON
loose_tokudb_row_format = tokudb_zlib
loose_rds_reset_all_filter = 0
loose_innodb_adaptive_hash_index_parts = 8
loose_tokudb_fsync_log_period = 0
loose_thread_handling = "one-thread-per-connection"
loose_rds_allow_unsafe_stmt_with_gtid = ON

[mysqldump]
quick
max_allowed_packet = 64M

[mysql]
no-auto-rehash
prompt = "\\u@\\h : \\d \\R:\\m:\\s> "

[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
user = mysql
basedir = /opt/alisql

[mysql_install_db]
basedir = /opt/alisql

初始化
cd /opt/alisql/scripts/
 
/opt/alisql/scripts/mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/data/alisql --pid-file=/tmp/alisql.pid --tmpdir=/tmp

cp /opt/alisql/support-files/mysql.server /etc/init.d/mysql
 
环境变量配置
#echo "PATH=/usr/local/alisql/bin:/usr/local/alisql/lib:$PATH" >> 
/etc/profile.d/alisql.sh 

# source  /etc/profile.d/alisql.sh 
 
启动并加入开机自启
# /etc/init.d/mysql restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL........ SUCCESS! 
chkconfig --level 35 mysql on

登录进入alisql:
mysql -p -S /tmp/alisql.sock
root@localhost : (none) 23:28:19> show variables like '%version%';
+-------------------------+---------------------+
| Variable_name           | Value               |
+-------------------------+---------------------+
| innodb_version          | 5.6.32              |
| protocol_version        | 10                  |
| slave_type_conversions  |                     |
| tls_version             | TLSv1               |
| tokudb_version          |                     |
| version                 | 5.6.32-log          |
| version_comment         | Source distribution |
| version_compile_machine | x86_64              |
| version_compile_os      | Linux               |
+-------------------------+---------------------+
9 rows in set (0.01 sec)

root@localhost : (none) 23:28:28> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| TokuDB             | YES     | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology | YES          | YES  | YES        |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)
 


--编译安装过程报错信息:
#/opt/alisql/scripts/mysql_install_db --user=mysql --basedir=/opt/alisql --datadir=/data/alisql --pid-file=/tmp/alisql.pid --tmpdir=/tmp
--报错信息:
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
--解决办法:
yum-y install autoconf
--启动的时候报错:
InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages
--解决办法:
#删除$datadir目录下的数据原有的数据问你.

文章参考:
https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/5.6/en/source-configuration-options.html
http://blog.fungo.me/2016/10/compile-alisql-from-source/

相关阅读

centOS 7下无法启动网络(service network start)错误解

   今天在centOS 7下更改完静态ip后发现network服务重启不了,翻遍了网络,尝试了各种方法,终于解决了。现把各种解决方法归纳整理,希

centos7设置时间为日本东京时间

1.首先我们先查看我们本地时间通过 ls -l /etc/localtime   命令 2.timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时

Linux(Centos7)下,阿帕奇(Apache)服务器的安装与配置

Y6   Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用

Linux 编译安装 ghostscript 最新版

1、下载地址https://www.ghostscript.com/download/gsdnld.html我写这个的时候最新版本是9.25下载Ghostscript 9.25 for Linux x8

SoftEther centos 服务器搭建

因为限制,关键字用 *** 代替 开始安装 1 安装部署 服务端 打开要安装的路径,可以自定义 # cd /usr/local/ 下载安装包 # w

分享到:

栏目导航

推荐阅读

热门阅读