RPM方式安装GreatSQL 8.0.25-16

Only1You1
发布于 2022-8-19 16:19
浏览
0收藏

 ● 一、系统信息
      ◆1.确认OS信息
      ◆2.OS优化调整
      ◆3.临时关闭 firewall 和 selinux
 ● 二、rpm安装
      ◆1.下载安装包
      ◆2.安装依赖包
      ◆3.依次安装下列软件包
      ◆4.替换配置文件
      ◆5.创建数据目录
      ◆6.启动服务
      ◆7.查看开启状态
      ◆8.启动后查看初始化的密码
      ◆9.设置下root密码
      ◆10.查看下版本
      ◆11.总结

一、系统信息


部署前提:准备一个干净的系统,确认先前没有安装过MySQL、Mariadb等相关服务,造成不必要的冲突。

 

1.确认OS信息

[root@mgr1 opt]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

[root@mgr1 opt]# uname -r
3.10.0-862.el7.x86_64
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

 

2.OS优化调整


其他一些OS调整这里不涉及,跳过。

 

3.临时关闭 firewall 和 selinux

systemctl stop firewalld.service
setenforce 0
  • 1.
  • 2.

二、rpm安装


1.下载安装包


将这4个文件下载并上传到 /opt 目录

● greatsql-client-8.0.25-16.1.el7.x86_64.rpm
● greatsql-devel-8.0.25-16.1.el7.x86_64.rpm
● greatsql-server-8.0.25-16.1.el7.x86_64.rpm
● greatsql-shared-8.0.25-16.1.el7.x86_64.rpm
下载地址:https://gitee.com/GreatSQL/GreatSQL/releases/GreatSQL-8.0.25-16

 

2.安装依赖包

yum install openssl-devel net-tools perl-devel -y
  • 1.

 

3.依次安装下列软件包

rpm -ivh greatsql-shared-8.0.25-16.1.el7.x86_64.rpm
rpm -ivh greatsql-client-8.0.25-16.1.el7.x86_64.rpm
rpm -ivh greatsql-server-8.0.25-16.1.el7.x86_64.rpm
rpm -ivh greatsql-devel-8.0.25-16.1.el7.x86_64.rpm
  • 1.
  • 2.
  • 3.
  • 4.

安装过程 greatsql-server-8.0.25-16.1.el7.x86_64.rpm 如果出现如下报错

 

file /etc/my.cnf from install of greatsql-server-8.0.25-16.1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64

file /usr/lib64/mysql/plugin/dialog.so from install of greatsql-server-8.0.25-16.1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64

 

则先卸载mariadb-libs,然后再执行

yum remove mariadb-libs -y
  • 1.

执行 rpm -qa|grep greatsql 确认下都装上了

greatsql-shared-8.0.25-16.1.el7.x86_64
greatsql-server-8.0.25-16.1.el7.x86_64
greatsql-client-8.0.25-16.1.el7.x86_64
greatsql-devel-8.0.25-16.1.el7.x86_64
  • 1.
  • 2.
  • 3.
  • 4.

 

4.替换配置文件


备份下原来的/etc/my.cnf文件

mv /etc/my.cnf /etc/my.cnf.`date +"%F"`
  • 1.

添加配置文件,直接复制到窗口执行即可。

以下配置在2核2G内存正常运行,根据硬件情况自己微调。

echo '
#my.cnf
[client]
socket = /data/GreatSQL/mysql.sock
[mysql]
loose-skip-binary-as-hex
prompt="(\\D)[\\u@GreatSQL][\\d]>"
no-auto-rehash
[mysqld]
user    = mysql
port    = 3306
server_id = 3306213
basedir = /usr
datadir    = /data/GreatSQL
socket    = /data/GreatSQL/mysql.sock
pid-file = mysql.pid
character-set-server = UTF8MB4
skip_name_resolve = 1

#若你的MySQL数据库主要运行在境外,请务必根据实际情况调整本参数
default_time_zone = "+8:00"

#performance setttings
lock_wait_timeout = 3600
open_files_limit    = 65535
back_log = 1024
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
thread_stack = 512K
sort_buffer_size = 4M
join_buffer_size = 4M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
thread_cache_size = 768
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M

#log settings
log_timestamps = SYSTEM
log_error = /data/GreatSQL/error.log
log_error_verbosity = 3
slow_query_log = 1
log_slow_extra = 1
slow_query_log_file = /data/GreatSQL/slow.log
long_query_time = 0.1
log_queries_not_using_indexes = 1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_bin = /data/GreatSQL/binlog
binlog_format = ROW
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
binlog_rows_query_log_events = 1
binlog_expire_logs_seconds = 604800
#MySQL 8.0.22前,想启用MGR的话,需要设置binlog_checksum=NONE才行
binlog_checksum = CRC32
gtid_mode = ON
enforce_gtid_consistency = TRUE

