Linux软件包安装

1.软件包分类:

source:源码,需要编译之后才可以使用

源码包优点:开源,可以修改源码,可以自由切换功能,软件是通过编译安装的,稳定,效率高

缺点:

安装步骤多,容易出现安装时间长,由于是编译安装,安装报错难以解决。

   配置./configure-prefiex=/usr/local/python

   make

   make install

二进制包:.工业化生产--绿色的软件(相当于一个模块)、

bin二进制已近编译成功可以直接使用

【例1】:源码安装python3

1).将软件包拖入虚拟机

2).进行解压

[root@localhost ~]#  tar -zxvf Python-3.12.4.tgz
[root@localhost ~]# ls

anaconda-ks.cfg               jdk-22_linux-x64_bin.tar.gz  Python-3.12.4.tgz  tom

apache-tomcat-10.1.25.tar.gz  Python-3.12.4                todolist.jar

 3).进行安装编译--在解压后的目录中找到confi

[root@localhost ~]# cd Python-3.12.4
[root@localhost Python-3.12.4]#  ./configure prefix=/usr/local/python3124   //配置编译文件 prefiex--前置  =/usr/local--位置  python3124文件名
[root@localhost Python-3.12.4]# make
make:***没有指明目标并且找不到makefile。停止 解决措施
解决办法:缺少gcc依赖包因此需要下载gcc依赖包
[root@localhost Python-3.12.4]# yum -y install gcc
[root@localhost Python-3.12.4]# make

4).进行make install

[root@localhost Python-3.12.4]# make && make install

5).在/usr/local/python3.12 找到python3.12可执行文件

[root@localhost bin]# cd
[root@localhost ~]# cd /usr/local/python3124/
[root@localhost python3124]# ls
bin  include  lib  share
[root@localhost python3124]# cd bin
[root@localhost bin]# ls
2to3  2to3-3.12  idle3  idle3.12  pydoc3  pydoc3.12  python3  python3.12  python3.12-config  python3-config
[root@localhost bin]# ./py
pydoc3             pydoc3.12          python3            python3.12         python3.12-config  python3-config

6).执行python3.12

[root@localhost bin]# ./python3.1
Python 3.12.4 (main, Jul 10 2024, 10:00:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

6)修改配置文件

[root@localhost bin]# vim /etc/profile
在最后一行export PATH=/usr/local/python3124/:$PATH
[root@localhost bin]# soure /etc/profile

2.网络配置

1)查看网卡信息

[root@localhost bin]# ifconfig

-bash: ifconfig: 未找到命令 解决办法: yum -y install net-tools

[root@localhost ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.216.42  netmask 255.255.255.0  broadcast 192.168.216.255

        inet6 fe80::6487:64e7:954f:f84f  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:fa:8a:d9  txqueuelen 1000  (Ethernet)

        RX packets 28747  bytes 29654823 (28.2 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 15183  bytes 2819143 (2.6 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 580  bytes 50456 (49.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 580  bytes 50456 (49.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2)添加网卡

3)如何禁用或重新激活网卡,以及修改IP地址

[root@localhost ~]# ifconfig ens36 192.168.200.2 netmask 255.255.255.0  //修改网卡ens36的IP地址
[root@localhost ~]# ifconfig
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.200.2  netmask 255.255.255.0  broadcast 192.168.200.255
[root@localhost ~]# ifconfig ens36 down  //临时停用IP地址
[root@localhost ~]# ifconfig ens36 up

若停止则无法访问到:

4.hostname

1)临时修改hostname

[root@localhost ~]# hostname aa

[root@localhost ~]# hostname

aa

2)永久性修改hostname

方式1:

[root@localhost ~]# vim /etc/hostname
[root@localhost ~]# cat /etc/hostname
ll

方式2:

[root@localhost ~]# hostnamectl set-hostname mm

)查看本主机IP

[root@hostname ~]# hostname -i

 【例二】安装:redis

1.下装源文件

[root@localhost ~]#wget https://download.redis.io/redis-stable.tar.gz

[root@localhost ~]# ls

anaconda-ks.cfg               jdk-22_linux-x64_bin.tar.gz  Python-3.12.4.tgz  redis-stable.tar.gz  tom

