1、清理 YUM 的本地缓存和下载并创建新的元数据缓存。yum clean allyum makecache个别Kylin系统中默认的umask是0077需要修改一下否则新建的文件、目录权限控制太严格可能导致启动异常$umask0077 $touch/tmp/tmpfile $ls-l/tmp/tmpfile -rw-------1root root0Aug2916:48 /tmp/tmpfile $umask0022 $rm-f/tmp/tmpfile;touch/tmp/tmpfile $ls-l/tmp/tmpfile -rw-r--r--1root root0Aug2916:49 /tmp/tmpfile修改 /etc/bashrc 添加下面这行内容使之永久生效umask00222、安装依赖包yuminstall-ypkg-config perl libaio-devel numactl-devel numactl-libs net-tools openssl openssl-devel jemalloc jemalloc-devel perl-Data-Dumper perl-Digest-MD5 python2 perl-JSON perl-Test-Simple如果有报错的包去掉就行。3、下载自己的GreatSQL二进制包cat/etc/system-releaseuname-aldd--version4、解压包解压在这下面可以不用修改文件cd/usr/localtarxf GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64.tar.xz5、创建/etc/my.cnf文件[client]socket/data/GreatSQL/mysql.sock[mysql]loose-skip-binary-as-hex prompt(\\D)[\\uGreatSQL][\\d]no-auto-rehash[mysqld]usermysql port3306server_id3306lower_case_table_names0#大小写敏感basedir/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64 datadir/data/GreatSQL socket/data/GreatSQL/mysql.sock pid-filemysql.pid character-set-serverUTF8MB4 skip_name_resolveON default_time_zone8:00bind_address0.0.0.0secure_file_priv/data/GreatSQL# Performancelock_wait_timeout3600open_files_limit65535back_log1024max_connections1024max_connect_errors1000000table_open_cache4096table_definition_cache2048thread_stack512K sort_buffer_size4M join_buffer_size4M read_buffer_size8M read_rnd_buffer_size4M bulk_insert_buffer_size64M thread_cache_size768interactive_timeout600wait_timeout600tmp_table_size96M max_heap_table_size96M max_allowed_packet64M net_buffer_shrink_interval180sql_generate_invisible_primary_keyON loose-lock_ddl_polling_modeON loose-lock_ddl_polling_runtime200# Logslog_timestampsSYSTEM log_errorerror.log log_error_verbosity3slow_query_logON log_slow_extraON slow_query_log_fileslow.log long_query_time0.01log_queries_not_using_indexesON log_throttle_queries_not_using_indexes60min_examined_row_limit100log_slow_admin_statementsON log_slow_replica_statementsON log_slow_verbosityFULL log_binbinlog binlog_formatROW sync_binlog1binlog_cache_size4M max_binlog_cache_size6G max_binlog_size1G binlog_space_limit500G binlog_rows_query_log_eventsON binlog_expire_logs_seconds604800binlog_checksumCRC32 binlog_order_commitsOFF gtid_modeON enforce_gtid_consistencyON# Replicationrelay-logrelaylog relay_log_recoveryON replica_parallel_typeLOGICAL_CLOCK replica_parallel_workers16replica_preserve_commit_orderON replica_checkpoint_period2loose-rpl_read_binlog_speed_limit100# MGR 非集群直接删除这段loose-plugin_load_addmysql_clone.soloose-plugin_load_addgroup_replication.soloose-group_replication_group_nameaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1loose-group_replication_local_address172.16.16.10:33061loose-group_replication_group_seeds172.16.16.10:33061,72.16.16.12:33061,72.16.16.12:33061loose-group_replication_communication_stackXCOMloose-group_replication_recovery_use_sslOFF loose-group_replication_ssl_modeDISABLED loose-group_replication_start_on_bootOFF loose-group_replication_bootstrap_groupOFF loose-group_replication_exit_state_actionREAD_ONLY loose-group_replication_flow_control_modeDISABLEDloose-group_replication_single_primary_modeON loose-group_replication_enforce_update_everywhere_checksOFF loose-group_replication_majority_after_modeON loose-group_replication_communication_max_message_size10M loose-group_replication_arbitratorOFF loose-group_replication_single_primary_fast_mode1loose-group_replication_request_time_threshold100loose-group_replication_primary_election_modeGTID_FIRST loose-group_replication_unreachable_majority_timeout0loose-group_replication_member_expel_timeout5loose-group_replication_autorejoin_tries288loose-group_replication_recovery_get_public_keyON loose-group_replication_donor_threshold100report_host172.16.16.10# InnoDBinnodb_buffer_pool_size2G#如果是专用的数据库服务器则可以设置为物理内存的50%-70%视实际情况而定innodb_buffer_pool_instances8innodb_data_file_pathibdata1:12M:autoextend innodb_flush_log_at_trx_commit1innodb_log_buffer_size64M innodb_redo_log_capacity6Ginnodb_doublewrite_files64innodb_doublewrite_pages128innodb_max_undo_log_size4G innodb_io_capacity10000innodb_io_capacity_max20000innodb_open_files65535innodb_flush_methodO_DIRECT innodb_use_fdatasyncONinnodb_lru_scan_depth9000innodb_lock_wait_timeout10innodb_rollback_on_timeoutON innodb_print_all_deadlocksON innodb_online_alter_log_max_size4Ginnodb_print_ddl_logsOFF innodb_status_fileON innodb_status_outputOFF innodb_status_output_locksON innodb_sort_buffer_size64M innodb_adaptive_hash_indexOFF innodb_numa_interleaveOFF innodb_spin_wait_delay20innodb_print_lock_wait_timeout_infoOFF innodb_change_bufferingnone kill_idle_transaction300#旧版本这条会报错旧版无此参数#innodb_data_file_async_purge ON#innodb monitor settings#innodb_monitor_enable module_innodb,module_server,module_dml,module_ddl,module_trx,module_os,module_purge,module_log,module_lock,module_buffer,module_index,module_ibuf_system,module_buffer_page,module_adaptive_hash#pfs settingsperformance_schema1#performance_schema_instrument %memory%onperformance_schema_instrument%lock%on一般修改 basedir/datadir/innodb_buffer_pool_size 等几个选项就可以修改完后保存退出。6、新建mysql用户/sbin/groupadd mysql /sbin/useradd-gmysql mysql-d/dev/null-s/sbin/nologin7、新建数据库主目录并修改权限模式及属主mkdir-p/data/GreatSQLchown-Rmysql:mysql /data/GreatSQLchmod-R700/data/GreatSQL配置GreatSQL systemd服务推荐采用systemd来管理GreatSQL服务执行 vim /etc/systemd/system/greatsql.service 命令添加下面的内容bash[Unit]DescriptionGreatSQL ServerDocumentationman:mysqld(8)Documentationhttp://dev.mysql.com/doc/refman/en/using-systemd.htmlAfternetwork.targetAftersyslog.target[Install]WantedBymulti-user.target[Service]# some limits# file sizeLimitFSIZEinfinity# cpu timeLimitCPUinfinity# virtual memory sizeLimitASinfinity# open filesLimitNOFILE65535# processes/threadsLimitNPROC65535# locked memoryLimitMEMLOCKinfinity# total threads (userkernel)TasksMaxinfinityTasksAccountingfalseUsermysqlGroupmysql#如果是GreatSQL 5.7版本此处需要改成simple模式否则可能服务启用异常#如果是GreatSQL 8.0版本则可以使用notify#如果启动时my.cnf中增加daemonize1参数以daemon方式启动GreatSQL则可以采用forking模式#TypesimpleTypenotifyTimeoutSec10PermissionsStartOnlytrueExecStartPre/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld_pre_systemdExecStart/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld$MYSQLD_OPTSEnvironmentFile-/etc/sysconfig/mysqlRestarton-failureRestartPreventExitStatus1EnvironmentMYSQLD_PARENT_PID1PrivateTmpfalse注意确认文件中 ExecStartPre 和 ExecStart 两个参数指定的目录及文件名是否正确。如果不是安装到/usr/local目录下需要修改二进制包中的 mysqld_pre_systemd 脚本修改脚本中几处涉及 GreatSQL 安装路径的地方例如grep-nGreatSQL /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld_pre_systemd33:ret$(/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/my_print_defaults${instance:--defaults-group-suffix$instance}$section|\178: /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld${instance:--defaults-group-suffix$instance}--initialize\183:if[-x/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysql_ssl_rsa_setup-a!-e${datadir}/server-key.pem];then184: /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysql_ssl_rsa_setup--datadir$datadir--uidmysql/dev/null21以上几处修改后然后执行命令重载systemd加入 greatsql 服务如果没问题就不会报错systemctl daemon-reload8、添加动态依赖库编辑 /etc/ld.so.conf 文件增加以下几行内容/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/lib/ /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/lib/private /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/lib/mysqlrouter/ /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/lib/mysqlrouter/private保存退出执行下面的命令确认生效ldconfigldconfig-p|greplibprotobuf.so…libprotobuf.so.24.4.0 (libc6,x86-64) /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_6这个步骤的作用是加载 GreatSQL 自带的动态依赖库文件这样在运行 mysql/mysqld 等二进制文件时可能需要用到避免报错。9、启动GreatSQLsystemctl start greatsql首次启动可能会报错$ systemctl status greatsql● greatsql.service - GreatSQL ServerLoaded: loaded (/etc/systemd/system/greatsql.service; disabled; vendor preset: disabled)Active: failed (Result: exit-code) since …Docs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 1258165 ExecStart/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld $MYSQLD_OPTS (codeexited, status1/FAILURE)Process: 1257969 ExecStartPre/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld_pre_systemd (codeexited, status0/SUCCESS)Main PID: 1258165 (codeexited, status1/FAILURE)Status: “Server shutdown complete”systemd[1]: Starting GreatSQL Server…mysqld_pre_systemd[1257969]: mktemp: failed to create file via template ‘/var/lib/mysql-files/install-validate-password-plugin.XXXXXX.sql’: No such file or directorymysqld_pre_systemd[1257969]: chmod: cannot access ‘’: No such file or directorymysqld_pre_systemd[1257969]: /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld_pre_systemd: line 43: : No such file or directorymysqld_pre_systemd[1257969]: /usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysqld_pre_systemd: line 44: $initfile: ambiguous redirectsystemd[1]: greatsql.service: Main process exited, codeexited, status1/FAILUREsystemd[1]: greatsql.service: Failed with result ‘exit-code’.systemd[1]: Failed to start GreatSQL Server.查看错误日志/data/GreatSQL/error.log需手动创建 /var/lib/mysql-files 目录再次启动GreatSQL服务即可注意再次启动时因为要初始化必须先清空/data/GreatSQL不然还会报错。mkdir-p/var/lib/mysql-fileschown-Rmysql:mysql /var/lib/mysql-files systemctl start greatsql10、连接登入GreatSQL上面启动成功后会进行GreatSQL初始化时会为 rootlocalhost 用户生成一个随机密码记录在 error.log 日志文件中例如下面这样grep-iroot /data/GreatSQL/error.log... A temporary password is generatedforrootlocalhost: KO!pdiw5sJ先添加环境变量后再连接不然使用绝对路径/usr/local/GreatSQL-8.4.4-4-Linux-glibc2.28-x86_64/bin/mysql连接如果存在其它mysql客户端首次连接可能会报ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.原因是此客户端不受信任必须使用GREATSQL提供的客户端连接才行。mysql-uroot-pKO!pdiw5sJ登录后先修改密码才能执行命令。status;