Google Code Prettify

2021年2月12日 星期五

install MS SQL Server@CentOS7

Vagrant.configure("2") do |config|
  config.vm.box = "generic/centos7"
  config.vm.box_check_update = false
  config.vm.box_download_insecure = true
  
  config.vm.define "db-server" do |db|
    # db.vm.synced_folder "mssql", "/var/opt/mssql"
    db.vm.synced_folder "mssql", "/home/vagrant/mssql"
    db.vm.hostname = "db-server"
    db.vm.provider "virtualbox" do |vb|
      vb.gui = false
      vb.memory = 4096
      vb.cpus = 1
    end
	  
    db.vm.network "private_network", ip: "192.168.50.13"
  end
end
vagrant 是管理 VM 很方便的工具,先到官網下載並安裝後,建立一個內容如上檔名為 Vagrantfile 的設定檔,然後在該檔所在的路徑執行如下指令:
vagrant up
vagrant ssh 192.168.50.13
這樣會啟動一個 CentOS 7 的 VM,接著 ssh 進入該 VM, 底下將在 VM 裡安裝 MS SQL Server 2019。 

設定套件
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
# Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried 
如果出現如上錯誤,編輯 /etc/resolv.conf,設定 nameserver 8.8.8.8,再安裝一次。

安裝 SQL Server 套件
sudo yum install -y mssql-server.x86_64

安裝 SQL Server (選 2 Developer)
sudo /opt/mssql/bin/mssql-conf setup
出現綠色 active (running) 表示 sql server 正常運行
sudo systemctl status mssql-server.service

啟用 SQL Server Agent
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
將 vagrant 加入 mssql 群組
sudo usermod -aG mssql vagrant

重新啟動 SQL Server 服務
sudo systemctl restart mssql-server

Confirm installation
sudo rpm -qi mssql-server

開防火牆
sudo firewall-cmd --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

安裝工具程式
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
sudo yum install compat-openssl10

Install SQL Server command-line tools
sudo yum -y install mssql-tools unixODBC-devel
設定開機後 sql server 自動啟動
sudo systemctl is-enabled mssql-server.service

Add /opt/mssql/bin/ to your $PATH variable
sudo echo 'export PATH=$PATH:/opt/mssql/bin:/opt/mssql-tools/bin' | sudo tee /etc/profile.d/mssql.sh
source /etc/profile.d/mssql.sh
# 改變預設路徑 
# sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /home/vagrant/mssql/data 
# sudo /opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /home/vagrant/mssql/log 

重啟 sql server
sudo systemctl restart mssql-server

1 則留言:

  1. Casinos Near Casinos Near Penn National Race Course
    Find Casinos 제주도 출장샵 Near Penn National 당진 출장안마 Race Course 제주도 출장샵 in Pennsylvania, 광주광역 출장샵 including Westmoreland Park, and Harrah's Philadelphia Casino. Mapyro 광주광역 출장샵 users can compare

    回覆刪除