时间:2021-07-01 10:21:17 帮助过:12人阅读
最小安装: 1. 选择English 2. DATE & TIME 修改好本地时间 SOFTWARE SELECTION默认的Minimal Install就好 INSTALLATION DESTINATION选一下 然后,Begin Installation 3. ROOT PASSWORD设置ROOT密码 USER CREATION设置新用户,勾选Make this user administrator 等待安装完成,点Reboot按钮。 配置静态IPv4: $ systemctl status NetworkManager.service 检查网络管理器服务状态 $ nmcli dev status DEVICE TYPE STATE CONNECTION ens33 ethernet disconnected -- lo loopback unmanaged -- 这里需要配置ens33 $ su # cd /etc/sysconfig/network-scripts # ls ifcfg* # vi ifcfg-ens33 配置的ens33 将 BOOTPROTO=dhcp 改为 BOOTPROTO=static 然后在下行添加: IPADDR=192.168.48.128 NETMASK=225.225.225.0 NM_CONTROLLED=no 将 ONBOOT=no 改为 ONBOOT=yes 保存退出vi(NM_CONTROLLED=no表示该接口通过该配置文件设置,而不是通过网络管理器) 注:如果使用dhcp动态IP 只要将 ONBOOT=no 改为 ONBOOT=yes 即可。 # systemctl restart netowrk.service # ip add 查看ip信息 配置光盘为安装源(注:后面有配置iso为安装源的,这里仅光盘镜像临时作为安装源使用): $ sudo ssh 192.168.48.128 -l root # cat /etc/yum.repos.d/CentOS-Media.repo 基本内容如下: [c7-media] name=CentOS-$releasever - Media baseurl=file:///media/CentOS/ file:///media/cdrom/ file:///media/cdrecorder/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 文件头的注释部分提示可以用命令 yum --enablerepo=c7-media [command] 或者 yum --disablerepo=\* --enablerepo=c7-media [command] 安装软件。 # ls /dev/cdrom # mkdir /media/cdrom # mount /dev/cdrom /media/cdrom 挂载cdrom 安装vim、gcc、g++: # yum --disablerepo=\* --enablerepo=c7-media install vim -y # yum --disablerepo=\* --enablerepo=c7-media install gcc gcc-c++ -y 安装mysql 5.6: 先将client和server两个rpm安装包复制到本机下载目录,然后在mac终端输入: $ sudo scp ~/Downloads/MySQL-*.rpm bob@192.168.48.128:/home/bob/ 复制client和server安装文件到/home/bob/目录下(注:也可以复制到其他目录,比如root@192.168.48.128:/usr/local/) 回到ssh: # rpm -qa|grep -i mariadb 查询mariadb,与mysql冲突,下面将查到的库一并强制删除(最小安装只有mariadb-libs) # rpm -e --nodeps mariadb-libs # groupadd -r mysql # useradd -g mysql mysql -d /home/mysql -s /sbin/nologin (注:mysql 5.7论坛版安装顺序是:common、libs、client、server) (注2:mariadb 10.2需要一些依赖:yum --disablerepo=\* --enablerepo=c7-media install lsof perl rsync boost perl-DBI -y 然后安装顺序是:galera、MariaDB-10.2.10-centos73-x86_64-*(放在同一目录下:compat、common、client、server) ) # yum --disablerepo=\* --enablerepo=c7-media install perl -y # rpm -ivh ./MySQL-client-5.6.34-1.el7.x86_64.rpm # yum --disablerepo=\* --enablerepo=c7-media install autoconf -y # rpm -ivh ./MySQL-server-5.6.34-1.el7.x86_64.rpm # rm -f MySQL-*.rpm # systemctl start mysql.service (注:mysql 5.7的启动服务是mysqld.service) (注2:mariadb 10.2启动服务是mysqld.service,mariadb也可以) # cat /root/.mysql_secret The random password set for the root user at Tue Feb 21 13:55:26 2017 (local time): vZQwDJLbxm_zHno_ (注:mysql 5.7的初始密码在log文件里 $ grep "temporary password" /var/log/mysqld.log 然后在调用mysql_secure_installation前,手动修改安全策略: $ mysql -uroot -p mysql> set global validate_password_policy=0; mysql> set global validate_password_length=0; mysql> exit 或者编辑 /etc/my.cnf [mysqld] validate_password=off ) (注2:mariadb 10.2没有初始密码,可以通过下面命令将密码设置为123456 /usr/bin/mysqladmin -u root password ‘123456‘ ) # /usr/bin/mysql_secure_installation 把随机密码粘贴到提示符,根据提示,改变root密码,移除匿名账户,禁用root远程登录,移除测试数据库,刷新权限。 (注:mysql 5.7在设置了前面的密码策略后,可能要多次输入简单的密码来确认) # mysql -uroot -p 创建新用户: mysql> create user ‘bob‘@‘%‘ identified by ‘123456‘; (如果用root账户远程连接:mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;) mysql> flush privileges; mysql> exit # firewall-cmd --zone=public --add-port=3306/tcp --permanent # firewall-cmd --reload ------ mysql emoji ------ 注意:utf8mb4的最低mysql版本支持版本为5.5.3+ 如果创建数据库、表、列时指定utf8mb4和utf8mb4_general_ci,下面应该可以不用设置。 1) 设置my.cnf $ sudo vim /etc/my.cnf(ubuntu的位置 /etc/mysql/my.cnf) [client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] character-set-client-handshake=FALSE character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci init_connect=‘SET NAMES utf8mb4‘ skip-name-resolve 保存后重启mysql $ systemctl restart mysql $ mysql -uroot -p mysql> SHOW VARIABLES WHERE Variable_name LIKE ‘character_set_%‘ OR Variable_name LIKE ‘collation%‘; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | | collation_connection | utf8mb4_general_ci | | collation_database | utf8mb4_unicode_ci | | collation_server | utf8mb4_unicode_ci | +--------------------------+----------------------------+ 11 rows in set 注:collation_connection、collation_database、collation_server是utf8mb4_general_ci没有关系。 2) 修改Database、Table、Column字符集: ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE table_name CHANGE column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 修复优化表 REPAIR TABLE table_name; OPTIMIZE TABLE table_name; 也可以用mysqlcheck命令优化所有数据库 $ mysqlcheck -uroot -p --auto-repair --optimize --all-databases 3) 对于Java来说mysql connector版本需高于5.1.13。 安装gogs: 先将linux_amd64.zip包复制到本机下载目录,然后在mac终端输入: $ sudo scp ~/Downloads/linux_amd64.tar.gz root@192.168.48.128:/root/ 复制linux_amd64.tar.gz文件到/root/目录下(注:也可以复制到其他目录,比如root@192.168.48.128:/usr/local/) 回到ssh: # groupadd -r git # useradd -g git git -d /home/git # mv /root/linux_amd64.tar.gz /home/git/ # chown git:git /home/git/linux_amd64.tar.gz (如果是zip文件:yum --disablerepo=\* --enablerepo=c7-media install unzip -y) # su git $ cd ~ $ tar xvfz linux_amd64.tar.gz (如果是zip文件:unzip linux_amd64.zip) $ ls gogs linux_amd64.tar.gz $ rm -f linux_amd64.tar.gz $ cd gogs $ chmod +x ./gogs $ cat ./scripts/mysql.sql DROP DATABASE IF EXISTS gogs; CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; $ mysql -uroot -p < scripts/mysql.sql $ mysql -uroot -p mysql> grant all privileges on gogs.* to ‘bob‘@‘%‘ identified by ‘123456‘; mysql> flush privileges; mysql> exit $ exit # cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/ # cat /etc/systemd/system/gogs.service [Unit] Description=Gogs After=syslog.target After=network.target After=mariadb.service mysqld.service postgresql.service memcached.service redis.service [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because # of that ### #LimitMEMLOCK=infinity #LimitNOFILE=65535 Type=simple User=git Group=git WorkingDirectory=/home/git/gogs ExecStart=/home/git/gogs/gogs web Restart=always Environment=USER=git HOME=/home/git [Install] WantedBy=multi-user.target 启动服务,配置防火墙 # systemctl start gogs.service # systemctl enable gogs.service # firewall-cmd --zone=public --add-port=3000/tcp --permanent # firewall-cmd --reload (ubuntu系统配置防火墙命令: sudo ufw allow 3000 sudo ufw enable) 然后在浏览器打开 http://192.168.48.128:3000 (注2:mariadb配置好后,主机也许不能用127.0.0.1连接,请用主机ip:192.168.48.128) 注:如果开启了selinux,可能需要关闭。 # vim /etc/sysconfig/selinux 将SELINUX=enforce改为disabled 需要重启。 无法使用ssh进行clone和push数据 如果http方式没问题,就是应为gogs的账户(这里是git账户)没有指定shell, 解决办法是: # cat /etc/shells /bin/sh /bin/bash ... # usermod -s /bin/bash git 升级gogs $ sudo service gogs stop $ sudo su - git $ cd ~ $ pwd /home/git $ ls gogs gogs-repositories $ mv gogs gogs_old $ wget https://dl.gogs.io/gogs_v$VERSION_$OS_$ARCH.tar.gz $ tar -zxvf gogs_v$VERSION_$OS_$ARCH.tar.gz $ ls gogs gogs_old gogs-repositories gogs_v$VERSION_$OS_$ARCH.tar.gz $ cp -R gogs_old/custom gogs $ cp -R gogs_old/data gogs $ cp -R gogs_old/log gogs $ sudo service gogs start 如果启动失败,可能是权限的问题: # chmod +x /home/git/gogs/gogs # chown -R git:git /home/git/gogs # service gogs start -------------------------- sudo $ su # vim /etc/sudoers 在 root ALL=(ALL) ALL后面添加相同一行,新行的root改成当前用户,然后w!写入,退出vim # exit $ 就可以了。 启动到命令行界面 graphical.target to multi-user.target $ systemctl get-default graphical.target $ sudo systemctl set-default multi-user.target Removed symlink /etc/systemd/system/default.target. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target. $ sudo reboot // boot to graphical desktop $ startx 更改所有权 chown -R youruser:youruser /home/youruser/* 更换shell # cat /etc/shells # echo $SHELL # usermod -s /sbin/nologin youruser # usermod -s /sbin/bash youruser 设置iso作为安装源 查看网址 # ip add 远程拷贝 $ scp ~/Desktop/CentOS-7-x86_64-Everything-1611.iso root@192.168.48.128:/usr/local/ 远程登录 $ ssh 192.168.48.128 -l root 移动文件到/usr/local/iso # mkdir /usr/local/iso # mv /usr/local/CentOS-7-x86_64-Everything-1611.iso /usr/local/iso/ 修改fstab,挂着iso到/mnt/centiso # vi /etc/fstab 追加: /usr/local/iso/CentOS-7-x86_64-Everything-1611.iso /mnt/centiso iso9660 defaults,ro,loop 0 0 创建挂载点并挂载: # mkdir /mnt/centiso # mount -a # ls /mnt/centiso CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL 记住这里面的GPG-KEY的文件,将用在yum配置源上 查看yum源 # ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo 新建一个cdrom.repo # vi cdrom.repo [CDROM] name=centiso baseurl=file:///mnt/centiso enabled=1 gpgcheck=0 gkgkey=file///mnt/centiso/RPM-GPG-KEY-CentOS-7 检查安装源 # yum list gcc Loaded plugins: fastestmirror CDROM | 3.6 kB 00:00 base | 3.6 kB 00:00 ... 可以看见CDROM安装源 安装vim # yum install vim
centos上安装mysql/mariadb安装gogs
标签:应该 status ip) mct itme cst prot pts pat