centos mysql安装_VMware安装Centos8并搭建基础服务器

b47c2e468f6b44c4c59fda49df057499.png

基础服务器包含CentosMINI版+GNOME+SSH+Python3.8+Jupyter+MySQL

1.安装

下载CentOS-minimal版本版本进行安装

minimal​mirrors.aliyun.com


使用Vmware的详细安装过程见视频

知乎视频​www.zhihu.com


设置root密码:datscicn ,并且添加一个用户,用户名为datscicn
设置虚拟机网络为桥接模式(自动检测)

2.连接网络

打开虚拟机,设置网络连接

cd /etc/sysconfig/network-scripts  
ls  
vi ifcfg-ens33  #修改ONBOOT=yes  
reboot

3.安装 GNOME 桌面

若采用 minimal 安装的系统,安装 gnome3 桌面,方便后面的系统操作
dnf groupinstall "Server with GUI"
设置桌面启动优先
systemctl set-default graphical.target
reboot

4.安装ssh服务并且免密远程登录

4.1. 安装ssh服务

1) 查看是否安装ssh服务
rpm -qa | grep ssh
2) 安装ssh服务
yum install openssh-server
3) 常用操作

systemctl status sshd.service      #检查SSH服务有没有启动:  
systemctl start sshd.service         #启动ssh服务  
systemctl restart sshd.service      #重启ssh服务   
systemctl enable sshd.service     #开机ssh自启  
systemctl stop sshd.service    #关闭ssh服务  
netstat -antp | grep sshd      #端口22是否启动

4.2. 免密远程登录

1) 在Mac客户端命令行生成公钥和私钥 cd ~/.ssh ssh-keygen -t rsa 之后回车两次,注:(Enter passphrase (empty for no passphrase): 可以设置密码) 结果生成两个文件id_rsa(私钥)和id_rsa.pub(公钥) 2) 登陆CentOS服务器端,创建ssh目录 mkdir /root/.ssh ifconfig #查看系统IP 3) 发送公钥到CentOS服务器端 scp ./.ssh/id_rsa.pub root@10.67.74.158:/root/.ssh 4) 登陆CentOS服务器端,设置公钥文件

ssh root@10.67.74.158  注:此时还是需要输入密码
cd /root/.ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys   #注:必须设置成600

5) 在Mac客户端输入# ssh root@10.67.74.158 ,即可无密码访问 6) 使用别名登录 vim ./.ssh/config

Host  lc00
    HostName   172.16.125.128
    Port       22
    User       root

5.yum源配置

1.备份原有的yum源 mkdir -p /root/back mv /etc/yum.repos.d/CentOS-Base.repo /root/back/CentOS-Base.repo.back 2.下载新的yum源(阿里) 因为我这是centos8,源就选择了Centos-8.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo 3.清除原有yum缓存: yum clean all 4.生成新的缓存: yum makecache

6.Python环境

6.1 升级自带Python3.6.8到3.8.5

  1. 下载Python3.8.5的压缩包

wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

  1. 解压Python3.8.5的压缩包

tar -xvf ./Python-3.8.5.tgz

  1. 安装编译Python所需要的依赖环境

yum -y install gcc zlib* libffi-devel

  1. 删除系统自带Python3文件夹(其余相关python3.6文件夹及文件可自行删除)

rm -rf /usr/bin/python3

  1. 进入Python3.8.5文件夹下进行操作

cd ./Python-3.8.5/ ./configure --prefix=/usr/local/bin/python3 make make install

  1. 创建Python3软链接

ln -s /usr/local/bin/python3/bin/python3 /usr/bin/python3

  1. 查看系统Python此时的版本

python3 -V

  1. 创建pip3软链接
pip3 --version
mv usr/local/python3.6/bin/pip3 /usr/bin/
hash -r
rm -rf  /usr/bin/pip3
rm -rf  /usr/local/bin/pip3
ln -s /usr/bin/pip3.8 /usr/bin/pip3
ln -s /usr/bin/pip3.8 /usr/local/bin/pip3
  1. 检查pip3软链接是否可用,命令:

pip3 list

6.2.切换pip源

mkdir /root/.pip
cd /root/.pip
vim ./pip.conf

[global]  
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

6.3.常用安装包

yum install  gcc gcc-c++ python38-devel.x86_64 cyrus-sasl-lib.x86_64   cyrus-sasl-devel.x86_64 cyrus-sasl-devel.x86_64  
pip3 install openpyxl 
pip3 install xlrd  
pip3 install numpy 
pip3 install scipy matplotlib pandas 
pip3 install seaborn scikit-learn 
pip3 install thrift_sasl sasl thrift
pip3 install pyhive pymysql 
pip3 install pyecharts

6.4.jupyter服务

pip3 install jupyterlab
1)生成配置文件
jupyter notebook --generate-config
默认生成了 /root/.jupyter/jupyter_notebook_config.py
jupyter notebook password
查看密码
cat /root/.jupyter/jupyter_notebook_config.json
2)修改配置文件 scp -r lc00:/root/.jupyter/jupyter_notebook_config.py ./

# 上述密码
c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$Vh9rdlOCEAtha9majLT5hA$d8mm+aEsCs1CXmk2stf3+Q'
# 启动打开目录
c.NotebookApp.notebook_dir = '/home/datscicn'
# 监听端口设置为8888或其他自己喜欢的端口
c.NotebookApp.port = 6636
# 允许远程访问
c.NotebookApp.allow_remote_access = True
# 是否允许notebook在root用户下运行.
c.NotebookApp.allow_root = True
# 将ip设置为*,意味允许任何IP访问
c.NotebookApp.ip  = '*'
# 服务器上并没有浏览器可以供Jupyter打开
c.NotebookApp.open_browser = False

scp -r ./jupyter_notebook_config.py lc00:/root/.jupyter
3)防火墙
需要启用到主机的HTTP和HTTPS通信,修改防火墙规则并添加以下条目(如果尚未完成)
firewall-cmd --zone=public --add-port=6636/tcp --permanent
systemctl restart firewalld
4)启动命令
nohup jupyter lab &

7.MySQL环境

7.1.安装mysql, mysql-server和mysql-libs

yum install mysql mysql-server mysql-libs

7.2.查看已安装的这些包的版本、作用等具体信息,比如:

rpm -qi mysql

7.3.管理MySQL服务

systemctl start mysqld
systemctl status mysqld

设置开机自动启动MySQL服务:
systemctl enable mysqld

7.4.配置MySQL

mysql_secure_installation
设置密码:Datsci@cn20
一路y

7.5.远程登录

在调用mysql_secure_installation程序时我们设置了默认拒绝root远程登录
如果要开放远程访问权限,需要先开放防火墙,允许3306访问:

firewall-cmd --permanent --zone=public --add-port=3306/tcp  
firewall-cmd --reload

然后登录root账户,选择mysql数据库,修改user表中root的host列(把localhost改成%,表示允许任意主机访问),最后刷新权限或重启服务器以使更改生效:
登录数据库
$ mysql -uroot -p

use mysql;
select user,host from user;
update user set host='%' where user='root';
select user,host from user;
flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值