CentOS 环境下的一些配置(安装软件)

3 篇文章 0 订阅
3 篇文章 0 订阅

本文基于CenOS 7.6 和 8.5

1. 构建CentOS 系统

  1. 制作CentOS 系统盘(推荐使用软碟通),具体步骤可自行查阅
  2. 修改系统启动项,重启F12进入选择U盘启动,进入启动界面
  3. (1)方案一
 // 将默认提示
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet
// 改为以下
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=U盘名称 quiet

(2)方案二

// 将将默认提示
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

// 改为以下
vmlinuz initrd=initrd.img linux dd quiet 
/* 查看U盘编号/盘符
** 如看到U盘对应盘符为sdaX(X为某个数字)
** 重启电脑
*/

//再次将
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet 
// 改成
vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdaX quiet 
// 执行安装操作

(3)方案三

// 启动项内容可能稍有区别
// 修改:
LABEL=CentOSx207x20x86_64
// 改为
/dev/sdb4

原理都是找到U盘代表的分区名,如果找不到一个一个试也能试出来

  1. 安装过程省略(分区可自行查阅)
  2. 启动项更新
yum -y install epel-release
yum -y install ntfs-3g
grub2-mkconfig -o /boot/grub2/grub.cfg
  1. CentOS 8 的yum源配置
// 下载yum源
curl https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo > /etc/yum.repos.d/Centos-vault-8.5.2111.repo

curl https://mirrors.aliyun.com/repo/epel-archive-8.repo > /etc/yum.repos.d/epel-archive-8.repo

// 更新配置 
yum clean all && yum makecache

2. 常用软件的安装

1. 安装git
  1. 对版本无要求可简易安装(默认1.8.3.1版本,版本老旧)
yum -y install git
  1. 手动安装更高级版本
// 版本自选,下载安装包(https://mirrors.edge.kernel.org/pub/software/scm/git/)
wget https://www.kernel.org/pub/software/scm/git/git-2.38.1.tar.gz

// 解压
tar -xzvf git-2.38.1.tar.gz

// 进入目录
cd git-2.38.1.tar.gz
 
// 安装依赖环境
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install -y gcc-c++ perl-ExtUtils-MakeMaker

// 检查环境,配置安装路径
./configure --prefix=/usr/local/git

// 编译安装
make && make install

// 添加到系统环境变量
vim ~/.bashrc

// 文件末尾添加如下内容:
# git
export PATH="/usr/local/git/bin:$PATH"

// 使配置生效
source ~/.bashrc

// 检查结果是否成功
git version

2. 安装nodejs、npm
// 下载某个node版本
wget https://npm.taobao.org/mirrors/node/v14.17.6/node-v14.17.6-linux-x64.tar.gz

// 解压文件
tar -xzvf node-v14.17.6-linux-x64.tar.gz

// 改名
mv node-v14.17.6-linux-x64 node

// 建立软链接
ln -s /usr/local/node/bin/node /usr/local/bin/node
ln -s /usr/local/node/bin/npm /usr/local/bin/npm

// 检测是否成功
npm -v
node -v

// 删除下载的安装包
rm -f node-v14.17.6-linux-x64.tar.gz
3.安装goland
// 下载goland
wget https://download.jetbrains.com.cn/go/goland-2022.2.4.tar.gz

// 解压
tar -xzvf goland-2022.2.4.tar.gz 

// 运行goland
/usr/local/GoLand-2022.2.4/bin/goland.sh

// 添加桌面
// 编辑文件goland.desktop内容如下,放置桌面即可
[Desktop Entry]
Version=2022.2.4
Name=Goland
Comment=Goland
Exec=/usr/local/GoLand-2022.2.4/bin/goland.sh
Icon=/usr/local/GoLand-2022.2.4/bin/goland.png
Terminal=false
Type=Application
Categories=Application;Network;Goland Software;
StartupNotify=true
Name[zh_CN]=Goland
Comment[zh_CN]=Goland



4. 安装golong
//下载并解压到/usr/local文件下
wget https://studygolang.com/dl/golang/go1.19.2.linux-amd64.tar.gz