apache-tomcat-10.1.25.tar.gz  Python-3.12.4                redis-stable       todolist.jar

2.解压文件

[root@localhost ~]# tar -xzvf redis-stable.tar.gz

3.将源文件移动到指定目录下可以使用mv 也可使用./configure

mv方式:

[root@localhost ~]# mv redis-stable /usr/local/

[root@localhost ~]# ls /usr/local/

apache-tomcat-10.1.25  bin  games    jdk-22.0.1  lib64    python3124    sbin   src

apache-tomcat-9.0.91   etc  include  lib         libexec  redis-stable  share

[root@localhost ~]# cd /usr/local/redis-stable/

[root@localhost redis-stable]# ls

00-RELEASENOTES     CONTRIBUTING.md  INSTALL    README.md   runtest-cluster    SECURITY.md    tests

BUGS                COPYING          Makefile   redis.conf  runtest-moduleapi  sentinel.conf  TLS.md

CODE_OF_CONDUCT.md  deps             MANIFESTO  runtest     runtest-sentinel   src            utils

4.进行make和 make && make install

 [root@localhost redis-stable]# make && make install

【例三】 安装:MongoDB并进行简单的增删改查

1.[root@hostname~]#wgethttps://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.1-1.el7.x86_64.rpm

--2024-07-10 15:45:05--  https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.1-1.el7.x86_64.rpm正在解析主机 repo.mongodb.org (repo.mongodb.org)... 99.86.4.24, 99.86.4.66, 99.86.4.126, ...正在连接 repo.mongodb.org (repo.mongodb.org)|99.86.4.24|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:28762832 (27M)

正在保存至: “mongodb-org-server-5.0.1-1.el7.x86_64.rpm”

100%[=======================================================================>] 28,762,832   268KB/s 用时 1m 50s

2024-07-10 15:47:05 (256 KB/s) - 已保存 “mongodb-org-server-5.0.1-1.el7.x86_64.rpm” [28762832/28762832])

[root@hostname ~]# ls

anaconda-ks.cfg               jdk-22_linux-x64_bin.tar.gz                Python-3.12.4.tgz    tom

apache-tomcat-10.1.25.tar.gz  mongodb-org-server-5.0.1-1.el7.x86_64.rpm  redis-stable.tar.gz

community                     Python-3.12.4                              todolist.jar

[root@hostname ~]#

2.解压

[root@hostname ~]# tar -zxvf mongodb-org-server-5.0.1-1.el7.x86_64.rpm 

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now  //但出现了错误 问题:下载的地址出错!!!
解决:自己在官网进行下载并拖拽至虚拟机

[root@hostname ~]# tar -zxvf mongodb-linux-x86_64-rhel70-3.6.3.tgz 

3.将   mongodb移动到指定目录下

[root@hostname ~]# mv mongodb-linux-x86_64-rhel70-3.6.3 /usr/local
[root@hostname ~]# cd /usr/local
[root@hostname local]# ls
apache-tomcat-10.1.25  bin  games    jdk-22.0.1  lib64    mongodb-linux-x86_64-rhel70-3.6.3  redis-stable  share
apache-tomcat-9.0.91   etc  include  lib         libexec  python3124                         sbin          src

4.切换到指定目录下 

[root@hostname local]# cd mongodb-linux-x86_64-rhel70-3.6.3/
[root@hostname mongodb-linux-x86_64-rhel70-3.6.3]# 

5.对配置文件进行编辑

[root@hostname mongodb-linux-x86_64-rhel70-3.6.3]# vim /etc/profile
[root@hostname mongodb-linux-x86_64-rhel70-3.6.3]# source /etc/profile
[root@hostname mongodb-linux-x86_64-rhel70-3.6.3]# 

6.

vim /etc/mongodb.conf
dbpath=/usr/local/mongodb/data/db
logpath=/usr/local/mongodb/log/mongodb.log
logappend=true
fork=true
bind_ip=192.168.4.51
replSet=rs1(随便写)
进入 bin 目录  cd /usr/local/mongodb/bin/

启动 MongoDB(-conf 使用配置文件方式启动)

 mongod -f /etc/mongodb.conf 

  • 11
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值