728x90
이번 포스트에서는 CentOS에 SQL Server를 설치해볼 예정이다. 무작정 따라 하기
콘셉트로 작성된 포스트이니.... 오류 발생 시엔 메모를 남기도록 하겠다...
SQL Server 실행 패키지 설치
아래 명령어를 따라 하자
$ sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 232 100 232 0 0 416 0 --:--:-- --:--:-- --:--:-- 417
$ sudo yum install -y mssql-server
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
packages-microsoft-com-mssql-server-2017 | 3.0 kB 00:00:00
updates | 2.9 kB 00:00:00
packages-microsoft-com-mssql-server-2017/primary_db | 32 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.3421.10-2 will be installed
--> Processing Dependency: libatomic for package: mssql-server-14.0.3421.10-2.x86_64
--> Running transaction check
---> Package libatomic.x86_64 0:4.8.5-44.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================================
Installing:
mssql-server x86_64 14.0.3421.10-2 packages-microsoft-com-mssql-server-2017 208 M
Installing for dependencies:
libatomic x86_64 4.8.5-44.el7 base 51 k
Transaction Summary
========================================================================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 208 M
Installed size: 1.0 G
Downloading packages:
(1/2): libatomic-4.8.5-44.el7.x86_64.rpm | 51 kB 00:00:00
warning: /var/cache/yum/x86_64/7/packages-microsoft-com-mssql-server-2017/packages/mssql-server-14.0.3421.10-2.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY00 ETA
Public key for mssql-server-14.0.3421.10-2.x86_64.rpm is not installed
(2/2): mssql-server-14.0.3421.10-2.x86_64.rpm | 208 MB 00:00:27
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 7.6 MB/s | 208 MB 00:00:27
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
Userid : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
From : https://packages.microsoft.com/keys/microsoft.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libatomic-4.8.5-44.el7.x86_64 1/2
Installing : mssql-server-14.0.3421.10-2.x86_64 2/2
+--------------------------------------------------------------+
Please run 'sudo /opt/mssql/bin/mssql-conf setup'
to complete the setup of Microsoft SQL Server
+--------------------------------------------------------------+
SQL Server needs to be restarted in order to apply this setting. Please run
'systemctl restart mssql-server.service'.
Verifying : libatomic-4.8.5-44.el7.x86_64 1/2
Verifying : mssql-server-14.0.3421.10-2.x86_64 2/2
Installed:
mssql-server.x86_64 0:14.0.3421.10-2
Dependency Installed:
libatomic.x86_64 0:4.8.5-44.el7
Complete!
설치하면서 나온 텍스트가 많아서 복잡하겠지만 아래의 두 명령어를 실행시킨 것이다.
$ sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
$ sudo yum install -y mssql-server
SQL Server 설치
다음으로 SQL Server를 설치하겠다.
sudo /opt/mssql/bin/mssql-conf setup 명령어를 실행하면 아래의 3가지를 입력하게 된다.
- SQL 버전 -> 이 포스트에선 Express 버전으로 설치한다.
- 설치하고자 하는 버전의 사용 조건에 동의하는지 여부! Yes!!
- Administrator Password
**메모리 부족 에러
sqlservr: This program requires a machine with at least 2000 megabytes of memory.
/opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory.
설치 마지막에 위와 같이 에러 메시지가 뜬다면 해당 서버에 메모리가 부족한 경우다....
내가 부족했다...
$ sudo /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:
1) Evaluation (free, no production use rights, 180-day limit)
2) Developer (free, no production use rights)
3) Express (free)
4) Web (PAID)
5) Standard (PAID)
6) Enterprise (PAID)
7) Enterprise Core (PAID)
8) I bought a license through a retail sales channel and have a product key to enter.
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409
Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.
Enter your edition(1-8): 3
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
Do you accept the license terms? [Yes/No]:yes
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
설치가 완료되었습니다. 이제 SQL Server를 시작하는 중입니다.
서비스 실행 확인
이제 SQL Server는 설치가 끝났다.
정상적으로 서비스가 실행 중인지 확인해본다.
$ systemctl status mssql-server
· mssql-server.service - Microsoft SQL Server Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
Active: active (running) since 화 2017-11-28 15:45:51 KST; 5min ago
Docs: https://docs.microsoft.com/en-us/sql/linux
Main PID: 6224 (sqlservr)
CGroup: /system.slice/mssql-server.service
├─6224 /opt/mssql/bin/sqlservr
└─6263 /opt/mssql/bin/sqlservr
11월 28 15:45:54 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:54.9...
11월 28 15:45:54 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:54.9...
11월 28 15:45:55 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:55.2...
11월 28 15:45:55 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:55.5...
11월 28 15:45:55 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:55.9...
11월 28 15:45:55 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:55.9...
11월 28 15:45:55 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:55.9...
11월 28 15:45:56 localhost.localdomain sqlservr[6224]: 2017-11-28 15:45:56.0...
11월 28 15:51:00 localhost.localdomain sqlservr[6224]: 2017-11-28 15:51:00.5...
11월 28 15:51:00 localhost.localdomain sqlservr[6224]: 2017-11-28 15:51:00.6...
Hint: Some lines were ellipsized, use -l to show in full.
SQL Server Command-line Tools 설치
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 462 0 --:--:-- --:--:-- --:--:-- 462
$ sudo yum install -y mssql-tools unixODBC-devel
Loaded plugins: fastestmirror, langpacks
packages-microsoft-com-prod | 2.9 kB 00:00:00
packages-microsoft-com-prod/primary_db | 43 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: data.nicehosting.co.kr
* extras: data.nicehosting.co.kr
* updates: centos.mirror.cdnetworks.com
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:14.0.6.0-1 will be installed
--> Processing Dependency: msodbcsql < 13.2.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
--> Processing Dependency: msodbcsql >= 13.1.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
---> Package unixODBC-devel.x86_64 0:2.3.1-11.el7 will be installed
--> Processing Dependency: unixODBC(x86-64) = 2.3.1-11.el7 for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libtemplate.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libtdsS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libsapdbS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: liboraodbcS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: liboplodbcS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbctxtS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbcnnS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbcminiS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbcdrvcfg2S.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbcdrvcfg1S.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libodbccr.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libnn.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libmimerS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Processing Dependency: libesoobS.so.2()(64bit) for package: unixODBC-devel-2.3.1-11.el7.x86_64
--> Running transaction check
---> Package msodbcsql.x86_64 0:13.1.9.1-1 will be installed
---> Package unixODBC.x86_64 0:2.3.1-11.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================
Package Arch Version Repository Size
========================================================================
Installing:
mssql-tools x86_64 14.0.6.0-1 packages-microsoft-com-prod 249 k
unixODBC-devel x86_64 2.3.1-11.el7 base 55 k
Installing for dependencies:
msodbcsql x86_64 13.1.9.1-1 packages-microsoft-com-prod 4.0 M
unixODBC x86_64 2.3.1-11.el7 base 413 k
Transaction Summary
========================================================================
Install 2 Packages (+2 Dependent packages)
Total download size: 4.7 M
Installed size: 5.6 M
Downloading packages:
(1/4): unixODBC-devel-2.3.1-11.el7.x86_64.rpm | 55 kB 00:00:00
(2/4): unixODBC-2.3.1-11.el7.x86_64.rpm | 413 kB 00:00:00
(3/4): mssql-tools-14.0.6.0-1.x86_64.rpm | 249 kB 00:00:00
(4/4): msodbcsql-13.1.9.1-1.x86_64.rpm | 4.0 MB 00:00:01
----------------------------------------------------------------------------------------------------------------
Total 2.6 MB/s | 4.7 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : unixODBC-2.3.1-11.el7.x86_64 1/4
The license terms for this product can be downloaded from
https://aka.ms/odbc131eula and found in
/usr/share/doc/msodbcsql/LICENSE.TXT . By entering 'YES',
you indicate that you accept the license terms.
Do you accept the license terms? (Enter YES or NO)
yes
Please enter YES or NO
Do you accept the license terms? (Enter YES or NO)
YES
Installing : msodbcsql-13.1.9.1-1.x86_64 2/4
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.
Do you accept the license terms? (Enter YES or NO)
YES
Installing : mssql-tools-14.0.6.0-1.x86_64 3/4
Installing : unixODBC-devel-2.3.1-11.el7.x86_64 4/4
Verifying : msodbcsql-13.1.9.1-1.x86_64 1/4
Verifying : unixODBC-devel-2.3.1-11.el7.x86_64 2/4
Verifying : unixODBC-2.3.1-11.el7.x86_64 3/4
Verifying : mssql-tools-14.0.6.0-1.x86_64 4/4
Installed:
mssql-tools.x86_64 0:14.0.6.0-1 unixODBC-devel.x86_64 0:2.3.1-11.el7
Dependency Installed:
msodbcsql.x86_64 0:13.1.9.1-1 unixODBC.x86_64 0:2.3.1-11.el7
Complete!
환경변수 설정
$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
$ source ~/.bashrc
SQL Server 접속 (로컬)
$ sqlcmd -U SA
Password:
1>
##DB 생성
1> create database TESTDB
2> go
테이블 생성 및 데이터 삽입, 확인
1> use TESTDB;
2> create table TEST (ID int, NAME varchar(10))
3> insert into TEST values (1, 'heni')
4> go
데이터베이스 컨텍스트가 'TESTDB'(으)로 변경되었습니다.
(1 rows affected)
1> select * from TEST
2> go
ID NAME
----------- ----------
1 heni
(1 rows affected)
##sqlcmd 명령 프롬프트 종료
1> quit
2> go
Msg 2812, Level 16, State 62, Server localhost, Line 1
저장 프로시저 'quit'을(를) 찾을 수 없습니다.
1> QUIT
설치 중 발생한 에러
1. UnicodeEncodeError
[root@e7ca3a728a4c home]# /opt/mssql/bin/mssql-conf setup
Error in localization. Using en_US.
Choose an edition of SQL Server:
1) Evaluation (free, no production use rights, 180-day limit)
2) Developer (free, no production use rights)
3) Express (free)
4) Web (PAID)
5) Standard (PAID)
6) Enterprise (PAID)
7) Enterprise Core (PAID)
8) I bought a license through a retail sales channel and have a product key to enter.
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748
Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.
Enter your edition(1-8): 3
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010
Choose the language for SQL Server:
(1) English
(2) Deutsch
Traceback (most recent call last):
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 280, in <module>
main()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 276, in main
processCommands()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 199, in processCommands
COMMAND_TABLE[args.which]()
File "/opt/mssql/bin/../lib/mssql-conf/mssql-conf.py", line 54, in handleSetup
exit(mssqlconfhelper.setupSqlServer(eulaAccepted, noprompt=args.noprompt))
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 818, in setupSqlServer
languageSelect(noprompt)
File "/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 170, in languageSelect
print (u"(3) Español")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 8: ordinal not in range(128)
"/opt/mssql/lib/mssql-conf/mssqlconfhelper.py", line 170 에서 명령어를 실행하다가 적절한 아스키 코드 값이 없어서 발생한 에러다. 해결법으로는 170라인 print (u"(3) Español") 명령어를 주석처리 해주어도 된다.
728x90
'DataBase > MSSQL' 카테고리의 다른 글
[MSSQL] DBCC SHRINKFILE - DB 데이터/로그 파일 축소하기 - 1편 (0) | 2022.05.03 |
---|---|
[MSSQL] 파일 그룹별로 디스크 할당량, 사용량, 할당 가능량 조회 쿼리 (0) | 2022.05.02 |
[MSSQL] 제약조건(CONSTRAINT)이란 ? (0) | 2022.04.20 |
[MSSQL] 테이블 컬럼 추가, 수정, 삭제 ALTER TABLE (0) | 2022.04.15 |
[MSSQL] 데이터베이스 파일그룹 정리 (0) | 2022.02.18 |