//解压并复制到/user/local文件夹下
tar -zvxf go1.18.3.linux-amd64.tar.gz

// 编辑文件
vim /etc/profile

// 在文件后追加以下内容
export GOPROXY=https://goproxy.cn
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/root/go
export PATH=$PATH:$GOPATH/BIN

// 刷新环境变量
source /etc/profile
5. 安装vscode
## 导入Microsoft GPG key
rpm --import https://packages.microsoft.com/keys/microsoft.asc

## 创建源仓库文件
vim /etc/yum.repos.d/vscode.repo

[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

## 安装最新版本的 Visual Studio Code
dnf install code

## 添加root 用户
vim ~/.bashrc
##  添加一行
alias code='/usr/share/code/code . --no-sandbox --unity-launch'
## 报存生效
source ~/.bashrc

## 快捷方式点击无响应,更改VScode.desktop文件内容如下
## 修改 Exec=/usr/share/code/code --unity-launch  %F
Exec=/usr/share/code/code --unity-launch --no-sandbox %F

6.安装mysql(脚本安装)

参考连接 :https://blog.csdn.net/weixin_44772835/article/details/126514951
作者主页 :https://blog.csdn.net/weixin_44772835

#!/bin/bash
wget MySQL8.0 Download URL: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
wait 
. /etc/init.d/functions 
SRC_DIR=`pwd`
#MYSQL='mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz'
MYSQL='mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz'
COLOR='echo -e \E[01;31m'
END='\E[0m'
MYSQL_ROOT_PASSWORD=password
check (){
if [ $UID -ne 0 ]; then
 action "当前用户不是root,安装失败" false
  exit 1
fi
cd  $SRC_DIR
if [ !  -e $MYSQL ];then
        $COLOR"缺少${MYSQL}文件"$END
 $COLOR"请将相关软件放在${SRC_DIR}目录下"$END
        exit
elif [ -e /usr/local/mysql ];then
       action "数据库已存在,安装失败" false
        exit
else
 return
fi
} 
install_mysql(){
    $COLOR"开始安装MySQL数据库..."$END
 yum  -y -q install libaio numactl-libs &> /dev/null
    cd $SRC_DIR
   tar xf $MYSQL -C /usr/local/
    MYSQL_DIR=`echo $MYSQL| sed -nr 's/^(.*[0-9]).*/\1/p'`
    mv /usr/local/$MYSQL_DIR /usr/local/mysql
   id mysql &> /dev/null || { useradd -s /sbin/nologin -r mysql ; action "创建mysql用户"; }
   chown -R mysql.mysql /usr/local/mysql/     
    echo 'PATH=/usr/local/mysql/bin/:$PATH' > /etc/profile.d/mysql.sh
   . /etc/profile.d/mysql.sh
    ln -s /usr/local/mysql/bin/* /usr/bin/
    cat > /etc/my.cnf <<-EOF
[mysqld]
bind-address=0.0.0.0
#skip-grant-tables
basedir = /usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
log-error=/usr/local/mysql/mysql.log
pid-file=/usr/local/mysql/mysql.pid
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# default_authentication_plugin=mysql_native_password
# Disabling symbolic-links is recommended to prevent assorted security risks
# symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[client]
  socket = /usr/local/mysql/mysql.sock
  default-character-set=utf8
!includedir /etc/my.cnf.d
EOF
   [ -d /usr/local/mysql/data ] || mkdir /usr/local/mysql/data -p
    mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
   chkconfig --add mysqld
   chkconfig mysqld on
   
    service mysqld start
   [ $? -ne 0 ] && { $COLOR"数据库启动失败,退出!"$END;exit; }
    MYSQL_OLDPASSWORD=`awk '/A temporary password/{print $NF}' /usr/local/mysql/mysql.log`
    mysqladmin  -uroot -p$MYSQL_OLDPASSWORD password $MYSQL_ROOT_PASSWORD&>/dev/null
    action "数据库安装完成"
}
check
install_mysql
## 若启动mysql报错:
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
## 进入报错目录 /usr/lib64
cp  libtinfo.so.6 libtinfo.so.5

以上仅作为笔记记录,捣鼓系统需要耐心,可能会遇到各种不同的问题…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值