当前位置:   article > 正文

centos7安装SQL server2019_centos安装sqlserver2019

centos安装sqlserver2019

centos7安装SQL server2019

1、yum安装

# 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
# 配置 yum 源
yum -y install wget
wget -O /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
yum clean all
yum makecache fast

# 安装 SQLserver
yum install mssql-server
# 初始化配置 SQLserver
/opt/mssql/bin/mssql-conf setup
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

sqlserver

sqlserver

2、启动 SQLserver

systemctl start mssql-server
systemctl enable mssql-server

# 验证
systemctl status mssql-server

# SQLserver 的安装路径在/var/opt/mssql,配置文件在 /var/opt/mssql/mssql.conf。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3、配置 SQLserver

mssql-conf是在Linux上安装SQL Server 2017后的一个配置脚本。使用命令 /opt/mssql/bin/mssql-conf 可以对 SQLserver 的配置进行修改优化。支持设置以下参数:

配置选项描述
Agent 启用启用或禁用SQL Server代理
Collation 设置设置新的排序规则
Customer feedback 选择选择是否发送反馈给微软
Database Mail Profile 设置设置默认的数据库邮件配置
Default data directory 修改修改新的数据文件的默认路径
Default log directory 修改修改新的日志文件的默认路径
Default master database file directory 修改修改master数据库的默认路径
Default master database file name 修改修改master数据库文件的名称
Default dump directory 修改修改新的内存DUMP和其他排错文件的默认路径
Default error log directory 修改修改新的SQL Server错误日志文件、默认跟踪、系统健康会话扩展事件和Hekaton会话扩展事件文件
Default backup directory 修改修改新的备份文件的默认路径
Dump type 选择选择内存DUMP文件收集的DUMP类型
High availability 启用启用可用性组
Local Audit directory 配置配置一个添加本地审核文件的目录
Locale 配置配置SQL Server使用的地区(配置语言环境)
Memory limit 配置配置SQL Server内存限制
TCP port 修改修改SQL Server连接监听的端口
TLS 配置配置TLS(Transport Level Security)
Traceflags 设置设置服务使用的跟踪标识

示例1:启用 SQLServer 代理


/opt/mssql/bin/mssql-conf set sqlagent.enabled true

# 需要重启
systemctl restart mssql-server
  • 1
  • 2
  • 3
  • 4
  • 5

示例2:修改默认数据和日志目录位置

filelocation.defaultdatadir和filelocation.defaultlogdir 设置修改新的数据和日志文件创建的位置。默认路径是:/var/opt/mssql/data。修改到:/home/msdata,操作如下:


mkdir -p /home/mssql/data
mkdir -p  /home/mssql/log
chown -R mssql:mssql /home/mssql

# 使用mssql-conf脚本执行set命令修改默认数据目录
/opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /home/mssql/data
# 修改日志目录
/opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /home/mssql/log

# 需要重启
systemctl restart mssql-server
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

SQL server

4、docker方式安装

docker run -d -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=abc123!@#" -p 1433:1433 -v mssql:/var/opt/mssql --name mssql --hostname mssql -d mcr.microsoft.com/mssql/server
  • 1

5、安装 SQLserver 客户端 sqlcmd

yum install -y mssql-tools unixODBC-devel

echo "export PATH=$PATH:/opt/mssql-tools/bin" >> /etc/profile
source /etc/profile

# 连接 SQLserver
sqlcmd -S <SQLserver_IP> -U SA -p
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

6、新建数据库


CREATE DATABASE erpdata
ON PRIMARY
(
    NAME = 'MyDatabase_data',
    FILENAME = '/var/opt/mssql/data/erpdata_data.mdf',
    SIZE = 64MB,
    MAXSIZE = 4GB,
    FILEGROWTH = 10%
)
LOG ON
(
    NAME = 'MyDatabase_log',
    FILENAME = '/var/opt/mssql/data/erpdata_log.ldf',
    SIZE = 32MB,
    MAXSIZE = 1GB,
    FILEGROWTH = 500MB
);
GO
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/827582
推荐阅读
相关标签
  

闽ICP备14008679号