Sql Server 脚本部署

+++++++++++++++++++++++++++++++++++++++++++
标题:SqlServer数据库实例部署
时间:2019年9月24日
内容:部署SqlServer单实例
参考:https://www.jianshu.com/p/2adcf1f0655d
https://blog.csdn.net/wujiandao/article/details/81638614
+++++++++++++++++++++++++++++++++++++++++++

CentOS安装sql server

#!/bin/bash

curl https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo > /etc/yum.repos.d/mssql-server.repo
yum install -y mssql-server
echo -e “\033[31m选择2—输入Yes—选择10—输入sa密码\033[0m”
sleep 10
sudo /opt/mssql/bin/mssql-conf setup

systemctl enable mssql-server
systemctl start mssql-server

#安装命令行工具
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
echo -e “\033[31m输入YES—输入YES\033[0m”
sleep 10
yum install -y mssql-tools unixODBC-devel

ln -s /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd

sqlcmd -S localhost -U SA -P ''

如有报错

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Can’t open lib ‘/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1’ : file not found.

1、解决过程
(1):看看文件权限

ll /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1

(2):看看文件的库

[root@master ~]# ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1
/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.3’ not found (required by /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1)

(3):发现/opt/lampp/lib/libstdc++.so.6缺少一个东西,看看系统的库有没有这个东西

find / -name “libstdc++.so.6”
strings /usr/lib64/libstdc++.so.6 | grep CXXABI

(4):发现系统的库有CXXABI_1.3.3,移走它

mv /opt/lampp/lib/libstdc++.so.6 /tmp/

(5):做个软连接

ln -s /usr/lib64/libstdc++.so.6 /opt/lampp/lib/libstdc++.so.6

(6):登录成功

sqlcmd -S localhost -U SA -P ''

centos7的部署脚本

#!/bin/bash

# 2019-09-12
# CentOS安装sql server
# 参考:https://www.jianshu.com/p/2adcf1f0655d
# https://blog.csdn.net/wujiandao/article/details/81638614

curl https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo > /etc/yum.repos.d/mssql-server.repo
yum install -y mssql-server
echo -e "\033[31m选择2---输入Yes---选择10---输入sa密码\033[0m"
sleep 10
sudo /opt/mssql/bin/mssql-conf setup

systemctl enable mssql-server
systemctl start mssql-server


# 安装命令行工具
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
echo -e "\033[31m输入YES---输入YES\033[0m"
sleep 10
yum install -y mssql-tools unixODBC-devel

ln -s /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
# sqlcmd -S localhost -U SA -P '<Password>'

# 报错
# Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1' : file not found.
# 解决
# 看看文件权限
# ll /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1
# 看看文件的库
# [root@master ~]# ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1
# /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.3' not found (required by /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.1.1)
# 发现/opt/lampp/lib/libstdc++.so.6缺少一个东西,看看系统的库有没有这个东西
# find / -name "libstdc++.so.6"
# strings /usr/lib64/libstdc++.so.6 | grep CXXABI
# 发现系统的库有CXXABI_1.3.3,移走它
# mv /opt/lampp/lib/libstdc++.so.6 /tmp/
# 做个软连接
# ln -s /usr/lib64/libstdc++.so.6 /opt/lampp/lib/libstdc++.so.6
# 登录成功
# sqlcmd -S localhost -U SA -P '<Password>'