#myisam settings
key_buffer_size = 32M
myisam_sort_buffer_size = 128M

#replication settings
#master_info_repository = TABLE
#relay_log_info_repository = TABLE
relay_log_recovery = 1
slave_parallel_type = LOGICAL_CLOCK

#可以设置为逻辑CPU数量的2倍
slave_parallel_workers = 64
binlog_transaction_dependency_tracking = WRITESET
slave_preserve_commit_order = 1
slave_checkpoint_period = 2

#innodb settings
transaction_isolation = REPEATABLE-READ
innodb_buffer_pool_size = 256M
innodb_buffer_pool_instances = 8
innodb_data_file_path = ibdata1:12M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
#innodb_log_file_size = 48M
#innodb_log_files_in_group = 3
innodb_doublewrite_files = 2
innodb_max_undo_log_size = 4G

# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_open_files = 65534
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
innodb_print_ddl_logs = 1
innodb_status_file = 1

#注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快
innodb_status_output = 0
innodb_status_output_locks = 1
innodb_sort_buffer_size = 67108864

#innodb monitor settings
innodb_monitor_enable = "module_innodb"
innodb_monitor_enable = "module_server"
innodb_monitor_enable = "module_dml"
innodb_monitor_enable = "module_ddl"
innodb_monitor_enable = "module_trx"
innodb_monitor_enable = "module_os"
innodb_monitor_enable = "module_purge"
innodb_monitor_enable = "module_log"
innodb_monitor_enable = "module_lock"
innodb_monitor_enable = "module_buffer"
innodb_monitor_enable = "module_index"
innodb_monitor_enable = "module_ibuf_system"
innodb_monitor_enable = "module_buffer_page"
innodb_monitor_enable = "module_adaptive_hash"

#pfs settings
performance_schema = 1
#performance_schema_instrument = '%memory%=on'
performance_schema_instrument = '%lock%=on'
' > /etc/my.cnf
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.

 

5.创建数据目录

mkdir -p /data/GreatSQL
chown mysql.mysql /data/GreatSQL
  • 1.
  • 2.

 

6.启动服务


rpm安装会自动生成一个mysqld.service的启动服务,并设置为开机自启动,所以我们直接开启服务即可。

 

如果是第一次开启,mysqld.service服务会调用/usr/bin/mysqld_pre_systemd脚本进行数据初始化操作,此过程时间较长,请耐心等待!

systemctl start mysqld.service
  • 1.

如果开启过程出现

 

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

 

执行 journalctl -xe 发现以下内容,确认下相关的/data/GreatSQL/error.log文件存在且配置权限正常,可以尝试关闭selinux再进行开启

......
[ERROR] [MY-010338] [Server] Can't find error-message file '/usr/local/GreatSQL-8.0.25-15-Linux-glibc2.17-x86_64/s
[Warning] [MY-010091] [Server] Can't create test file /data/GreatSQL/mysqld_tmp_file_case_insensitive_test.lower-t
[Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /data/GreatSQL/ is case in
[ERROR] [MY-010187] [Server] Could not open file '/data/GreatSQL/error.log' for error logging: Permission denied
......
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

 

7.查看开启状态


启动服务后,查看下服务启动状态,关键字active (running)

[root@localhost GreatSQL]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-05-17 05:13:09 EDT; 50s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 32417 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 32506 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─32506 /usr/sbin/mysqld
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

8.启动后查看初始化的密码


记录下输出的初始化密码,稍后改密需要用到

cat /data/GreatSQL/error.log |grep 'root@localhost'|awk '{print $NF}'
  • 1.

9.设置下root密码

# 1.使用初始化的密码登陆
mysql -p -uroot -S /data/GreatSQL/mysql.sock

# 2.设置修改密码,把 GreatSQL.2022! 改成你需要设置的密码
[root@GreatSQL][(none)]> set password for root@'localhost'='GreatSQL.2022!';
[root@GreatSQL][(none)]> flush privileges;
[root@GreatSQL][(none)]> quit

# 3.新密码登陆下
mysql -uroot -p -S /data/GreatSQL/mysql.sock
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

10.查看下版本

[root@GreatSQL][(none)]>status
--------------
Server version:    8.0.25-16 GreatSQL (GPL), Release 16, Revision 8bb0e5af297
  • 1.
  • 2.
  • 3.

11.总结


以上就是使用rpm方式安装完成一个单机的GreatSQL,实际环境要根据硬件、系统等配置进行微调,不可直接用于生产。

分类
标签
已于2022-8-19 16:19:27修改
收藏
回复
举报
回复
    相关推荐