Hướng dẫn cài bionic v3.0 wordpress
MS SQL liên quan tới hệ thống CSDL của Microsoft và bắt đầu được Open sourced từ năm 2016. Dưới đây là bài viết hướng dẫn cách cài và cấu hình MS SQL 2017 trên Ubuntu Linux x64 (Ubuntu 18.04 Bionic Beaver Linux). Dưới đây là cấu hình hệ thống cơ bản để cài và chạy MS SQL trên Ubuntu 18.04 / 16.04 server:
Phần 1. Cài đặt MS SQL Server trên Ubuntu 18.04 hoặc Ubuntu 16.04 LTS Bước 1: Cập nhật hệ thống Ubuntu Trên màn lệnh terminal của Ubuntu nhập 2 lệnh sau: sudo apt-get update sudo apt-get -y upgrade Nếu phần lỗi “kernel” đã được cập nhật xong, chúng ta sẽ nhập tiếp lệnh để khởi động lại Ubuntu: sudo reboot Bước 2: Nhập key GPG lưu trữ bộ cài MS SQL “repository GPG keys”: Nhập lệnh để thêm key: sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add – Bước 3: Thêm địa chỉ để download bộ cài Microsoft SQL Server Ubuntu repository: Nhập lệnh sau: sudo add-apt-repository “$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)” Bước 4: Nhập lệnh cài MS SQL Server 2017 trên Ubuntu 18.04/ Ubuntu 16.04 LTS Gõ 3 lệnh sau: sudo apt-get update sudo apt install libcurl3 sudo apt-get install -y mssql-server Màn hình các thao tác thực hiện sau: Reading package lists… 0% Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: grub-pc-bin libpython-all-dev python-all python-all-dev python-asn1crypto python-cffi-backend python-crypto python-cryptography python-dbus python-enum34 python-gi python-idna python-ipaddress python-keyring python-keyrings.alt python-pkg-resources python-secretstorage python-setuptools python-six python-wheel python-xdg Use ‘apt autoremove’ to remove them. The following NEW packages will be installed: mssql-server 0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded. Need to get 176 MB of archives. After this operation, 928 MB of additional disk space will be used. Get:1 https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial/main amd64 mssql-server amd64 14.0.3030.27-1 [176 MB] Fetched 176 MB in 5s (36.3 MB/s) Preconfiguring packages … Selecting previously unselected package mssql-server. (Reading database … 117280 files and directories currently installed.) Preparing to unpack …/mssql-server_14.0.3030.27-1_amd64.deb … Unpacking mssql-server (14.0.3030.27-1) … Processing triggers for libc-bin (2.27-3ubuntu1) … Setting up mssql-server (14.0.3030.27-1) … +————————————————————–+ 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’. Processing triggers for man-db (2.8.3-2) … Processing triggers for libc-bin (2.27-3ubuntu1) … Nếu đến đây xuất hiện lỗi: “mssql-server : Depends: openssl (<= 1.1.0) but 1.1.0g-2ubuntu4.1 is to be installed“. Đây là lỗi SSL, Chúng ta sẽ hạ version SSL bằng cách cài openssl và hạ version để cài lại cùng mssql server, nhập 3 lệnh sau: $ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb $ sudo dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb $ apt-get -y install mssql-server Khi việc cài đặt xong, chúng ta sẽ xử lý cấu hình của MSSQL thiết lập mật khẩu cho root user thông qua file /opt/mssql/bin/mssql-conf: Gõ lệnh sau: $ sudo /opt/mssql/bin/mssql-conf setup Choose an edition of SQL Server:
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): 2 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… ForceFlush is enabled for this instance. ForceFlush feature is enabled for log durability. Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /lib/systemd/system/mssql-server.service. Setup has completed successfully. SQL Server is now starting. Bây giờ chúng ta cần kiểm tra tình trạng đã khởi động của dịch vụ MS SQL, gõ lệnh: $ systemctl status mssql-server.service ● mssql-server.service – Microsoft SQL Server Database Engine Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-09-18 14:39:34 UTC; 21s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 3501 (sqlservr) Tasks: 108 CGroup: /system.slice/mssql-server.service ├─3501 /opt/mssql/bin/sqlservr └─3541 /opt/mssql/bin/sqlservr Sep 18 14:39:37 ubuntu18 sqlservr[3501]: [155B blob data] Sep 18 14:39:37 ubuntu18 sqlservr[3501]: [62B blob data] Sep 18 14:39:37 ubuntu18 sqlservr[3501]: [61B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [389B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [66B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [75B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [96B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [100B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [71B blob data] Sep 18 14:39:38 ubuntu18 sqlservr[3501]: [124B blob data] Bước 5: Cài công cụ MS SQL client và gói hỗ trợ kết nối unixODBC plugin Gõ lệnh sau:
2 Nếu gặp phải lỗi: Command ‘curl’ not found, but can be installed with: apt install curl Chúng ta sẽ cài thêm bộ lệnh curl bằng cách gõ lệnh: apt install curl Sau khi cài bổ sung curl xong, ta tiếp tục nhập lại lệnh:
0
1 Bước 6. Kết nối với MS-SQL console: # sqlcmd -S 127.0.0.1 -U SA Password: Nếu bạn gặp lỗi sau: Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746. Đây là lỗi do phiên bản SSL version 1 cần phải được cập nhật, chúng ta sẽ phải cài lại OpenSSL thư viện version 1.0 để kết nối với SQL Server. Thực hiện các lệnh sau:
Tiếp theo chúng ta có thể kiểm tra tình hình vận hành của MS-SQL Server bằng 3 lệnh sau: 1> create database testDB; Get a list database:
2
3
4
5
6
7
8
9
0
1 Phần 2. Lập trình, thiết kế CSDL và Administrator DBA: Các bạn có thể dùng tool Microsoft SQL Server Management Studio: Nhập thông tin địa chỉ tên/IPv4 của máy chủ MS-SQL server bạn vừa cài trên Ubuntu linux 18.04/16.04 LTS Phần mềm chuyên cho thiết kế, quản trị CSDL của MS-SQL Server 2017: Nếu cần thông tin hoặc học nâng cao về các công nghệ và phần mềm xử lý dữ liệu MS-SQL Database, Data-ware house, BI cho chuyên ngành của minh Hay tìm hiểu các môn đó trên trang web: https://robusta.vn/ Chúc các bạn thành công! |