{"id":19398928,"url":"https://github.com/pschiffe/haiscsisimulator","last_synced_at":"2026-07-03T14:01:46.737Z","repository":{"id":80759480,"uuid":"44275550","full_name":"pschiffe/haiscsisimulator","owner":"pschiffe","description":"HA iSCSI Storage Simulator with Clients","archived":false,"fork":false,"pushed_at":"2015-10-19T12:37:23.000Z","size":156,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-16T05:23:54.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pschiffe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-14T20:48:42.000Z","updated_at":"2024-01-05T19:37:12.000Z","dependencies_parsed_at":"2023-03-12T12:08:54.807Z","dependency_job_id":null,"html_url":"https://github.com/pschiffe/haiscsisimulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pschiffe/haiscsisimulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffe%2Fhaiscsisimulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffe%2Fhaiscsisimulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffe%2Fhaiscsisimulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffe%2Fhaiscsisimulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pschiffe","download_url":"https://codeload.github.com/pschiffe/haiscsisimulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pschiffe%2Fhaiscsisimulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35088478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T11:07:40.619Z","updated_at":"2026-07-03T14:01:46.691Z","avatar_url":"https://github.com/pschiffe.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HA iSCSI Storage Simulator\n\nThis repo describes simple `HA iSCSI Storage` simulator with his `iSCSI Clients`. The HA Storage simulator is managed by 2 iSCSI controllers which are sharing one storage device. Remote clients of iSCSI Storage use multipath setup.\n\n```\n   /----------\\\n   | client 1 |\n   \\----------/\n       |\n       |  /----------\\\n       |  | client 2 |\n       |  \\----------/\n       |       |\n       |    /--+--------------\\\n       |    |                 |\n       +--------------------\\ |\n       |    |               | |\n       |    |               | |\n   /-------------\\     /------------\\\n   | Controller1 |     | Contoller2 |\n   \\-------------/     \\------------/\n        |                    |\n        \\--------+-----------/\n                 |\n          ( Local Storage )\n```\n\n## Infrastructure\n\nInfrastructure for the simulator consists of 3 virtual machines, client1, client2 and controller with CentOS 7.1. All machines have 2 network interfaces connected in 2 different networks. Controller has attached 2 virtual drives. For the quick and easy deployment I've used [Vagrant](https://www.vagrantup.com/) with [oh-my-vagrant](https://github.com/purpleidea/oh-my-vagrant).\n\n### Storage\n\nTo simulate storage I've created 2 virtual drives attached to the controller, one for each client. We can pretend that they are LUNs in some SAN. Alternative way could be single virtual drive with 2 image files. I chose the former option because I think it's closer to the real world scenario.\n\n### Controller\n\nReason why I used single machine for both iSCSI controllers is that virtual drives can be attached only to single machine. If we want both clients to be connected to both controllers, both controllers need access to both drives. To model this, I used one machine running 2 iSCSI targets with one drive each, listening on 2 network interfaces.\n\n### Clients\n\nEach client is connected to one iSCSI target via both network interfaces, using multipath setup.\n\n## Deployment\n\nThis section contains steps how to deploy described architecture.\n\n### Controller\n\nOn controller, I used [LIO](http://linux-iscsi.org/wiki/Main_Page) for iSCSI target. To install it:\n```\nyum install python-rtslib targetcli\n```\n\n`targetcli` is powerful tool for configuring LIO iSCSI target: (reference [here](http://linux-iscsi.org/wiki/Targetcli) and [here](http://linux-iscsi.org/wiki/ISCSI))\n```\ntargetcli\n  # Create 2 backstores of block type, one for each drive\ncd /backstores/block/\ncreate client1 /dev/vdb\ncreate client2 /dev/vdc\n  # Create 2 targets, one for each drive\ncd /iscsi/\ncreate iqn.2015-10.local.iscsi:client1\ncreate iqn.2015-10.local.iscsi:client2\n  # Add LUN to each target\ncd /iscsi/iqn.2015-10.local.iscsi:client1/tpg1/luns/\ncreate /backstores/block/client1\ncd /iscsi/iqn.2015-10.local.iscsi:client2/tpg1/luns/\ncreate /backstores/block/client2\n  # Delete default portals and create new for both interfaces\ncd /iscsi/iqn.2015-10.local.iscsi:client1/tpg1/portals/\ndelete 0.0.0.0 3260\ncd /iscsi/iqn.2015-10.local.iscsi:client2/tpg1/portals/\ndelete 0.0.0.0 3260\ncreate 192.168.121.161  # IP of eth0\ncreate 192.168.131.100  # IP of eth1\ncd /iscsi/iqn.2015-10.local.iscsi:client1/tpg1/portals/\ncreate 192.168.121.161  # IP of eth0\ncreate 192.168.131.100  # IP of eth1\n  # Set up authentication. I'm being brave here and using no authentication, because this is controlled enviroment.\n  # It is possible to setup regular authentication, allowing only selected clients, with username and password.\ncd /iscsi/iqn.2015-10.local.iscsi:client1/tpg1/\nset attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1\ncd /iscsi/iqn.2015-10.local.iscsi:client2/tpg1/\nset attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1\nexit\n```\n\nStart and enable `target` service:\n```\nsystemctl restart target\nsystemctl enable target\n```\n\n### Clients\n\nOn both clients, install required packages:\n```\nyum install iscsi-initiator-utils device-mapper-multipath\n```\n\nBecause there is currently bug in CentOS 7.1, where `fast_io_fail_tmo 5` option in `/etc/multipath.conf` is ignored (more info [BZ#980139](https://bugzilla.redhat.com/show_bug.cgi?id=980139)), we need to edit `/etc/iscsi/iscsid.conf` file and change `node.session.timeo.replacement_timeout` from value `120` to, for example, `5`, otherwise when one path in multipath setup stops working, process accessing the multipath device might be blocked for 2 minutes before path is evaluated as broken.\n\nDiscover target:\n```\niscsiadm --mode discovery --type sendtargets --portal 192.168.121.161  # IP of the controller\n```\n\nLogin to one of the targets:\n```\niscsiadm --mode node --login --targetname iqn.2015-10.local.iscsi:client1\n```\n\nEnable multipath:\n```\nmpathconf --enable --with_multipathd y\n```\n\nConfigure multipath `/etc/multipath.conf`:\n```\nblacklist {\n  devnode \"^vd[a-z]\"\n}\n\ndefaults {\n  user_friendly_names yes\n  find_multipaths yes\n  path_grouping_policy multibus  # So both paths are actively used\n}\n\nmultipaths {\n  multipath {\n    wwid   36001405f4812b956f2e4f56b527da9d5  # Needs to be changed to actual value\n    alias  mpatha\n  }\n}\n```\n\nRestart multipath service:\n```\nsystemctl restart multipathd\n```\n\nTo check actual state of multipath:\n```\nmultipath -ll\nmultipathd -k\"show paths\"\n```\n\nUse multipath device:\n```\necho -e \"n\\np\\n1\\n\\n\\nw\" | fdisk /dev/mapper/mpatha\n  # Reload partition table\npartprobe\nmkfs.xfs /dev/mapper/mpatha1\nmkdir -p /mnt/iscsi\necho '/dev/mapper/mpatha1  /mnt/iscsi  xfs  defaults,_netdev  0 0' \u003e\u003e /etc/fstab\nmount -a\n```\n\n## Simulating fail-over\n\nTo simulate fail-over, disable one network interface on controller:\n```\nifdown eth1\n```\n\nMultipath can be monitored on clients with:\n```\nmultipath -ll\nmultipathd -k\"show paths\"\n```\n\n## Automatic deployment\n\nAs I wrote in the beginning, I'm using [Vagrant](https://www.vagrantup.com/) with [oh-my-vagrant](https://github.com/purpleidea/oh-my-vagrant) to quickly deploy these virtual machines. Quick how-to (this should work for Fedora, probably CentOS/RHEL 7):\n\nDownload proper repo file from [https://copr.fedoraproject.org/coprs/purpleidea/oh-my-vagrant/](https://copr.fedoraproject.org/coprs/purpleidea/oh-my-vagrant/) or:\n```\ndnf copr enable purpleidea/oh-my-vagrant\n```\n\nInstall oh-my-vagrant:\n```\nyum install oh-my-vagrant\n```\n\nAdd yourself to the `vagrant` group:\n```\nusermod -aG vagrant $(whoami)\n```\n\nInit oh-my-vagrant (omv) in some temp directory, so it downloads all needed plugins:\n```\nmkdir /tmp/omv\ncd /tmp/omv\nomv init\ncd -\nrm -rf /tmp/omv\n```\n\nUse my repo:\n```\ngit clone https://github.com/pschiffe/haiscsisimulator.git\ncd haiscsisimulator/omv\nomv up\n```\n\n`omv` is just a wrapper around `vagrant` binary, so it accepts all the `vagrant` commands like `status`, `ssh`, `halt`...\n\nConnect to the controller and configure it together with clients:\n```\nomv ssh controller\nsudo su -\ncd /vagrant/simulator\n./distribute-keys.sh\nansible-playbook -i ansible-hosts ansible-playbook.yml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschiffe%2Fhaiscsisimulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpschiffe%2Fhaiscsisimulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpschiffe%2Fhaiscsisimulator/lists"}