我下载的R2019b_Linux.iso文件是一个完整的文件,若您的iso文件分为两个,可参考此处:
https://blog.csdn.net/u011387593/article/details/84883474
https://blog.csdn.net/elgong/article/details/82931416
下面的内容也有部分参考上述两位大神的博客,在此表示感谢。
1. 前期准备
下载镜像文件R2019b_Linux.iso和R2019b的许可证文件license.lic,并远程传输到服务器端(我用的软件是filezilla)。许可证文件是学校购买的,大家如果没有的话只能自己想办法了。
2. 进入R2019b_Linux.iso所在文件夹,挂载镜像:
- 创建挂载点:
mkdir -p home/MATLAB/mnt/
- 挂载镜像:
mount -o loop R2019b_Linux.iso home/MATLAB/mnt/
3. 修改配置文件
- 复制home/MATLAB/mnt/下的installer_input.txt文件到其他地方(因为挂载文件夹里都是写保护的)我放的是上一级文件夹,且在文件名后加了“_me”以示区别:
cp /mnt/installer_input.txt /home/MATLAB/installer_input_me.txt
- 用vim或其他编辑器打开“installer_input_me.txt”,设置安装密钥和ssh静默安装(此处提供的fileInstallationKey仅供参考,貌似后面的激活不受影响):
fileInstallationKey=09806-07443-53955-64350-21751-41297
agreeToLicense=yes
mode=silent
- 用
cd
退出到根目录(系统会要求到根目录),并确保自己是管理员身份,执行安装命令:
sudo /home/MATLAB/mnt/install -inputFile /home/MATLAB/installer_input_me.txt -mode silent
(*注:上述“-mode silent”是多余的,因为“installer_input_me.txt”中已经写明,此处仅作为参考)
4. 安装完成!
提示还需要安装额外的支持包,一般不需要。
5. 安装成功后进行激活:
/usr/local/Polyspace/R2019b/bin/activate_matlab.sh -propertiesFile /home/gpuk80/MATLAB/matlab/activate.ini
提示我失败:
Silent activation failed. Please see /tmp/aws_gpuk80.log for more information.
“aws_gpuk80.log”文件内容为:
(Oct 26, 2019 16:47:32)Starting activation process.
(Oct 26, 2019 16:47:32)Performing silent activation.
(Oct 26, 2019 16:47:35)No activateCommand set. Please add the activateCommand property to your configuration file.
(Oct 26, 2019 16:47:35)Silent activation failed. Please see /tmp/aws_gpuk80.log for more information.
提示“No activateCommand set”。当我打开activate.ini文件后发现激活命令有缺省,需要人为添加。再一次,由于挂载文件夹是只读的,所以还要把它复制到外面一层文件夹,为了区别我把它重命名为“activate_me.ini”。
下面的“activate_me.ini”文件内容中,
- isSilent表示“静默激活”,远程命令行操作需要选true。
- activateCommand有两个值: activateDcAnon / activateOffline,前者表示在线安装,需要激活码;后者表示离线安装,需要证书文件license.lic。
- 因为我选了离线安装,所以后两项缺省。
isSilent=true
activateCommand=activateOffline
licenseFile=/home/MATLAB/license.lic
activationKey=
installLicenseFileDir=
修改好ini文件后,运行
/usr/local/Polyspace/R2019b/bin/activate_matlab.sh -propertiesFile /home/gpuk80/MATLAB/activate_me.ini
在不同操作系统和机器上“activate_matlab.sh”文件位置可能不同,大家可以自己寻找。等待很短时间后,显示
至此完成激活。
5. 配置环境变量
为了可以直接输入matlab启动,把相关文件添加到环境变量:
vim /etc/profile
在文末添加上
#set matlab environment
export PATH=$PATH:/usr/local/Polyspace/R2019b/bin
保存退出后,执行:
source /etc/profile
至此,环境变量设置完成。现在可以直接在终端输入matlab即可打开。
6. 附录
(a) installer_input.txt文件内容
以下是installer_input.txt文件内容,均被"#"注释。详细给出了安装指南,这里只挑几个重要的讲:
- 如想安装指定的功能,在 SPECIFY PRODUCTS YOU WANT TO INSTALL 中删除对应注释,被注释功能将不会被安装!否则默认安装所有工具箱。
- 我把文件复制到外面一层的文件夹后,在文末添加了第3步的3行命令,并改名为“installer_input_me.txt”。等到安装的时候添加这个文件即可。
##################################################################
##
## Use this file to specify parameters required by the installer at runtime.
##
## Instructions for using this file.
##
## 1. Create a copy of this template file and fill in the required
## information.
##
## 2. Uncomment only those lines that start with a single '#'
## and set the desired values. All allowed values for the
## parameters are defined in the comments section for each
##